Module Mathutils :: Class Matrix
[frames | no frames]

Class Matrix


The Matrix Object

This object gives access to Matrices in Blender.

Attention: Quaternion data can be wrapped or non-wrapped. When a object is wrapped it means that the object will give you direct access to the data inside of blender. Modification of this object will directly change the data inside of blender. To copy a wrapped object you need to use the object's constructor. If you copy and object by assignment you will not get a second copy but a second reference to the same data. Only certain functions will return wrapped data. This will be indicated in the method description. Example:

   wrappedObject = Object.getAttribute() #this is wrapped data
   print wrappedObject.wrapped #prints 'True'
   copyOfObject = Object(wrappedObject) #creates a copy of the object
   secondPointer = wrappedObject #creates a second pointer to the same data
   print wrappedObject.attribute #prints '5'
   secondPointer.attribute = 10
   print wrappedObject.attribute #prints '10'
   print copyOfObject.attribute #prints '5'

Notes:

Method Summary
New matrix object. __init__(list1, list2, list3, list4)
Create a new matrix object from initialized values.
float determinant()
Return the determinant of a matrix.
  identity()
Set the matrix to the identity matrix.
  invert()
Set the matrix to its inverse.
  resize4x4()
Resize the matrix to by 4x4
Matrix object. rotationPart()
Return the 3d submatrix corresponding to the linear term of the embedded affine transformation in 3d.
Euler object toEuler()
Return an Euler representation of the rotation matrix.
Quaternion object toQuat()
Return a quaternion representation of the rotation matrix
Vector object. translationPart()
Return a the translation part of a 4 row matrix.
  transpose()
Set the matrix to its transpose.
  zero()
Set all matrix values to 0.

Instance Variable Summary
  colsize: The column size of the matrix.
  rowsize: The row size of the matrix.
  wrapped: Whether or not this object wrapps internal data

Method Details

__init__(list1=None, list2=None, list3=None, list4=None)
(Constructor)

Create a new matrix object from initialized values.

Example:
 matrix = Matrix([1,1,1],[0,1,0],[1,0,0])
 matrix = Matrix(mat)
 matrix = Matrix(seq1, seq2, vector)
Parameters:
list1 - A 2d,3d or 4d list.
           (type=PyList of int/float)
list2 - A 2d,3d or 4d list.
           (type=PyList of int/float)
list3 - A 2d,3d or 4d list.
           (type=PyList of int/float)
list4 - A 2d,3d or 4d list.
           (type=PyList of int/float)
Returns:
It depends wheter a parameter was passed:
  • (list1, etc.): Matrix object initialized with the given values;
  • (): An empty 3 dimensional matrix.

           (type=New matrix object.)

determinant()

Return the determinant of a matrix.
Returns:
Return a the determinant of a matrix.
           (type=float)

identity()

Set the matrix to the identity matrix. An object with zero location and rotation, a scale of 1, will have an identity matrix.
Returns:
a copy of itself

invert()

Set the matrix to its inverse.
Returns:
a copy of itself
Raises:
ValueError - When matrix is singular.

resize4x4()

Resize the matrix to by 4x4
Returns:
a copy of itself

rotationPart()

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.
Returns:
Return the 3d matrix for rotation and scale.
           (type=Matrix object.)

toEuler()

Return an Euler representation of the rotation matrix.
Returns:
Euler representation of the rotation matrix.
           (type=Euler object)

toQuat()

Return a quaternion representation of the rotation matrix
Returns:
Quaternion representation of the rotation matrix
           (type=Quaternion object)

translationPart()

Return a the translation part of a 4 row matrix.
Returns:
Return a the translation of a matrix.
           (type=Vector object.)

transpose()

Set the matrix to its transpose.
Returns:
a copy of itself

zero()

Set all matrix values to 0.
Returns:
a copy of itself

Instance Variable Details

colsize

The column size of the matrix.

rowsize

The row size of the matrix.

wrapped

Whether or not this object wrapps internal data

Generated by Epydoc 2.1 on Thu Dec 22 22:38:11 2005 http://epydoc.sf.net