docs / clenup (no functional code changes)

- added API examples for mathutils.Color/Euler/Quaternion/Matrix.
- corrected own bad spelling matricies --> matrices.
- minor pep8 edits.
- update CMake ignore file list.
This commit is contained in:
Campbell Barton 2011-10-17 02:20:53 +00:00
parent 8fae0c6d7e
commit 67c15da97d
11 changed files with 123 additions and 12 deletions

@ -27,6 +27,10 @@ IGNORE = (
"extern/eltopo/common/openglutils.cpp",
"extern/eltopo/eltopo3d/broadphase_blenderbvh.cpp",
"source/blender/imbuf/intern/imbuf_cocoa.m",
"extern/recastnavigation/Recast/Source/RecastLog.cpp",
"extern/recastnavigation/Recast/Source/RecastTimer.cpp",
"entern/audaspace/SRC/AUD_SRCResampleFactory.cpp",
"entern/audaspace/SRC/AUD_SRCResampleReader.cpp",
"extern/bullet2/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h",
"extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h",
@ -41,6 +45,10 @@ IGNORE = (
"extern/eltopo/common/meshes/TriangleIndex.hpp",
"extern/eltopo/common/meshes/meshloader.h",
"extern/eltopo/eltopo3d/broadphase_blenderbvh.h"
"extern/recastnavigation/Recast/Include/RecastLog.h",
"extern/recastnavigation/Recast/Include/RecastTimer.h",
"intern/audaspace/SRC/AUD_SRCResampleFactory.h",
"intern/audaspace/SRC/AUD_SRCResampleReader.h",
)
UTF8_CHECK = True

@ -0,0 +1,30 @@
import mathutils
# color values are represented as RGB values from 0 - 1, this is blue
col = mathutils.Color((0.0, 0.0, 1.0))
# as well as r/g/b attribute access you can adjust them by h/s/v
col.s *= 0.5
# you can access its components by attribute or index
print("Color R:", col.r)
print("Color G:", col[1])
print("Color B:", col[-1])
print("Color HSV: %.2f, %.2f, %.2f", col[:])
# components of an existing color can be set
col[:] = 0.0, 0.5, 1.0
# components of an existing color can use slice notation to get a tuple
print("Values: %f, %f, %f" % col[:])
# colors can be added and subtracted
col += mathutils.Color((0.25, 0.0, 0.0))
# Color can be multiplied, in this example color is scaled to 0-255
# can printed as integers
print("Color: %d, %d, %d" % (col * 255.0)[:])
# This example prints the color as hexidecimal
print("Hexidecimal: %.2x%.2x%.2x" % (col * 255.0)[:])

@ -1,3 +1,32 @@
import mathutils
import math
# todo
# create a new euler with default axis rotation order
eul = mathutils.Euler((0.0, math.radians(45.0), 0.0), 'XYZ')
# rotate the euler
eul.rotate_axis(math.radians(10.0), 'Z')
# you can access its components by attribute or index
print("Euler X", eul.x)
print("Euler Y", eul[1])
print("Euler Z", eul[-1])
# components of an existing euler can be set
eul[:] = 1.0, 2.0, 3.0
# components of an existing euler can use slice notation to get a tuple
print("Values: %f, %f, %f" % eul[:])
# the order can be set at any time too
eul.order = 'ZYX'
# eulers can be used to rotate vectors
vec = mathutils.Vector((0.0, 0.0, 1.0))
vec.rotate(eul)
# often its useful to convert the euler into a matrix so it can be used as
# transformations with more flexibility
mat_rot = eul.to_matrix()
mat_loc = mathutils.Matrix.Translation((2.0, 3.0, 4.0))
mat = mat_loc * mat_rot.to_4x4()

@ -1,3 +1,28 @@
import mathutils
import math
# todo
# create a location matrix
mat_loc = mathutils.Matrix.Translation((2.0, 3.0, 4.0))
# create an identitiy matrix
mat_sca = mathutils.Matrix.Scale(0.5, 4, (0.0, 0.0, 1.0))
# create a rotation matrix
mat_rot = mathutils.Matrix.Rotation(math.radians(45.0), 4, 'X')
# combine transformations
mat_out = mat_loc * mat_rot * mat_sca
print(mat_out)
# extract components back out of the matrix
loc, rot, sca = mat_out.decompose()
print(loc, rot, sca)
# it can also be useful to access components of a matrix directly
mat = mathutils.Matrix()
mat[0][0], mat[1][0], mat[2][0] = 0.0, 1.0, 2.0
mat[0][0:3] = 0.0, 1.0, 2.0
# each item in a matrix is a vector so vector utility functions can be used
mat[0].xyz = 0.0, 1.0, 2.0

@ -1,3 +1,23 @@
import mathutils
import math
# todo
# a new rotation 90 degrees about the Y axis
quat_a = mathutils.Quaternion((0.7071068, 0.0, 0.7071068, 0.0))
# passing values to Quaternion's directly can be confusing so axis, angle
# is supported for initializing too
quat_b = mathutils.Quaternion((0.0, 1.0, 0.0), math.radians(90.0))
print("Check quaternions match", quat_a == quat_b)
# like matrices, quaternions can be multiplied to accumulate rotational values
quat_a = mathutils.Quaternion((0.0, 1.0, 0.0), math.radians(90.0))
quat_b = mathutils.Quaternion((0.0, 0.0, 1.0), math.radians(45.0))
quat_out = quat_a * quat_b
# print the quat, euler degrees for mear mortals and (axis, angle)
print("Final Rotation:")
print(quat_out)
print("%.2f, %.2f, %.2f" % tuple(math.degrees(a) for a in quat_out.to_euler()))
print("(%.2f, %.2f, %.2f), %.2f" % (quat_out.axis[:] +
(math.degrees(quat_out.angle), )))

@ -106,7 +106,7 @@ There are also methods to access the current :class:`bge.types.KX_Scene`
Matricies as used by the game engine are **row major**
``matrix[row][col] = float``
:class:`bge.types.KX_Camera` has some examples using matricies.
:class:`bge.types.KX_Camera` has some examples using matrices.
*********
Variables

@ -404,7 +404,7 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel):
part = context.space_data.pin_id
layout.enabled = particle_panel_enabled(context, psys)
layout.prop(part, "use_dynamic_rotation")
if part.use_dynamic_rotation:
@ -433,7 +433,6 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel):
subsub = sub.column()
subsub.active = part.angular_velocity_mode != 'NONE'
subsub.prop(part, "angular_velocity_factor", text="")
class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):

