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

Class Matrix

source code

The Matrix Object

This object gives access to Matrices in Blender.


Notes:

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'

Instance Methods [hide private]
New matrix object.
__init__(list1=None, list2=None, list3=None, list4=None)
Create a new matrix object from initialized values.
source code
 
zero()
Set all matrix values to 0.
source code
 
copy()
Returns a copy of this matrix
source code
 
identity()
Set the matrix to the identity matrix.
source code
 
transpose()
Set the matrix to its transpose.
source code
float
determinant()
Return the determinant of a matrix.
source code
 
invert()
Set the matrix to its inverse.
source code
Matrix object.
rotationPart()
Return the 3d submatrix corresponding to the linear term of the embedded affine transformation in 3d.
source code
Vector object.
translationPart()
Return a the translation part of a 4 row matrix.
source code
Vector object.
scalePart()
Return a the scale part of a 3x3 or 4x4 matrix.
source code
 
resize4x4()
Resize the matrix to by 4x4
source code
Euler object
toEuler()
Return an Euler representation of the rotation matrix (3x3 or 4x4 matrix only).
source code
Quaternion object
toQuat()
Return a quaternion representation of the rotation matrix
source code
Instance Variables [hide private]
  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 [hide private]

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

source code 

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 (PyList of int/float) - A 2d,3d or 4d list.
  • list2 (PyList of int/float) - A 2d,3d or 4d list.
  • list3 (PyList of int/float) - A 2d,3d or 4d list.
  • list4 (PyList of int/float) - A 2d,3d or 4d list.
Returns: New matrix object.
It depends wheter a parameter was passed:
  • (list1, etc.): Matrix object initialized with the given values;
  • (): An empty 3 dimensional matrix.

zero()

source code 

Set all matrix values to 0.

Returns:
an instance of itself

copy()

source code 

Returns a copy of this matrix

Returns:
a copy of itself

identity()

source code 

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

See http://en.wikipedia.org/wiki/Identity_matrix

Returns:
an instance of itself

transpose()

source code 

Set the matrix to its transpose.

See http://en.wikipedia.org/wiki/Transpose

Returns:
None

determinant()

source code 

Return the determinant of a matrix.

See http://en.wikipedia.org/wiki/Determinant

Returns: float
Return a the determinant of a matrix.

invert()

source code 

Set the matrix to its inverse.

See http://en.wikipedia.org/wiki/Inverse_matrix

Returns:
an instance of itself.
Raises:
  • ValueError - When matrix is singular.

rotationPart()

source code 

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

translationPart()

source code 

Return a the translation part of a 4 row matrix.

Returns: Vector object.
Return a the translation of a matrix.

scalePart()

source code 

Return a the scale part of a 3x3 or 4x4 matrix.

Returns: Vector object.
Return a the scale of a matrix.

Note: This method does not return negative a scale on any axis because it is not possible to obtain this data from the matrix alone.

resize4x4()

source code 

Resize the matrix to by 4x4

Returns:
an instance of itself.

toEuler()

source code 

Return an Euler representation of the rotation matrix (3x3 or 4x4 matrix only).

Returns: Euler object
Euler representation of the rotation matrix.

toQuat()

source code 

Return a quaternion representation of the rotation matrix

Returns: Quaternion object
Quaternion representation of the rotation matrix