c4d.Matrix¶
-
class
c4d.Matrix¶ See also
Warning
The
Matrixtype does not support the function copy.copy().Instead use the
Matrixconstructorimport c4d def main(): if op is None: return mat = op.GetMg() print "Matrix:", id(mat), mat ref = mat print "Reference:", id(ref), ref copy = c4d.Matrix(mat) print "Copy:", id(copy), copy if __name__=='__main__': main()
Attributes
Methods Signatures
Initializes a new
Matrix. |
|
Returns the Matrix as string. Called if str() is wrapped around an instance of |
|
Adds two matrices. |
|
Subtracts two matrices. |
|
Multiplies a matrix or vector by the matrix. Can also scale each vector of the matrix by a scalar.
|
|
Divides each element in the matrix by a scalar. |
|
Inverts the matrix. |
|
Checks if two matrices are equal. |
|
Checks if two matrices are not equal. |
|
raise NotImplemented. |
|
raise NotImplemented. |
|
raise NotImplemented. |
|
raise NotImplemented. |
Normalizes the matrix. |
|
Calculates the normalized matrix. |
|
Multiply the vector by the matrix, this includes any translation in the matrix. |
|
Multiply the vector by the matrix, this does not include any translation. |
|
Returns the matrix’ tensor. |
|
Performs uniform matrix scaling (float) or non-uniform matrix scaling (vector). |
|
Returns the scale stored by the matrix. |
Methods Documentation
-
Matrix.__init__(self, off=Vector(0), v1=Vector(1, 0, 0), v2=Vector(0, 1, 0), v3=Vector(0, 0, 1))¶ - Initializes a new
Matrix.All arguments are optional so it is possible to create a new matrix without any arguments. All components are simply set to:off = Vector(0)
v1 = Vector(1,0,0)
v2 = Vector(0,1,0)
v3 = Vector(0,0,1)
mat = c4d.Matrix() # => Matrix(v1: (1, 0, 0); v2: (0, 1, 0); v3: (0, 0, 1); off: (0, 0, 0)) mat = c4d.Matrix() mat.off = c4d.Vector(100,0,0) v1 = c4d.Vector(3) v2 = c4d.Vector(12,4,9.3) v3 = c4d.Vector(9,80,3) off = c4d.Vector(v1+v2) mat = c4d.Matrix(off,v1,v2,v3)
- Parameters
off (c4d.Vector) – The translation vector.
v1 (c4d.Vector) – The X axis of a left-handed coordinate system.
v2 (c4d.Vector) – The Y axis of a left-handed coordinate system.
v3 (c4d.Vector) – The Z axis of a left-handed coordinate system.
- Return type
- Returns
A new matrix.
-
Matrix.__str__(self)¶ Returns the Matrix as string. Called if str() is wrapped around an instance of
Matrix. (See __str__)v1 = c4d.Vector(3) v2 = c4d.Vector(12,4,9.3) v3 = c4d.Vector(9,80,3) off = c4d.Vector(v1+v2) mat = c4d.Matrix(off,v1,v2,v3) print mat # => Matrix(v1: (3, 3, 3); v2: (12, 4, 9.3); v3: (12, 4, 9.3); off: (15, 7, 12.3))
- Return type
str
- Returns
The Vector as string.
-
Matrix.__add__(self, other)¶ Adds two matrices.
- Parameters
other (c4d.Matrix) – The other matrix.
- Return type
- Returns
The result matrix.
-
Matrix.__sub__(self, other)¶ Subtracts two matrices.
- Parameters
other (c4d.Matrix) – The other matrix.
- Return type
- Returns
The result matrix.
-
Matrix.__mul__(self, other)¶ - Multiplies a matrix or vector by the matrix. Can also scale each vector of the matrix by a scalar.If both objects are of type
Matrix, multiplies the left hand matrix by the right hand matrix.If the left object is of typeMatrixand the right one of typeVector, multiplies the vector by the matrix including any translation in the matrix.If the left object is of typeVectorand the right one of typeMatrix, multiplies the vector by the matrix including any translation in the matrix.If the right object is a number, multiplies each vector of the matrix by it.- Parameters
other (Union[c4d.Vector, int, float]) – The other argument.
- Return type
- Returns
The result matrix or vector.
-
Matrix.__div__(self, other)¶ Divides each element in the matrix by a scalar.
- Parameters
other (float) – The scalar.
- Return type
- Returns
The result matrix.
-
Matrix.__invert__(self)¶ Inverts the matrix.
- Return type
- Returns
The inverted matrix.
-
Matrix.__eq__(self, other)¶ Checks if two matrices are equal.
- Parameters
other (c4d.Matrix) – The other matrix.
- Return type
bool
- Returns
True if matrices are equal.
-
Matrix.__ne__(self, other)¶ Checks if two matrices are not equal.
- Parameters
other (c4d.Matrix) – The other matrix.
- Return type
bool
- Returns
True if matrices are not equal.
-
Matrix.__ge__(self, other)¶ raise NotImplemented.
-
Matrix.__gt__(self, other)¶ raise NotImplemented.
-
Matrix.__le__(self, other)¶ raise NotImplemented.
-
Matrix.__lt__(self, other)¶ raise NotImplemented.
-
Matrix.Normalize(self)¶ Normalizes the matrix.
-
Matrix.GetNormalized(self)¶ Calculates the normalized matrix.
- Return type
- Returns
The normalized matrix.
-
Matrix.Mul(self, v)¶ Multiply the vector by the matrix, this includes any translation in the matrix.
- Parameters
v (c4d.Vector) – The vector to multiply.
- Return type
- Returns
The result vector.
-
Matrix.MulV(self, v)¶ Multiply the vector by the matrix, this does not include any translation.
- Parameters
v (c4d.Vector) – The vector to multiply.
- Return type
- Returns
The result vector.
-
Matrix.GetTensorMatrix(self)¶ Returns the matrix’ tensor.
- Return type
- Returns
The tensor matrix.
-
Matrix.Scale(self, v)¶ Performs uniform matrix scaling (float) or non-uniform matrix scaling (vector).
- Parameters
v (Union[c4d.Vector, float]) – The scaling scalar.
-
Matrix.GetScale(self)¶ Returns the scale stored by the matrix.
- Returns
The scale.
- Return type