[Bf-python] Patch for quaternion element confusion.
Michael Reimpell
M.Reimpell at tu-bs.de
Tue Nov 23 19:56:00 CET 2004
This patch fixes a bug in quat.c (wrong initialization with
newQuaternionObject( NULL )), corrects some typos in the BPy api doc and
gives additional information about the parameters to the constructors of
Quaternion([w,x,y,z]) and Vector([x,y,z,w]) in the BPy api.
Regards,
Michael
-------------- next part --------------
Index: blender/python/api2_2x/quat.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/quat.c,v
retrieving revision 1.5
diff -u -r1.5 quat.c
--- blender/python/api2_2x/quat.c 12 Oct 2004 23:58:03 -0000 1.5
+++ blender/python/api2_2x/quat.c 23 Nov 2004 18:47:48 -0000
@@ -531,13 +531,17 @@
&Quaternion_SeqMethods, /*tp_as_sequence */
};
-/*
- newQuaternionObject
-
- if the quat arg is not null, this method allocates memory and copies *quat into it.
- we will free the memory in the dealloc routine.
-*/
-
+/** Creates a new quaternion object.
+ *
+ * Memory for a new quaternion is allocated. The quaternion copies the given
+ * list of parameters or initializes to the identity, if a <code>NULL</code>
+ * pointer is given as parameter. The memory will be freed in the dealloc
+ * routine.
+ *
+ * @param quat Pointer to a list of floats for the quanternion parameters w, x, y, z.
+ * @return Quaternion Python object.
+ * @see Quaternion_Identity
+ */
PyObject *newQuaternionObject( float *quat )
{
QuaternionObject *self;
@@ -550,10 +554,7 @@
self->quat = PyMem_Malloc( 4 * sizeof( float ) );
if( !quat ) {
- for( x = 0; x < 4; x++ ) {
- self->quat[x] = 0.0f;
- }
- self->quat[3] = 1.0f;
+ Quaternion_Identity(self);
} else {
for( x = 0; x < 4; x++ ) {
self->quat[x] = quat[x];
Index: blender/python/api2_2x/doc/Mathutils.py
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/doc/Mathutils.py,v
retrieving revision 1.3
diff -u -r1.3 Mathutils.py
--- blender/python/api2_2x/doc/Mathutils.py 28 Jul 2004 09:00:46 -0000 1.3
+++ blender/python/api2_2x/doc/Mathutils.py 23 Nov 2004 18:47:48 -0000
@@ -319,7 +319,7 @@
v = Blender.Mathutils.Vector([1,0,0])
@type list: PyList of float or int
@param list: The list of values for the Vector object.
- Must be 2, 3, or 4 values.
+ Must be 2, 3, or 4 values. The list is mapped to the parameters as [x,y,z,w].
@rtype: Vector object.
@return: It depends wheter a parameter was passed:
- (list): Vector object initialized with the given values;
@@ -429,7 +429,7 @@
@type list: PyList of int/float
@param list: A 3d or 4d list to initialize quaternion.
- 4d if intializing, 3d if will be used as an axis of rotation.
+ 4d if intializing [w,x,y,z], 3d if used as an axis of rotation.
@type angle: float (optional)
@param angle: An arbitrary rotation amount around 'list'.
List is used as an axis of rotation in this case.
@@ -527,7 +527,7 @@
def determinant():
"""
- Return a the determinant of a matrix.
+ Return the determinant of a matrix.
@rtype: int
@return: Return a the determinant of a matrix.
@@ -540,9 +540,12 @@
def rotationPart():
"""
- Return the 3d rotation matrix.
+ Return the 3d submatrix corresponding to the linear term of the
+ embedded affine transformation in 3d. This matrix represents rotation
+ and scale. Note that the (4,4) element of a matrix can be used for uniform
+ scaling, too.
@rtype: Matrix object.
- @return: Return the 3d rotation matrix.
+ @return: Return the 3d matrix for rotation and scale.
"""
@@ -561,17 +564,17 @@
def toEuler():
"""
- Return a euler representing the rotation matrix.
+ Return an Euler representation of the rotation matrix.
@rtype: Euler object
- @return: Return a euler representing the rotation matrix.
+ @return: Euler representation of the rotation matrix.
"""
def toQuat():
"""
- Return a quaternion representation the rotation matrix
+ Return a quaternion representation of the rotation matrix
@rtype: Quaternion object
- @return: Quaternion representation the rotation matrix
+ @return: Quaternion representation of the rotation matrix
"""
More information about the Bf-python
mailing list