[Bf-python] Mathutils

Joseph Gilbert models at paposo.com
Thu Feb 12 03:55:26 CET 2004


Well here she is.  After many hours Ive checked all the math in this thing.
I am sure all the math is correct, except for a problem with the euler
conversions.

I am currently using EulerToQuat and EulerToMat3 which are defined in
arthrib.c.  Problem is that it doesn't return the correct matrix/quaternion.
Example:(using the new module)

eul = Euler([90,0,0]) #90 degree rotation around X axis
mat = RotationMatrix(90,3,'x') #90 degree rotation around X axis

e2 = mat.toEuler()
print e2

(output is [90,0,0])

m2 = eul.toMatrix()
e3 = m2.toEuler()
print e3

(output is [116,0,0])

The quat->matrix, quat->euler, mat->euler, mat->quat all seem to work o.k.
however, eul->matrix, and eul->quat don't seem to return the correct
rotation.  These function are used in other blender code so though.

Other than that all the math is fine.
The main module is called Mathutils which consists of 4 submodules: vector,
quaternion, matrix and euler.
Each submodule consists has it's own internal functions for self
manipulation.
Mathutils consists of the following functions:
Rand
Vector
CrossVecs
DotVecs
AngleBetweenVecs
MidpointVecs
VecMultMat
ProjectVecs
CopyVec
Matrix
RotationMatrix
ScaleMatrix
OrthoProjectionMatrix
ShearMatrix
TranslationMatrix
MatMultVec
CopyMat
Quaternion
CrossQuats
DotQuats
CopyQuat
DifferenceQuats
Slerp
Euler
CopyEuler
RotateEuler

Vector has the following self methods:
Zero
Normalize
Negate
Resize2D
Resize3D
Resize4D

Matrix has the following self methods:
Zero
Identity
Transpose
Determinant
Invert
TranslationPart
RotationPart
Resize4x4
toEuler
toQuat

Quaternion has the following self methods:
Identity
Negate
Conjugate
Inverse
Normalize
ToEuler
ToMatrix

Euler has the following self methods:
Zero
Unique
ToMatrix
ToQuat

Matrix, vector, quaternion, euler all have sequence protocols so they can be
accessed as a sequence, and all but euler has numeric protocols so they can
be manipulated as a number.
Example:

m1 = RotationMatrix(180,3,'x')
t = Vector([1,2,3])
m2 = TranslationMatrix(t)

finalMatrix = m1 * m2

I have to split the .zip file into 2 parts so it can squeeze in the mailing
list :)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Mathutils1.zip
Type: application/x-zip-compressed
Size: 23959 bytes
Desc: not available
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20040211/665f3296/attachment.bin>


More information about the Bf-python mailing list