Difference between revisions of "IC Python API:RLPy RMatrix3"

From Reallusion Wiki!
Jump to: navigation, search
(Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} ==Detailed Description== This class represent the 3x3 matrix. ==Operators== This class supports the following operat...")
 
m
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
==Detailed Description==
+
{{last_modified}}
This class represent the 3x3 matrix.
+
 
==Operators==
+
== Detailed Description ==
This class supports the following operators:
+
 
{| class="wikitable"
+
This class represent the 3x3 matrix. iClone uses row-major order where consecutive elements of a row reside next to each other, and the data is read from left to right, top to bottom, in a vertical zig-zag. This class provides access to RLPy's internal 3x3 matrix operators and related functions.
!Member
+
 
!Operation
+
== Operators ==
!Syntax
+
 
!Description
+
=== + ===
!Example
+
 
|-
+
The "addition" operator.
! scope="row"|__add__
+
 
|Addition
+
|a + b
+
|Adds values on either side of the operator.
+
|a + b = 30
+
|-
+
! scope="row"|__sub__
+
|Subtraction
+
|a - b
+
|Subtracts right hand operand from left hand operand.
+
|a – b = -10
+
|-
+
! scope="row"|__mul__
+
|Multiplication
+
|a * b
+
|Multiplies values on either side of the operator.
+
|a * b = 200
+
|-
+
! scope="row"|__truediv__
+
|Division
+
|a / b
+
|Divides left hand operand by right hand operand.
+
|b / a = 2
+
|-
+
! scope="row"|__neg__
+
|Negation
+
| -a
+
|Return the value negated.
+
| a = -b
+
|-
+
! scope="row"|__eq__
+
|Equality
+
|a == b
+
|If the values of two operands are equal, then the condition becomes true.
+
|(a == b) is not true.
+
|-
+
! scope="row"|__ne__
+
|Difference
+
|a != b
+
|If values of two operands are not equal, then condition becomes true.
+
|(a != b) is true.
+
|-
+
! scope="row"|__gt__
+
|Greater Than
+
|a > b
+
|If the value of left operand is greater than the value of right operand, then condition becomes true.
+
|(a > b) is not true.
+
|-
+
! scope="row"|__lt__
+
|Less Than
+
|a < b
+
|If the value of left operand is less than the value of right operand, then condition becomes true.
+
|(a < b) is true.
+
|-
+
! scope="row"|__ge__
+
|Greater Than or Equal
+
|a >= b
+
|If the value of left operand is greater than or equal to the value of right operand, then condition becomes true.
+
|(a >= b) is not true.
+
|-
+
! scope="row"|__le__
+
|Less or Equal
+
|a <= b
+
|If the value of left operand is less than or equal to the value of right operand, then condition becomes true.
+
|(a <= b) is true.
+
|-
+
! scope="row"|__iadd__
+
|Addition (Inplace)
+
|a += b
+
|It adds right operand to the left operand and assign the result to left operand.
+
|c += a is equivalent to c = c + a
+
|-
+
! scope="row"|__isub__
+
|Subtraction (Inplace)
+
|a -= b
+
|It subtracts right operand from the left operand and assign the result to left operand.
+
|c -= a is equivalent to c = c - a
+
|-
+
! scope="row"|__imul__
+
|Multiply (Inplace)
+
|a *= b
+
|It multiplies right operand with the left operand and assign the result to left operand.
+
|c *= a is equivalent to c = c * a
+
|-
+
! scope="row"|__itruediv__
+
|Divide (Inplace)
+
|a /= b
+
|It divides left operand with the right operand and assign the result to left operand.
+
|c /= a is equivalent to c = c / ac /= a is equivalent to c = c / a
+
|}
+
==Member Functions==
+
===AccuScale===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.AccuScale ( self, rkScale )
+
matrix3_a = RLPy.RMatrix3( 1, 2, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3_b = RLPy.RMatrix3( 2, 2, 2,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3_result = matrix3_a + matrix3_b
 +
print( matrix3_result.GetRow(0)[0] == 1+2 ) # true
 +
print( matrix3_result.GetRow(0)[1] == 2+2 ) # true
 +
print( matrix3_result.GetRow(0)[2] == 3+2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Accumulate matrix with scale vector.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''rkScale''' [IN] Scale vector - RLPy.RVector3
+
=== - ===
</div>
+
 
====Returns====
+
The "subtraction" operator.
<div style="margin-left: 2em;">Return a new matrix - RLPy.RMatrix3
+
 
</div>
+
-----
+
===Adjoint===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.Adjoint ( self )
+
matrix3_a = RLPy.RMatrix3( 1, 2, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3_b = RLPy.RMatrix3( 2, 2, 2,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3_result = matrix3_a - matrix3_b
 +
print( matrix3_result.GetRow(0)[0] == 1-2 ) # true
 +
print( matrix3_result.GetRow(0)[1] == 2-2 ) # true
 +
print( matrix3_result.GetRow(0)[2] == 3-2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Inverse times determinant.
+
 
====Returns====
+
=== * ===
<div style="margin-left: 2em;">A new matrix containing this matrix's adjoint - RLPy.RMatrix3
+
 
</div>
+
The "multiplication" operator.
-----
+
 
===AdjointTranspose===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.AdjointTranspose ( self )
+
matrix3_a = RLPy.RMatrix3( 1, 2, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3_b = RLPy.RMatrix3( 2, 0, 0,
 +
                          2, 0, 0,
 +
                          2, 0, 0 )
 +
matrix3_result = matrix3_a * matrix3_b
 +
print( matrix3_result.GetRow(0)[0] == 1*2 + 2*2 + 3*2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Transpose of inverse times determinant.
+
 
====Returns====
+
=== / ===
<div style="margin-left: 2em;">A new matrix - RLPy.RMatrix3
+
 
</div>
+
The "division" operator.  
-----
+
 
===Determinant===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.Determinant ( self )
+
matrix3_a = RLPy.RMatrix3( 1, 2, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3_result = matrix3_a / 2
 +
print( matrix3_result.GetRow(0)[0] == 1/2 ) # true
 +
print( matrix3_result.GetRow(0)[1] == 2/2 ) # true
 +
print( matrix3_result.GetRow(0)[2] == 3/2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
The matrix's determinant.
+
 
====Returns====
+
=== - ===
<div style="margin-left: 2em;">The determinant of the matrix - float
+
 
</div>
+
The "unary minus" .
-----
+
 
===E===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.E ( self, args )
+
matrix3_a = RLPy.RMatrix3( 1, 2, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3_result = -matrix3_a
 +
print( matrix3_result.GetRow(0)[0] == -1 ) # true
 +
print( matrix3_result.GetRow(0)[1] == -2 ) # true
 +
print( matrix3_result.GetRow(0)[2] == -3 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the matrix element for the specified index(0~8).
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''nRow''' [IN] Index of the matrix.
+
=== == ===
</div>
+
 
====Returns====
+
The "equal to" operator. Performs a one-by-one comparison of the matrix array.
<div style="margin-left: 2em;">The matrix element specified by index - float
+
 
</div>
+
-----
+
===FromAxisAngle===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.FromAxisAngle ( self, rkAxis, fAngle )
+
matrix3_a = RLPy.RMatrix3( 1, 2, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3_b = RLPy.RMatrix3( 1, 2, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
print( matrix3_a == matrix3_b ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Rotation matrix from axis angle.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''rkAxis''' [IN] axis vector - RLPy.RVector3
+
=== != ===
 +
 
 +
The "not equal to" operator. Performs a one-by-one comparison of the matrix array.
  
'''fAngle''' [IN] angle in radians - float
 
</div>
 
====Returns====
 
<div style="margin-left: 2em;">Return a new matrix from specified axis angle - RLPy.RMatrix3
 
</div>
 
-----
 
===FromEulerAngle===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.FromEulerAngle ( Oreder, rx, ry, rz )
+
matrix3_a = RLPy.RMatrix3( 1, 2, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3_b = RLPy.RMatrix3( 4, 5, 6,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
print( matrix3_a != matrix3_b ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Rotation matrix from Euler angle.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''Oreder''' [IN] Euler order - RLPy.Rotation_Order
+
=== > ===
  
'''rx''' [IN] Angle of x-axis in radians - float
+
The "greater than" operator. Performs a one-by-one comparison of the matrix array.
  
'''ry''' [IN] Angle of y-axis in radians - float
+
<syntaxhighlight lang="Python">
 +
matrix3_a = RLPy.RMatrix3( 2, 0, 0,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3_b = RLPy.RMatrix3( 5, 0, 0,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
print( matrix3_b >matrix3_a ) # true
 +
</syntaxhighlight>
 +
 
 +
=== >= ===
 +
 
 +
The "greater than or equal to" operator. Performs a one-by-one comparison of the matrix array.
  
'''rz''' [IN] Angle of z-axis in radians - float
 
</div>
 
====Returns====
 
<div style="margin-left: 2em;">Return a new matrix from specified axis angle - RLPy.RMatrix3
 
</div>
 
-----
 
===FromSpereUnitVec===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.FromSpereUnitVec ( self, rkVec )
+
matrix3_a = RLPy.RMatrix3( 1, 1, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3_b = RLPy.RMatrix3( 1, 1, 9,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
print( matrix3_b >= matrix3_a ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Rotation matrix from sphere unit vector.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''rkVec''' [IN] vector - RLPy.RVector3
+
=== < ===
</div>
+
 
====Returns====
+
The "less than" operator. Performs a one-by-one comparison of the matrix array.
<div style="margin-left: 2em;">Return a new matrix from sphere unit vector - RLPy.RMatrix3
+
 
</div>
+
-----
+
===GetColumn===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.GetColumn ( self, nCol )
+
matrix3_a = RLPy.RMatrix3( 2, 0, 0,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3_b = RLPy.RMatrix3( 5, 0, 0,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
print( matrix3_a< matrix3_b ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the matrix element for the specified column.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''nRow''' [IN] Index of the column in the matrix.
+
=== <= ===
</div>
+
 
====Returns====
+
The "less than" operator. Performs a one-by-one comparison of the matrix array.
<div style="margin-left: 2em;">The column vector of the matrix - RLPy.RVector3
+
 
</div>
+
-----
+
===GetRow===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.GetRow ( self, nRow )
+
matrix3_a = RLPy.RMatrix3( 1, 1, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3_b = RLPy.RMatrix3( 1, 1, 9,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
print( matrix3_a<= matrix3_b ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the matrix element for the specified row.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''nRow''' [IN] Index of the row in the matrix - int
+
=== += ===
</div>
+
 
====Returns====
+
The "addition assignment" operator.
<div style="margin-left: 2em;">The row vector of the matrix - RLPy.RVector3
+
 
</div>
+
-----
+
===InfNorm===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.InfNorm ( self )
+
matrix3 =  RLPy.RMatrix3( 1, 2, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3 += RLPy.RMatrix3( 2, 2, 2,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
print( matrix3.GetRow(0)[0] == 1+2 ) # true
 +
print( matrix3.GetRow(0)[1] == 2+2 ) # true
 +
print( matrix3.GetRow(0)[2] == 3+2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
InfNorm of the matrix.
+
 
====Returns====
+
=== -= ===
<div style="margin-left: 2em;">Return InfNorm - float
+
 
</div>
+
The "subtraction assignment" operator.
-----
+
 
===Inverse===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.Inverse ( self )
+
matrix3 =  RLPy.RMatrix3( 1, 2, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3 -= RLPy.RMatrix3( 2, 2, 2,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
print( matrix3.GetRow(0)[0] == 1-2 ) # true
 +
print( matrix3.GetRow(0)[1] == 2-2 ) # true
 +
print( matrix3.GetRow(0)[2] == 3-2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Inverse of the matrix.
+
 
====Returns====
+
=== *= ===
<div style="margin-left: 2em;">A new matrix containing this matrix's inverse - RLPy.RMatrix3
+
 
</div>
+
The "multiplication assignment" operator.  For the calculation method, refer to the '''*''' operator.
-----
+
 
===InverseTranspose===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.InverseTranspose ( self )
+
matrix3 =  RLPy.RMatrix3( 1, 2, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3 *= 2
 +
print( matrix3.GetRow(0)[0] == 1*2 ) # true
 +
print( matrix3.GetRow(0)[1] == 2*2 ) # true
 +
print( matrix3.GetRow(0)[2] == 3*2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Transpose of inverse.
+
 
====Returns====
+
=== /= ===
<div style="margin-left: 2em;">A new matrix - RLPy.RMatrix3
+
 
</div>
+
The "division assignment" operator. For the calculation method, refer to the '''/''' operator.
-----
+
 
===IsRightHandCoordinate===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.IsRightHandCoordinate ( self )
+
matrix3 =  RLPy.RMatrix3( 1, 2, 3,
 +
                          0, 0, 0,
 +
                          0, 0, 0 )
 +
matrix3 /= 2
 +
print( matrix3.GetRow(0)[0] == 1/2 ) # true
 +
print( matrix3.GetRow(0)[1] == 2/2 ) # true
 +
print( matrix3.GetRow(0)[2] == 3/2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Determine the coordinate is right hand or left hand.
 
====Return Values====
 
<div style="margin-left: 2em;">
 
  
'''true''' Right hand coordinate
+
== Member Functions ==
 +
 
 +
=== MakeIdentity ( self ) ===
 +
 
 +
This function can be used to initialize the 3x3 matrix.  It is equivalent to setting the matrix to:
 +
 
 +
:[1 0 0 0]
 +
:[0 1 0 0]
 +
:[0 0 1 0]
 +
:[0 0 0 1]
 +
 
 +
==== Returns ====
 +
 
 +
This object - RLPy.RMatrix3
  
'''true''' Left hand coordinate
 
</div>
 
-----
 
===M===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.M ( self, args )
+
matrix3 = RLPy.RMatrix3()
 +
matrix3.MakeIdentity()
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the matrix element for the specified row and column.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''nRow''' [IN] Index of the row in the matrix - int
+
=== M ( self, args ) ===
 +
 
 +
Get the value of an element in a 3x3 matrix by row and column index.
 +
 
 +
==== Parameters ====
 +
:'''nRow''' [IN] Index of the row in the matrix - int
 +
:'''nCol''' [IN] Index of the column in the matrix - int
 +
 
 +
==== Returns ====
 +
:Returns the matrix element specified by row and col - float*
  
'''nCol''' [IN] Index of the column in the matrix - int
 
</div>
 
====Returns====
 
<div style="margin-left: 2em;">The matrix element specified by row and col - float
 
</div>
 
-----
 
===MakeIdentity===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.MakeIdentity ( self )
+
matrix3 = RLPy.RMatrix3()
 +
matrix3.MakeIdentity()
 +
 
 +
print(matrix3.M(0,0))  # <Swig Object of type 'float *' at 0x0000020316B015A0>
 
</syntaxhighlight>
 
</syntaxhighlight>
Sets the matrix to the identity.
+
 
====Returns====
+
=== E ( self, args ) ===
<div style="margin-left: 2em;">This object - RLPy.RMatrix3
+
 
</div>
+
Get the value of an element in a 3x3 matrix by index number (from 0 to 8);
-----
+
 
===MaxColumn===
+
==== Parameters ====
 +
:'''nRow''' [IN] Index of the matrix.
 +
 
 +
==== Returns ====
 +
:Returns the matrix element specified by index - float*
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.MaxColumn ( self )
+
matrix3 = RLPy.RMatrix3()
 +
matrix3.MakeIdentity()
 +
 
 +
print(matrix3.E(0)) #
 
</syntaxhighlight>
 
</syntaxhighlight>
Get maximum value of the column index in the matrix.
+
 
====Returns====
+
=== GetRow ( self, nRow ) ===
<div style="margin-left: 2em;">Return index of column of M containing maximum abs entry, or -1 if M = 0 - int
+
 
</div>
+
Obtain an array of element values within a given row inside a 3x3 matrix.
-----
+
 
===MaxRow===
+
==== Parameters ====
 +
:'''nRow''' [IN] Index of the row in the matrix - int
 +
 
 +
==== Returns ====
 +
:Returns the row vector of the matrix - RLPy.RVector3
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.MaxRow ( self )
+
matrix3 = RLPy.RMatrix3()
 +
matrix3.MakeIdentity()
 +
row0 = matrix3.GetRow(0)
 +
 
 +
print(row0[0])
 +
print(row0[1])
 +
print(row0[2])
 
</syntaxhighlight>
 
</syntaxhighlight>
Get maximum value of the row index in the matrix.
+
 
====Returns====
+
=== GetColumn( self, nCol ) ===
<div style="margin-left: 2em;">Return index of row of M containing maximum abs entry, or -1 if M = 0 - int
+
 
</div>
+
Obtain an array of element values within a given column inside a 3x3 matrix.
-----
+
 
===OneNorm===
+
==== Parameters ====
 +
:'''nCol''' [IN] Index of the row in the matrix - int
 +
 
 +
==== Returns ====
 +
:Returns the column vector of the matrix - RLPy.RVector3
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.OneNorm ( self )
+
matrix3 = RLPy.RMatrix3()
 +
matrix3.MakeIdentity()
 +
col0 = matrix3.GetColumn(0)
 +
print(col0[0])
 +
print(col0[1])
 +
print(col0[2])
 
</syntaxhighlight>
 
</syntaxhighlight>
Norm of the matrix.
+
 
====Returns====
+
=== Transpose( self ) ===
<div style="margin-left: 2em;">Return Norm - float
+
 
</div>
+
Obtain the transposed matrix by transposing the current m * n matrix into an n * m matrix by row-column swapping.
-----
+
 
===RotationX===
+
==== Returns ====
 +
:Returns a new matrix containing this matrix's transpose - RLPy.RMatrix3
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.RotationX ( self, fAngle )
+
matrix3_orgin = RLPy.RMatrix3( 1, 2, 3,
 +
                              4, 5, 6,
 +
                              7, 8, 9 )
 +
matrix3_transpose = matrix3_orgin.Transpose()
 +
row0 = matrix3_orgin.GetRow(0)
 +
col0 = matrix3_transpose.GetColumn(0)
 +
 
 +
print(row0[0] == col0[0])
 +
print(row0[1] == col0[1])
 +
print(row0[2] == col0[2])
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=== TransposeTimes( self, mM ) ===
 +
 +
Multiply a transposed version of a 3x3 matrix with itself.
 +
 +
==== Parameters ====
 +
:'''mM''' [IN] the matrix - RLPy.RMatrix3
 +
 +
==== Returns ====
 +
:Returns a new matrix. (this^T * mM) - RLPy.RMatrix3
 +
 +
<syntaxhighlight lang="Python">
 +
matrix3_orgin = RLPy.RMatrix3( 1, 2, 3,
 +
                              4, 5, 6,
 +
                              7, 8, 9 )
 +
matrix3_transpose_value = RLPy.RMatrix3( 2, 0, 0,
 +
                                        0, 2, 0,
 +
                                        0, 0, 2 )
 +
matrix3_transpose_times = matrix3_orgin.TransposeTimes(matrix3_transpose_value)
 +
row0 = matrix3_orgin.GetRow(0)
 +
col0 = matrix3_transpose_times.GetColumn(0)
 +
 +
print(row0[0]*2 == col0[0])
 +
print(row0[1]*2 == col0[1])
 +
print(row0[2]*2 == col0[2])
 +
</syntaxhighlight>
 +
 +
=== TimesTranspose( self, mM ) ===
 +
 +
Multiply a given 3x3 matrix with a transposed version of itself.
 +
 +
==== Parameters ====
 +
:'''mM'''  [IN] the matrix - RLPy.RMatrix3
 +
 +
==== Returns ====
 +
:Returns a new matrix. (this * M^T) - RLPy.RMatrix3
 +
 +
<syntaxhighlight lang="Python">
 +
matrix3_orgin = RLPy.RMatrix3( 1, 2, 3,
 +
                              4, 5, 6,
 +
                              7, 8, 9 )
 +
matrix3_transpose_value = RLPy.RMatrix3( 3, 0, 0,
 +
                                        0, 3, 0,
 +
                                        0, 0, 3 )
 +
matrix3_times_transpose = matrix3_orgin.TimesTranspose(matrix3_transpose_value)
 +
row0 = matrix3_orgin.GetColumn(0)
 +
col0 = matrix3_times_transpose.GetColumn(0)
 +
 +
print(row0[0]*3 == col0[0])
 +
print(row0[1]*3 == col0[1])
 +
print(row0[2]*3 == col0[2])
 +
</syntaxhighlight>
 +
 +
=== Inverse( self ) ===
 +
 +
Invert a given 3x3 matrix.
 +
 +
==== Returns ====
 +
:Returns a new matrix containing this matrix's inverse - RLPy.RMatrix3
 +
 +
<syntaxhighlight lang="Python">
 +
matrix3_value = RLPy.RMatrix3( 1, 2, 3,
 +
                              2, 3, 4,
 +
                              4, 2, 1 )
 +
matrix3_inverse = matrix3_value.Inverse()
 +
row0 = matrix3_inverse.GetRow(0)
 +
print(row0[0])
 +
print(row0[1])
 +
print(row0[2])
 +
</syntaxhighlight>
 +
 +
=== Adjoint( self ) ===
 +
 +
Adjugate a given 3x3 matrix.
 +
 +
<syntaxhighlight lang="Python">
 +
matrix3_value = RLPy.RMatrix3( 1, 2, 3,
 +
                              2, 3, 4,
 +
                              4, 2, 1 )
 +
matrix3_Adjoint = matrix3_value.Adjoint()
 +
row0 = matrix3_Adjoint.GetRow(0)
 +
 +
print(row0[0])
 +
print(row0[1])
 +
print(row0[2])
 +
</syntaxhighlight>
 +
 +
==== Returns ====
 +
 +
Returns a new matrix containing this matrix's adjoint - RLPy.RMatrix3
 +
 +
=== AdjointTranspose( self ) ===
 +
 +
Adjugate and transpose a given 3x3 matrix.
 +
 +
==== Returns ====
 +
:Returns a new matrix - RLPy.RMatrix3
 +
 +
<syntaxhighlight lang="Python">
 +
matrix3_value = RLPy.RMatrix3( 1, 2, 3,
 +
                              2, 3, 4,
 +
                              4, 2, 1 )
 +
matrix3_Adjoint_transpose = matrix3_value.AdjointTranspose()
 +
col0_Adjoint_transpose = matrix3_Adjoint_transpose.GetColumn(0)
 +
 +
print(col0_Adjoint_transpose[0])
 +
print(col0_Adjoint_transpose[1])
 +
print(col0_Adjoint_transpose[2])
 +
</syntaxhighlight>
 +
 +
=== InverseTranspose( self ) ===
 +
 +
Invert and transpose a given 3x3 matrix.
 +
 +
==== Returns ====
 +
:Returns a new matrix - RLPy.RMatrix3
 +
 +
<syntaxhighlight lang="Python">
 +
matrix3_value = RLPy.RMatrix3( 1, 2, 3,
 +
                              2, 3, 4,
 +
                              4, 2, 1 )
 +
matrix3_inverse_transpose = matrix3_value.InverseTranspose()
 +
row0_inverse_transpose = matrix3_inverse_transpose.GetRow(0)
 +
 +
print(row0_inverse_transpose[0])
 +
print(row0_inverse_transpose[1])
 +
print(row0_inverse_transpose[2])
 +
</syntaxhighlight>
 +
 +
=== Determinant( self ) ===
 +
 +
Obtain the scalar value for a given 3x3 matrix.
 +
 +
==== Returns ====
 +
:Returns the determinant of the matrix - float
 +
 +
<syntaxhighlight lang="Python">
 +
matrix3_value = RLPy.RMatrix3( 1, 2, 3,
 +
                              2, 3, 4,
 +
                              4, 2, 1 )
 +
 +
print(matrix3_value.Determinant())
 +
</syntaxhighlight>
 +
 +
=== MaxColumn( self ) ===
 +
 +
Find the maximum absolute value within a 3x3 matrix, and return the column in which the value is located.  If all of the elements within the 3x3 matrix are 0 then return -1.
 +
 +
==== Returns ====
 +
:Return index of column of M containing maximum abs entry, or -1 if M = 0 - int
 +
 +
<syntaxhighlight lang="Python">
 +
matrix3_value = RLPy.RMatrix3( 10, 20, -30,
 +
                                0,  0,  0,
 +
                                0,  0,  0 )
 +
 +
print(matrix3_value.MaxColumn()) # column:2 ->abs(-30)
 +
</syntaxhighlight>
 +
 +
=== MaxRow( self ) ===
 +
 +
Find the maximum absolute value within a 3x3 matrix, and return the row in which the value is located.  If all of the elements within the 3x3 matrix are 0 then return -1.
 +
 +
==== Returns ====
 +
:Return index of row of M containing maximum abs entry, or -1 if M = 0 - int
 +
 +
<syntaxhighlight lang="Python">
 +
matrix3_value = RLPy.RMatrix3( 10, 0, 0,
 +
                              20, 0, 0,
 +
                              -30, 0, 0 )
 +
 +
print(matrix3_value.MaxRow()) # Row:2 ->abs(-30)
 +
</syntaxhighlight>
 +
 +
=== OneNorm( self ) ===
 +
 +
Return the sum of the column elements that contain the largest absolute values.
 +
 +
==== Returns ====
 +
:Return Norm - float
 +
 +
<syntaxhighlight lang="Python">
 +
matrix3_row_value = RLPy.RMatrix3( 10, 0, 0,
 +
                                  20, 0, 0,
 +
                                  -30, 0, 0 )
 +
 +
print(matrix3_row_value.OneNorm()) # 10+20+abs(-30) = 60
 +
</syntaxhighlight>
 +
 +
=== InfNorm( self ) ===
 +
 +
Return the sum of the row elements that contain the largest absolute values.
 +
 +
==== Returns ====
 +
:Return InfNorm - float
 +
 +
<syntaxhighlight lang="Python">
 +
matrix3_column_value = RLPy.RMatrix3( 10, 20, -30,
 +
                                      0,  0,  0,
 +
                                      0,  0,  0 )
 +
 +
print(matrix3_column_value.InfNorm()) # 10+20+abs(-30) = 60
 +
</syntaxhighlight>
 +
 +
=== FromAxisAngle( self, rkAxis, fAngle ) ===
 +
 +
Rotation matrix from axis angle。
 +
 +
==== Parameters ====
 +
:'''rkAxis''' [IN] axis vector - RLPy.RVector3
 +
:'''fAngle''' [IN] angle in radians - float
 +
 +
==== Returns ====
 +
:Return a new matrix from specified axis angle - RLPy.RMatrix3
 +
 +
<syntaxhighlight lang="Python">
 +
matrix3_orgin = RLPy.RMatrix3()
 +
matrix3_orgin.MakeIdentity()
 +
 +
x_axis_vector = RLPy.RVector3( 1, 0, 0 )  # axis = "X"
 +
y_axis_vector = RLPy.RVector3( 0, 1, 0 )  # axis = "Y"
 +
z_axis_vector = RLPy.RVector3( 0, 0, 1 )  # axis = "Z"   
 +
 +
matrix3_orgin.FromAxisAngle( x_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 +
matrix3_orgin.FromAxisAngle( y_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 +
matrix3_orgin.FromAxisAngle( z_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 +
</syntaxhighlight>
 +
 +
=== RotationX( self, fAngle ) ===
 +
 
Rotation matrix for rotations around x-axis.
 
Rotation matrix for rotations around x-axis.
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''fAngle''' [IN] angle in radians - float
+
==== Parameters ====
</div>
+
fAngle [IN] angle in radians - float
====Returns====
+
 
<div style="margin-left: 2em;">Return a new matrix of for rotations around x-axis - RLPy.RMatrix3
+
==== Returns ====
</div>
+
:Return a new matrix of for rotations around x-axis - RLPy.RMatrix3
-----
+
 
===RotationY===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.RotationY ( self, fAngle )
+
matrix3_orgin = RLPy.RMatrix3()
 +
matrix3_orgin.MakeIdentity()
 +
matrix3_orgin.RotationX( 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 
</syntaxhighlight>
 
</syntaxhighlight>
Rotation matrix for rotations around y-axis.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''fAngle''' [IN] angle in radians - float
+
=== RotationY( self, fAngle ) ===
</div>
+
 
====Returns====
+
Rotate a given 3x3 matrix around the y-axis。
<div style="margin-left: 2em;">Return a new matrix of for rotations around y-axis - RLPy.RMatrix3
+
 
</div>
+
==== Parameters ====
-----
+
:'''fAngle''' [IN] angle in radians - float
===RotationZ===
+
 
 +
==== Returns ====
 +
:Return a new matrix of for rotations around y-axis - RLPy.RMatrix3
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.RotationZ ( self, fAngle )
+
matrix3_orgin = RLPy.RMatrix3()
 +
matrix3_orgin.MakeIdentity()
 +
matrix3_orgin.RotationY( 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 
</syntaxhighlight>
 
</syntaxhighlight>
Rotation matrix for rotations around z-axis.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''fAngle''' [IN] angle in radians - float
+
=== RotationZ( self, fAngle ) ===
</div>
+
 
====Returns====
+
Rotation a given 3x3 matrix around the z-axis.
<div style="margin-left: 2em;">Return a new matrix of for rotations around z-axis - RLPy.RMatrix3
+
 
</div>
+
==== Parameters ====
-----
+
:'''fAngle''' [IN] angle in radians - float
===TimesTranspose===
+
 
 +
==== Returns ====
 +
:Return a new 3x3 matrix of for rotations around z-axis - RLPy.RMatrix3
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.TimesTranspose ( self, mM )
+
matrix3_orgin = RLPy.RMatrix3()
 +
matrix3_orgin.MakeIdentity()
 +
matrix3_orgin.RotationZ( 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 
</syntaxhighlight>
 
</syntaxhighlight>
Multiplies of the transpose of the matrix.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''mM''' [IN] the matrix - RLPy.RMatrix3
+
=== AccuScale( self, rkScale ) ===
</div>
+
 
====Returns====
+
Accumulate 3x3 matrix with scale vector.
<div style="margin-left: 2em;">A new matrix. (this * M^T) - RLPy.RMatrix3
+
 
</div>
+
==== Parameters ====
-----
+
rkScale [IN] Scale vector - RLPy.RVector3
===ToEulerAngle===
+
 
 +
==== Returns ====
 +
:Return a new matrix - RLPy.RMatrix3
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.ToEulerAngle ( self, Oreder, rx, ry, rz )
+
matrix3_orgin = RLPy.RMatrix3()
 +
matrix3_orgin.MakeIdentity()
 +
scale_vector = RLPy.RVector3( 2, 2, 2 )
 +
matrix3_orgin.AccuScale(scale_vector)
 
</syntaxhighlight>
 
</syntaxhighlight>
Convert matrix to Euler angle.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''Oreder''' [IN] Euler order - RLPy.Rotation_Order
+
=== ToEulerAngle( self, rkScaleself, Order, rx, ry, rz ) ===
  
'''rx''' [OUT] return angle of x-axis in radians - float
+
Convert matrix to Euler angles.
  
'''ry''' [OUT] return angle of y-axis in radians - float
+
==== Parameters ====
 +
:'''Order''' [IN] Euler order - RLPy.Rotation_Order
 +
:'''rx''' [OUT] return angle of x-axis in radians - float
 +
:'''ry''' [OUT] return angle of y-axis in radians - float
 +
:'''rz''' [OUT] return angle of z-axis in radians - float
  
'''rz''' [OUT] return angle of z-axis in radians - float
 
</div>
 
-----
 
===Transpose===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.Transpose ( self )
+
matrix3_value = RLPy.RMatrix3( -0, -0,  1,
 +
                                0, -1, -0,
 +
                                1,  0, -0 )
 +
euler_angle_x = 0
 +
euler_angle_y = 0
 +
euler_angle_z = 0
 +
result = matrix3_value.ToEulerAngle( RLPy.EEulerOrder_XYZ, euler_angle_x, euler_angle_y, euler_angle_z )
 +
 
 +
print(result[0] * RLPy.RMath.CONST_RAD_TO_DEG) # 180
 +
print(result[1] * RLPy.RMath.CONST_RAD_TO_DEG) # 90
 +
print(result[2] * RLPy.RMath.CONST_RAD_TO_DEG) # 0
 
</syntaxhighlight>
 
</syntaxhighlight>
Transpose of the matrix.
+
 
====Returns====
+
=== FromEulerAngle( self, Order, rx, ry, rz ) ===
<div style="margin-left: 2em;">A new matrix containing this matrix's transpose - RLPy.RMatrix3
+
 
</div>
+
Convert Euler angle to a 3x3 matrix.
-----
+
 
===TransposeTimes===
+
==== Parameters ====
 +
:'''Order''' [IN] Euler order - RLPy.Rotation_Order
 +
:'''rx''' [IN] return angle of x-axis in radians - float
 +
:'''ry''' [IN] return angle of y-axis in radians - float
 +
:'''rz''' [IN] return angle of z-axis in radians - float
 +
 
 +
==== Returns ====
 +
:Return a new matrix from specified axis angle - RLPy.RMatrix3
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix3.TransposeTimes ( self, mM )
+
matrix3_orgin = RLPy.RMatrix3()
 +
euler_angle_x = 90 * RLPy.RMath.CONST_DEG_TO_RAD
 +
euler_angle_y = 0
 +
euler_angle_z = 0
 +
matrix3_result = matrix3_orgin.FromEulerAngle( RLPy.EEulerOrder_XYZ, euler_angle_x, euler_angle_y, euler_angle_z)
 +
row0 = matrix3_result[0].GetRow(0)
 +
 
 +
print(row0[0])
 +
print(row0[1])
 +
print(row0[2])
 
</syntaxhighlight>
 
</syntaxhighlight>
Multiplies of the transpose of the matrix.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''mM''' [IN] the matrix - RLPy.RMatrix3
+
=== FromSphereUnitVec( self, rkVec ) ===
</div>
+
 
====Returns====
+
Convert Euler angle to matrix.
<div style="margin-left: 2em;">A new matrix. (this^T * mM) - RLPy.RMatrix3
+
 
</div>
+
==== Parameters ====
 +
:'''rkVec''' [IN] vector - RLPy.RVector3
 +
 
 +
==== Returns ====
 +
:Return a new 3x3 matrix from sphere unit vector - RLPy.RMatrix3
 +
 
 +
<syntaxhighlight lang="Python">
 +
vector = RLPy.RVector3( 0, 1, 0 )
 +
matrix3_result =  RLPy.RMatrix3().FromSphereUnitVec( vector )
 +
row0 = matrix3_result.GetRow(0)
 +
 
 +
print(row0[0])
 +
print(row0[1])
 +
print(row0[2])
 +
</syntaxhighlight>
 +
 
 +
=== IsRightHandCoordinate( self ) ===
 +
 
 +
Obtain the 3x3 matrix's coordinate system.  '''True''' stands for right-handed coordinate system while ''''False''' for left-handed.
 +
 
 +
==== Returns ====
 +
:'''True''' Right hand coordinate - bool
 +
:'''False''' Left hand coordinate - bool
 +
 
 +
<syntaxhighlight lang="Python">
 +
matrix3_value = RLPy.RMatrix3( 1, 0, 0,
 +
                              0, 1, 0,
 +
                              0, 0, 1 )
 +
result = matrix3_value.IsRightHandCoordinate()
 +
 
 +
print(result)
 +
</syntaxhighlight>

Revision as of 22:04, 24 February 2020

Contents

Main article: Modules.
Last modified: 02/24/2020

Detailed Description

This class represent the 3x3 matrix. iClone uses row-major order where consecutive elements of a row reside next to each other, and the data is read from left to right, top to bottom, in a vertical zig-zag. This class provides access to RLPy's internal 3x3 matrix operators and related functions.

Operators

+

The "addition" operator.

matrix3_a = RLPy.RMatrix3( 1, 2, 3,
                           0, 0, 0,
                           0, 0, 0 )
matrix3_b = RLPy.RMatrix3( 2, 2, 2,
                           0, 0, 0,
                           0, 0, 0 )
matrix3_result = matrix3_a + matrix3_b
print( matrix3_result.GetRow(0)[0] == 1+2 ) # true
print( matrix3_result.GetRow(0)[1] == 2+2 ) # true
print( matrix3_result.GetRow(0)[2] == 3+2 ) # true

-

The "subtraction" operator.

matrix3_a = RLPy.RMatrix3( 1, 2, 3,
                           0, 0, 0,
                           0, 0, 0 )
matrix3_b = RLPy.RMatrix3( 2, 2, 2,
                           0, 0, 0,
                           0, 0, 0 )
matrix3_result = matrix3_a - matrix3_b
print( matrix3_result.GetRow(0)[0] == 1-2 ) # true
print( matrix3_result.GetRow(0)[1] == 2-2 ) # true
print( matrix3_result.GetRow(0)[2] == 3-2 ) # true

*

The "multiplication" operator.

matrix3_a = RLPy.RMatrix3( 1, 2, 3,
                           0, 0, 0,
                           0, 0, 0 )
matrix3_b = RLPy.RMatrix3( 2, 0, 0,
                           2, 0, 0,
                           2, 0, 0 )
matrix3_result = matrix3_a * matrix3_b
print( matrix3_result.GetRow(0)[0] == 1*2 + 2*2 + 3*2 ) # true

/

The "division" operator.

matrix3_a = RLPy.RMatrix3( 1, 2, 3,
                           0, 0, 0,
                           0, 0, 0 )
matrix3_result = matrix3_a / 2
print( matrix3_result.GetRow(0)[0] == 1/2 ) # true
print( matrix3_result.GetRow(0)[1] == 2/2 ) # true
print( matrix3_result.GetRow(0)[2] == 3/2 ) # true

-

The "unary minus" .

matrix3_a = RLPy.RMatrix3( 1, 2, 3,
                           0, 0, 0,
                           0, 0, 0 )
matrix3_result = -matrix3_a
print( matrix3_result.GetRow(0)[0] == -1 ) # true
print( matrix3_result.GetRow(0)[1] == -2 ) # true
print( matrix3_result.GetRow(0)[2] == -3 ) # true

==

The "equal to" operator. Performs a one-by-one comparison of the matrix array.

matrix3_a = RLPy.RMatrix3( 1, 2, 3,
                           0, 0, 0,
                           0, 0, 0 )
matrix3_b = RLPy.RMatrix3( 1, 2, 3,
                           0, 0, 0,
                           0, 0, 0 )
print( matrix3_a == matrix3_b ) # true

!=

The "not equal to" operator. Performs a one-by-one comparison of the matrix array.

matrix3_a = RLPy.RMatrix3( 1, 2, 3,
                           0, 0, 0,
                           0, 0, 0 )
matrix3_b = RLPy.RMatrix3( 4, 5, 6,
                           0, 0, 0,
                           0, 0, 0 )
print( matrix3_a != matrix3_b ) # true

>

The "greater than" operator. Performs a one-by-one comparison of the matrix array.

matrix3_a = RLPy.RMatrix3( 2, 0, 0,
                           0, 0, 0,
                           0, 0, 0 )
matrix3_b = RLPy.RMatrix3( 5, 0, 0,
                           0, 0, 0,
                           0, 0, 0 )
print( matrix3_b >matrix3_a ) # true

>=

The "greater than or equal to" operator. Performs a one-by-one comparison of the matrix array.

matrix3_a = RLPy.RMatrix3( 1, 1, 3,
                           0, 0, 0,
                           0, 0, 0 )
matrix3_b = RLPy.RMatrix3( 1, 1, 9,
                           0, 0, 0,
                           0, 0, 0 )
print( matrix3_b >= matrix3_a ) # true

<

The "less than" operator. Performs a one-by-one comparison of the matrix array.

matrix3_a = RLPy.RMatrix3( 2, 0, 0,
                           0, 0, 0,
                           0, 0, 0 )
matrix3_b = RLPy.RMatrix3( 5, 0, 0,
                           0, 0, 0,
                           0, 0, 0 )
print( matrix3_a< matrix3_b ) # true

<=

The "less than" operator. Performs a one-by-one comparison of the matrix array.

matrix3_a = RLPy.RMatrix3( 1, 1, 3,
                           0, 0, 0,
                           0, 0, 0 )
matrix3_b = RLPy.RMatrix3( 1, 1, 9,
                           0, 0, 0,
                           0, 0, 0 )
print( matrix3_a<= matrix3_b ) # true

+=

The "addition assignment" operator.

matrix3 =  RLPy.RMatrix3( 1, 2, 3,
                          0, 0, 0,
                          0, 0, 0 )
matrix3 += RLPy.RMatrix3( 2, 2, 2,
                          0, 0, 0,
                          0, 0, 0 )
print( matrix3.GetRow(0)[0] == 1+2 ) # true
print( matrix3.GetRow(0)[1] == 2+2 ) # true
print( matrix3.GetRow(0)[2] == 3+2 ) # true

-=

The "subtraction assignment" operator.

matrix3 =  RLPy.RMatrix3( 1, 2, 3,
                          0, 0, 0,
                          0, 0, 0 )
matrix3 -= RLPy.RMatrix3( 2, 2, 2,
                          0, 0, 0,
                          0, 0, 0 )
print( matrix3.GetRow(0)[0] == 1-2 ) # true
print( matrix3.GetRow(0)[1] == 2-2 ) # true
print( matrix3.GetRow(0)[2] == 3-2 ) # true

*=

The "multiplication assignment" operator. For the calculation method, refer to the * operator.

matrix3 =  RLPy.RMatrix3( 1, 2, 3,
                          0, 0, 0,
                          0, 0, 0 )
matrix3 *= 2
print( matrix3.GetRow(0)[0] == 1*2 ) # true
print( matrix3.GetRow(0)[1] == 2*2 ) # true
print( matrix3.GetRow(0)[2] == 3*2 ) # true

/=

The "division assignment" operator. For the calculation method, refer to the / operator.

matrix3 =  RLPy.RMatrix3( 1, 2, 3,
                          0, 0, 0,
                          0, 0, 0 )
matrix3 /= 2
print( matrix3.GetRow(0)[0] == 1/2 ) # true
print( matrix3.GetRow(0)[1] == 2/2 ) # true
print( matrix3.GetRow(0)[2] == 3/2 ) # true

Member Functions

MakeIdentity ( self )

This function can be used to initialize the 3x3 matrix. It is equivalent to setting the matrix to:

[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]

Returns

This object - RLPy.RMatrix3

matrix3 = RLPy.RMatrix3()
matrix3.MakeIdentity()

M ( self, args )

Get the value of an element in a 3x3 matrix by row and column index.

Parameters

nRow [IN] Index of the row in the matrix - int
nCol [IN] Index of the column in the matrix - int

Returns

Returns the matrix element specified by row and col - float*
matrix3 = RLPy.RMatrix3()
matrix3.MakeIdentity()

print(matrix3.M(0,0))  # <Swig Object of type 'float *' at 0x0000020316B015A0>

E ( self, args )

Get the value of an element in a 3x3 matrix by index number (from 0 to 8);

Parameters

nRow [IN] Index of the matrix.

Returns

Returns the matrix element specified by index - float*
matrix3 = RLPy.RMatrix3()
matrix3.MakeIdentity()

print(matrix3.E(0)) #

GetRow ( self, nRow )

Obtain an array of element values within a given row inside a 3x3 matrix.

Parameters

nRow [IN] Index of the row in the matrix - int

Returns

Returns the row vector of the matrix - RLPy.RVector3
matrix3 = RLPy.RMatrix3()
matrix3.MakeIdentity()
row0 = matrix3.GetRow(0)

print(row0[0])
print(row0[1])
print(row0[2])

GetColumn( self, nCol )

Obtain an array of element values within a given column inside a 3x3 matrix.

Parameters

nCol [IN] Index of the row in the matrix - int

Returns

Returns the column vector of the matrix - RLPy.RVector3
matrix3 = RLPy.RMatrix3()
matrix3.MakeIdentity()
col0 = matrix3.GetColumn(0)
print(col0[0])
print(col0[1])
print(col0[2])

Transpose( self )

Obtain the transposed matrix by transposing the current m * n matrix into an n * m matrix by row-column swapping.

Returns

Returns a new matrix containing this matrix's transpose - RLPy.RMatrix3
matrix3_orgin = RLPy.RMatrix3( 1, 2, 3,
                               4, 5, 6,
                               7, 8, 9 )
matrix3_transpose = matrix3_orgin.Transpose()
row0 = matrix3_orgin.GetRow(0)
col0 = matrix3_transpose.GetColumn(0)

print(row0[0] == col0[0])
print(row0[1] == col0[1])
print(row0[2] == col0[2])

TransposeTimes( self, mM )

Multiply a transposed version of a 3x3 matrix with itself.

Parameters

mM [IN] the matrix - RLPy.RMatrix3

Returns

Returns a new matrix. (this^T * mM) - RLPy.RMatrix3
matrix3_orgin = RLPy.RMatrix3( 1, 2, 3,
                               4, 5, 6,
                               7, 8, 9 )
matrix3_transpose_value = RLPy.RMatrix3( 2, 0, 0,
                                         0, 2, 0,
                                         0, 0, 2 )
matrix3_transpose_times = matrix3_orgin.TransposeTimes(matrix3_transpose_value)
row0 = matrix3_orgin.GetRow(0)
col0 = matrix3_transpose_times.GetColumn(0)

print(row0[0]*2 == col0[0])
print(row0[1]*2 == col0[1])
print(row0[2]*2 == col0[2])

TimesTranspose( self, mM )

Multiply a given 3x3 matrix with a transposed version of itself.

Parameters

mM [IN] the matrix - RLPy.RMatrix3

Returns

Returns a new matrix. (this * M^T) - RLPy.RMatrix3
matrix3_orgin = RLPy.RMatrix3( 1, 2, 3,
                               4, 5, 6,
                               7, 8, 9 )
matrix3_transpose_value = RLPy.RMatrix3( 3, 0, 0,
                                         0, 3, 0,
                                         0, 0, 3 )
matrix3_times_transpose = matrix3_orgin.TimesTranspose(matrix3_transpose_value)
row0 = matrix3_orgin.GetColumn(0)
col0 = matrix3_times_transpose.GetColumn(0)

print(row0[0]*3 == col0[0])
print(row0[1]*3 == col0[1])
print(row0[2]*3 == col0[2])

Inverse( self )

Invert a given 3x3 matrix.

Returns

Returns a new matrix containing this matrix's inverse - RLPy.RMatrix3
matrix3_value = RLPy.RMatrix3( 1, 2, 3,
                               2, 3, 4,
                               4, 2, 1 )
matrix3_inverse = matrix3_value.Inverse()
row0 = matrix3_inverse.GetRow(0)
print(row0[0])
print(row0[1])
print(row0[2])

Adjoint( self )

Adjugate a given 3x3 matrix.

matrix3_value = RLPy.RMatrix3( 1, 2, 3,
                               2, 3, 4,
                               4, 2, 1 )
matrix3_Adjoint = matrix3_value.Adjoint()
row0 = matrix3_Adjoint.GetRow(0)

print(row0[0])
print(row0[1])
print(row0[2])

Returns

Returns a new matrix containing this matrix's adjoint - RLPy.RMatrix3

AdjointTranspose( self )

Adjugate and transpose a given 3x3 matrix.

Returns

Returns a new matrix - RLPy.RMatrix3
matrix3_value = RLPy.RMatrix3( 1, 2, 3,
                               2, 3, 4,
                               4, 2, 1 )
matrix3_Adjoint_transpose = matrix3_value.AdjointTranspose()
col0_Adjoint_transpose = matrix3_Adjoint_transpose.GetColumn(0)

print(col0_Adjoint_transpose[0])
print(col0_Adjoint_transpose[1])
print(col0_Adjoint_transpose[2])

InverseTranspose( self )

Invert and transpose a given 3x3 matrix.

Returns

Returns a new matrix - RLPy.RMatrix3
matrix3_value = RLPy.RMatrix3( 1, 2, 3,
                               2, 3, 4,
                               4, 2, 1 )
matrix3_inverse_transpose = matrix3_value.InverseTranspose()
row0_inverse_transpose = matrix3_inverse_transpose.GetRow(0)

print(row0_inverse_transpose[0])
print(row0_inverse_transpose[1])
print(row0_inverse_transpose[2])

Determinant( self )

Obtain the scalar value for a given 3x3 matrix.

Returns

Returns the determinant of the matrix - float
matrix3_value = RLPy.RMatrix3( 1, 2, 3,
                               2, 3, 4,
                               4, 2, 1 )

print(matrix3_value.Determinant())

MaxColumn( self )

Find the maximum absolute value within a 3x3 matrix, and return the column in which the value is located. If all of the elements within the 3x3 matrix are 0 then return -1.

Returns

Return index of column of M containing maximum abs entry, or -1 if M = 0 - int
matrix3_value = RLPy.RMatrix3( 10, 20, -30,
                                0,  0,   0,
                                0,  0,   0 )

print(matrix3_value.MaxColumn()) # column:2 ->abs(-30)

MaxRow( self )

Find the maximum absolute value within a 3x3 matrix, and return the row in which the value is located. If all of the elements within the 3x3 matrix are 0 then return -1.

Returns

Return index of row of M containing maximum abs entry, or -1 if M = 0 - int
matrix3_value = RLPy.RMatrix3( 10, 0, 0,
                               20, 0, 0,
                              -30, 0, 0 )

print(matrix3_value.MaxRow()) # Row:2 ->abs(-30)

OneNorm( self )

Return the sum of the column elements that contain the largest absolute values.

Returns

Return Norm - float
matrix3_row_value = RLPy.RMatrix3( 10, 0, 0,
                                   20, 0, 0,
                                  -30, 0, 0 )

print(matrix3_row_value.OneNorm()) # 10+20+abs(-30) = 60

InfNorm( self )

Return the sum of the row elements that contain the largest absolute values.

Returns

Return InfNorm - float
matrix3_column_value = RLPy.RMatrix3( 10, 20, -30,
                                       0,  0,   0,
                                       0,  0,   0 )

print(matrix3_column_value.InfNorm()) # 10+20+abs(-30) = 60

FromAxisAngle( self, rkAxis, fAngle )

Rotation matrix from axis angle。

Parameters

rkAxis [IN] axis vector - RLPy.RVector3
fAngle [IN] angle in radians - float

Returns

Return a new matrix from specified axis angle - RLPy.RMatrix3
matrix3_orgin = RLPy.RMatrix3()
matrix3_orgin.MakeIdentity()

x_axis_vector = RLPy.RVector3( 1, 0, 0 )  # axis = "X"
y_axis_vector = RLPy.RVector3( 0, 1, 0 )  # axis = "Y"
z_axis_vector = RLPy.RVector3( 0, 0, 1 )  # axis = "Z"    

matrix3_orgin.FromAxisAngle( x_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )
matrix3_orgin.FromAxisAngle( y_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )
matrix3_orgin.FromAxisAngle( z_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )

RotationX( self, fAngle )

Rotation matrix for rotations around x-axis.

Parameters

fAngle [IN] angle in radians - float

Returns

Return a new matrix of for rotations around x-axis - RLPy.RMatrix3
matrix3_orgin = RLPy.RMatrix3()
matrix3_orgin.MakeIdentity()
matrix3_orgin.RotationX( 90 * RLPy.RMath.CONST_DEG_TO_RAD )

RotationY( self, fAngle )

Rotate a given 3x3 matrix around the y-axis。

Parameters

fAngle [IN] angle in radians - float

Returns

Return a new matrix of for rotations around y-axis - RLPy.RMatrix3
matrix3_orgin = RLPy.RMatrix3()
matrix3_orgin.MakeIdentity()
matrix3_orgin.RotationY( 90 * RLPy.RMath.CONST_DEG_TO_RAD )

RotationZ( self, fAngle )

Rotation a given 3x3 matrix around the z-axis.

Parameters

fAngle [IN] angle in radians - float

Returns

Return a new 3x3 matrix of for rotations around z-axis - RLPy.RMatrix3
matrix3_orgin = RLPy.RMatrix3()
matrix3_orgin.MakeIdentity()
matrix3_orgin.RotationZ( 90 * RLPy.RMath.CONST_DEG_TO_RAD )

AccuScale( self, rkScale )

Accumulate 3x3 matrix with scale vector.

Parameters

rkScale [IN] Scale vector - RLPy.RVector3

Returns

Return a new matrix - RLPy.RMatrix3
matrix3_orgin = RLPy.RMatrix3()
matrix3_orgin.MakeIdentity()
scale_vector = RLPy.RVector3( 2, 2, 2 )
matrix3_orgin.AccuScale(scale_vector)

ToEulerAngle( self, rkScaleself, Order, rx, ry, rz )

Convert matrix to Euler angles.

Parameters

Order [IN] Euler order - RLPy.Rotation_Order
rx [OUT] return angle of x-axis in radians - float
ry [OUT] return angle of y-axis in radians - float
rz [OUT] return angle of z-axis in radians - float
matrix3_value = RLPy.RMatrix3( -0, -0,  1,
                                0, -1, -0,
                                1,  0, -0 )
euler_angle_x = 0
euler_angle_y = 0
euler_angle_z = 0
result = matrix3_value.ToEulerAngle( RLPy.EEulerOrder_XYZ, euler_angle_x, euler_angle_y, euler_angle_z )

print(result[0] * RLPy.RMath.CONST_RAD_TO_DEG) # 180
print(result[1] * RLPy.RMath.CONST_RAD_TO_DEG) # 90
print(result[2] * RLPy.RMath.CONST_RAD_TO_DEG) # 0

FromEulerAngle( self, Order, rx, ry, rz )

Convert Euler angle to a 3x3 matrix.

Parameters

Order [IN] Euler order - RLPy.Rotation_Order
rx [IN] return angle of x-axis in radians - float
ry [IN] return angle of y-axis in radians - float
rz [IN] return angle of z-axis in radians - float

Returns

Return a new matrix from specified axis angle - RLPy.RMatrix3
matrix3_orgin = RLPy.RMatrix3()
euler_angle_x = 90 * RLPy.RMath.CONST_DEG_TO_RAD
euler_angle_y = 0
euler_angle_z = 0
matrix3_result = matrix3_orgin.FromEulerAngle( RLPy.EEulerOrder_XYZ, euler_angle_x, euler_angle_y, euler_angle_z)
row0 = matrix3_result[0].GetRow(0)

print(row0[0])
print(row0[1])
print(row0[2])

FromSphereUnitVec( self, rkVec )

Convert Euler angle to matrix.

Parameters

rkVec [IN] vector - RLPy.RVector3

Returns

Return a new 3x3 matrix from sphere unit vector - RLPy.RMatrix3
vector = RLPy.RVector3( 0, 1, 0 )
matrix3_result =  RLPy.RMatrix3().FromSphereUnitVec( vector )
row0 = matrix3_result.GetRow(0)

print(row0[0])
print(row0[1])
print(row0[2])

IsRightHandCoordinate( self )

Obtain the 3x3 matrix's coordinate system. True stands for right-handed coordinate system while 'False for left-handed.

Returns

True Right hand coordinate - bool
False Left hand coordinate - bool
matrix3_value = RLPy.RMatrix3( 1, 0, 0,
                               0, 1, 0,
                               0, 0, 1 )
result = matrix3_value.IsRightHandCoordinate()

print(result)