@ -84,7 +84,7 @@ typedef struct SculptSession {
int modifiers_active; /* object is deformed with some modifiers */
float (*orig_cos)[3]; /* coords of undeformed mesh */
float (*deform_cos)[3]; /* coords of deformed mesh but without stroke displacement */
float (*deform_imats)[3][3]; /* crazyspace deformation matricies */
float (*deform_imats)[3][3]; /* crazyspace deformation matrices */
/* Partial redraw */
int partial_redraw;

@ -4351,7 +4351,7 @@ short proxylocked_constraints_owner (Object *ob, bPoseChannel *pchan)
* constraints either had one or no targets. It used to be called during the main constraint solving
* loop, but is now only used for the remaining cases for a few constraints.
*
* None of the actual calculations of the matricies should be done here! Also, this function is
* None of the actual calculations of the matrices should be done here! Also, this function is
* not to be used by any new constraints, particularly any that have multiple targets.
*/
void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, short ownertype, void *ownerdata, float mat[][4], float ctime)

@ -384,7 +384,7 @@ void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3
int totleft= sculpt_get_first_deform_matrices(scene, ob, deformmats, deformcos);
if(totleft) {
/* there are deformation modifier which doesn't support deformation matricies
/* there are deformation modifier which doesn't support deformation matrices
calculation. Need additional crazyspace correction */
float (*deformedVerts)[3]= *deformcos;

@ -1089,7 +1089,7 @@ static PyObject *Matrix_decompose(MatrixObject *self)
PyDoc_STRVAR(Matrix_lerp_doc,
".. function:: lerp(other, factor)\n"
"\n"
" Returns the interpolation of two matricies.\n"
" Returns the interpolation of two matrices.\n"
"\n"
" :arg other: value to interpolate with.\n"
" :type other: :class:`Matrix`\n"
@ -1669,7 +1669,7 @@ static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item)
}
else {
PyErr_SetString(PyExc_IndexError,
"slice steps not supported with matricies");
"slice steps not supported with matrices");
return NULL;
}
}
@ -1701,7 +1701,7 @@ static int Matrix_ass_subscript(MatrixObject* self, PyObject* item, PyObject* va
return Matrix_ass_slice(self, start, stop, value);
else {
PyErr_SetString(PyExc_IndexError,
"slice steps not supported with matricies");
"slice steps not supported with matrices");
return -1;
}
}