Documentation: updated mathutils documentation

Added descriptions of the constructors, and improved the module-level
documentation.
This commit is contained in:
Sybren A. Stüvel 2015-02-01 16:06:32 +01:00
parent fd75796afe
commit baa8b63111
6 changed files with 65 additions and 6 deletions

View File

@ -38,7 +38,18 @@
#endif
PyDoc_STRVAR(M_Mathutils_doc,
"This module provides access to matrices, eulers, quaternions and vectors."
"This module provides access to the math classes:\n"
"\n"
"- :class:`Color`,\n"
"- :class:`Euler`,\n"
"- :class:`Matrix`,\n"
"- :class:`Quaternion`,\n"
"- :class:`Vector`,\n"
"\n"
".. note::\n"
"\n"
" Classes, methods and attributes that accept vectors also accept other numeric sequences,\n"
" such as tuples, lists."
);
static int mathutils_array_parse_fast(float *array,
int size,

View File

@ -811,7 +811,12 @@ static struct PyMethodDef Color_methods[] = {
/* ------------------PY_OBECT DEFINITION-------------------------- */
PyDoc_STRVAR(color_doc,
"This object gives access to Colors in Blender."
".. class:: Color(rgb)\n"
"\n"
" This object gives access to Colors in Blender.\n"
"\n"
" :param rgb: (r, g, b) color values\n"
" :type rgb: 3d vector\n"
);
PyTypeObject color_Type = {
PyVarObject_HEAD_INIT(NULL, 0)

View File

@ -657,7 +657,14 @@ static struct PyMethodDef Euler_methods[] = {
/* ------------------PY_OBECT DEFINITION-------------------------- */
PyDoc_STRVAR(euler_doc,
"This object gives access to Eulers in Blender."
".. class:: Euler(angles, order='XYZ')\n"
"\n"
" This object gives access to Eulers in Blender.\n"
"\n"
" :param angles: Three angles, in radians.\n"
" :type angles: 3d vector\n"
" :param order: Optional order of the angles, a permutation of ``XYZ``.\n"
" :type order: str\n"
);
PyTypeObject euler_Type = {
PyVarObject_HEAD_INIT(NULL, 0)

View File

@ -2716,7 +2716,14 @@ static struct PyMethodDef Matrix_methods[] = {
/*------------------PY_OBECT DEFINITION--------------------------*/
PyDoc_STRVAR(matrix_doc,
"This object gives access to Matrices in Blender."
".. class:: Matrix([rows])\n"
"\n"
" This object gives access to Matrices in Blender, supporting square and rectangular\n"
" matrices from 2x2 up to 4x4.\n"
"\n"
" :param rows: Sequence of rows.\n"
" When ommitted, a 4x4 identity matrix is constructed.\n"
" :type rows: 2d number sequence\n"
);
PyTypeObject matrix_Type = {
PyVarObject_HEAD_INIT(NULL, 0)

View File

@ -187,6 +187,8 @@ PyDoc_STRVAR(Quaternion_to_exponential_map_doc,
"\n"
" :return: exponential map.\n"
" :rtype: :class:`Vector` of size 3\n"
"\n"
" To convert back to a quaternion, pass it to the :class:`Quaternion` constructor.\n"
);
static PyObject *Quaternion_to_exponential_map(QuaternionObject *self)
{
@ -1226,7 +1228,29 @@ static PyGetSetDef Quaternion_getseters[] = {
/* ------------------PY_OBECT DEFINITION-------------------------- */
PyDoc_STRVAR(quaternion_doc,
"This object gives access to Quaternions in Blender."
".. class:: Quaternion([seq, [angle]])\n"
"\n"
" This object gives access to Quaternions in Blender.\n"
"\n"
" :param seq: size 3 or 4\n"
" :type seq: :class:`Vector`\n"
" :param angle: rotation angle, in radians\n"
" :type angle: float\n"
"\n"
" The constructor takes arguments in various forms:\n"
"\n"
" (), *no args*\n"
" Create an identity quaternion\n"
" (*wxyz*)\n"
" Create a quaternion from a ``(w, x, y, z)`` vector.\n"
" (*exponential_map*)\n"
" Create a quaternion from a 3d exponential map vector.\n"
"\n"
" .. seealso:: :meth:`to_exponential_map`\n"
" (*axis, angle*)\n"
" Create a quaternion representing a rotation of *angle* radians over *axis*.\n"
"\n"
" .. seealso:: :meth:`to_axis_angle`\n"
);
PyTypeObject quaternion_Type = {
PyVarObject_HEAD_INIT(NULL, 0)

View File

@ -2904,7 +2904,12 @@ static struct PyMethodDef Vector_methods[] = {
*/
PyDoc_STRVAR(vector_doc,
"This object gives access to Vectors in Blender."
".. class:: Vector(seq)\n"
"\n"
" This object gives access to Vectors in Blender.\n"
"\n"
" :param seq: Components of the vector, must be a sequence of at least two\n"
" :type seq: sequence of numbers\n"
);
PyTypeObject vector_Type = {
PyVarObject_HEAD_INIT(NULL, 0)