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
 
(2 intermediate revisions by the same user not shown)
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==
+
== Description ==
This class supports the following operators:
+
 
{| class="wikitable"
+
This class represent a standard 3x3 matrix. This class provides access to RLPy's internal 3x3 matrix operators and related functions. 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:
!Member
+
 
!Operation
+
[0, 1, 2]
!Syntax
+
[3, 4, 5]
!Description
+
[6, 7, 8]
!Example
+
 
|-
+
== Constructor & Destructor ==
! scope="row"|__add__
+
 
|Addition
+
=== __init__(self, fM00, fM01, fM02, fM10, fM11, fM12, fM20, fM21, fM22) ===
|a + b
+
 
|Adds values on either side of the operator.
+
The constructor. Initialize a new 3x3 matrix with another [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] object.
|a + b = 30
+
 
|-
+
==== Parameters ====
! scope="row"|__sub__
+
:'''fM00''' [IN] Initialization value - float
|Subtraction
+
:'''fM01''' [IN] Initialization value - float
|a - b
+
:'''fM02''' [IN] Initialization value - float
|Subtracts right hand operand from left hand operand.
+
:'''fM10''' [IN] Initialization value - float
|a – b = -10
+
:'''fM11''' [IN] Initialization value - float
|-
+
:'''fM12''' [IN] Initialization value - float
! scope="row"|__mul__
+
:'''fM20''' [IN] Initialization value - float
|Multiplication
+
:'''fM21''' [IN] Initialization value - float
|a * b
+
:'''fM22''' [IN] Initialization value - float
|Multiplies values on either side of the operator.
+
 
|a * b = 200
+
==== Returns ====
|-
+
:Returns the row vector of the matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
! scope="row"|__truediv__
+
 
|Division
+
<syntaxhighlight lang="python" line='line'>
|a / b
+
matrix3 = RLPy.RMatrix3( 1, 0, 0,
|Divides left hand operand by right hand operand.
+
                        0, 2, 0,
|b / a = 2
+
                        0, 0, 3 )
|-
+
! 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">
+
RLPy.RMatrix3.AccuScale ( self, rkScale )
+
 
</syntaxhighlight>
 
</syntaxhighlight>
Accumulate matrix with scale vector.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''rkScale''' [IN] Scale vector - RLPy.RVector3
+
=== __init__(self, fM00, fM11, fM22) ===
</div>
+
 
====Returns====
+
The constructor. Initialize a new 3x3 matrix with RMatrix3[0,0], RMatrix3[1,1], RMatrix3[2,2].
<div style="margin-left: 2em;">Return a new matrix - RLPy.RMatrix3
+
 
</div>
+
==== Parameters ====
-----
+
:'''fM00''' [IN] Initialization value - float
===Adjoint===
+
:'''fM11''' [IN] Initialization value - float
<syntaxhighlight lang="Python">
+
:'''fM22''' [IN] Initialization value - float
RLPy.RMatrix3.Adjoint ( self )
+
 
 +
==== Returns ====
 +
:Returns the row vector of the matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
matrix3_init = RLPy.RMatrix3(1,2,3)
 +
matrix3 = RLPy.RMatrix3( 1, 0, 0,
 +
                        0, 2, 0,
 +
                        0, 0, 3 )
 +
 
 +
print( matrix3_init == matrix3 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Inverse times determinant.
+
 
====Returns====
+
=== __init__(self, args) ===
<div style="margin-left: 2em;">A new matrix containing this matrix's adjoint - RLPy.RMatrix3
+
 
</div>
+
The constructor. Initialize a new 3x3 matrix with another [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] object.
-----
+
 
===AdjointTranspose===
+
==== Parameters ====
<syntaxhighlight lang="Python">
+
:'''args''' [IN] A 3X3 matrix object - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
RLPy.RMatrix3.AdjointTranspose ( self )
+
 
 +
==== Returns ====
 +
:Returns the row vector of the matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
matrix3 = RLPy.RMatrix3( 1, 0, 0,
 +
                        0, 2, 0,
 +
                        0, 0, 3 )
 +
matrix3_copy = RLPy.RMatrix3(matrix3)                     
 +
print( matrix3_copy == matrix3 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Transpose of inverse times determinant.
+
 
====Returns====
+
=== __init__(self, rAxis, fAngle) ===
<div style="margin-left: 2em;">A new matrix - RLPy.RMatrix3
+
 
</div>
+
The constructor. Initialize a new 3x3 matrix with [[IC_Python_API:RLPy_RVector3|RVector3]] axis object and angle.
-----
+
 
===Determinant===
+
==== Parameters ====
<syntaxhighlight lang="Python">
+
:'''rAxis''' [IN]  a [[IC_Python_API:RLPy_RVector3|RVector3]] object - [[IC_Python_API:RLPy_RVector3|RVector3]] 
RLPy.RMatrix3.Determinant ( self )
+
:'''fAngle''' [IN] a float object - float
 +
 
 +
==== Returns ====
 +
:Returns the row vector of the matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
matrix3 = RLPy.RMatrix3( RLPy.RVector3( 1, 0, 0 ), 3 )
 
</syntaxhighlight>
 
</syntaxhighlight>
The matrix's determinant.
+
 
====Returns====
+
== Operators ==
<div style="margin-left: 2em;">The determinant of the matrix - float
+
 
</div>
+
=== + ===
-----
+
 
===E===
+
The "addition" operator.
<syntaxhighlight lang="Python">
+
 
RLPy.RMatrix3.E ( self, args )
+
See Also: [[#+=|+=]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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>
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 "subtraction" operator.
<div style="margin-left: 2em;">The matrix element specified by index - float
+
 
</div>
+
See Also: [[#-=|-=]]
-----
+
 
===FromAxisAngle===
+
<syntaxhighlight lang="python" line='line'>
<syntaxhighlight lang="Python">
+
matrix3_a = RLPy.RMatrix3( 1, 2, 3,
RLPy.RMatrix3.FromAxisAngle ( self, rkAxis, fAngle )
+
                          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>
Rotation matrix from axis angle.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''rkAxis''' [IN] axis vector - RLPy.RVector3
+
=== * ===
 +
 
 +
The "multiplication" operator.
 +
 
 +
See Also: [[#*=|*=]]
  
'''fAngle''' [IN] angle in radians - float
+
<syntaxhighlight lang="python" line='line'>
</div>
+
matrix3_a = RLPy.RMatrix3( 1, 2, 3,
====Returns====
+
                          0, 0, 0,
<div style="margin-left: 2em;">Return a new matrix from specified axis angle - RLPy.RMatrix3
+
                          0, 0, 0 )
</div>
+
matrix3_b = RLPy.RMatrix3( 2, 0, 0,
-----
+
                          2, 0, 0,
===FromEulerAngle===
+
                          2, 0, 0 )
<syntaxhighlight lang="Python">
+
matrix3_result = matrix3_a * matrix3_b
RLPy.RMatrix3.FromEulerAngle ( Oreder, rx, ry, rz )
+
print( matrix3_result.GetRow(0)[0] == 1*2 + 2*2 + 3*2 ) # 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 "division" operator.
  
'''ry''' [IN] Angle of y-axis in radians - float
+
See Also: [[#/=|/=]]
  
'''rz''' [IN] Angle of z-axis in radians - float
+
<syntaxhighlight lang="python" line='line'>
</div>
+
matrix3_a = RLPy.RMatrix3( 1, 2, 3,
====Returns====
+
                          0, 0, 0,
<div style="margin-left: 2em;">Return a new matrix from specified axis angle - RLPy.RMatrix3
+
                          0, 0, 0 )
</div>
+
matrix3_result = matrix3_a / 2
-----
+
 
===FromSpereUnitVec===
+
print( matrix3_result.GetRow(0)[0] == 1/2 ) # true
<syntaxhighlight lang="Python">
+
print( matrix3_result.GetRow(0)[1] == 2/2 ) # true
RLPy.RMatrix3.FromSpereUnitVec ( self, rkVec )
+
print( matrix3_result.GetRow(0)[2] == 3/2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Rotation matrix from sphere unit vector.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''rkVec''' [IN] vector - RLPy.RVector3
+
=== - ===
</div>
+
 
====Returns====
+
The "unary minus" operator.
<div style="margin-left: 2em;">Return a new matrix from sphere unit vector - RLPy.RMatrix3
+
 
</div>
+
<syntaxhighlight lang="python" line='line'>
-----
+
matrix3_a = RLPy.RMatrix3( 1, 2, 3,
===GetColumn===
+
                          0, 0, 0,
<syntaxhighlight lang="Python">
+
                          0, 0, 0 )
RLPy.RMatrix3.GetColumn ( self, nCol )
+
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 column.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''nRow''' [IN] Index of the column in the matrix.
+
=== == ===
</div>
+
 
====Returns====
+
The "equal to" 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>
+
See Also: [[#!=|!=]]
-----
+
 
===GetRow===
+
<syntaxhighlight lang="python" line='line'>
<syntaxhighlight lang="Python">
+
matrix3_a = RLPy.RMatrix3( 1, 2, 3,
RLPy.RMatrix3.GetRow ( self, nRow )
+
                          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>
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 "not equal to" operator. Performs a one-by-one comparison of the matrix array.
<div style="margin-left: 2em;">The row vector of the matrix - RLPy.RVector3
+
 
</div>
+
See Also: [[#==|==]]
-----
+
 
===InfNorm===
+
<syntaxhighlight lang="python" line='line'>
<syntaxhighlight lang="Python">
+
matrix3_a = RLPy.RMatrix3( 1, 2, 3,
RLPy.RMatrix3.InfNorm ( self )
+
                          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>
InfNorm of the matrix.
+
 
====Returns====
+
=== > ===
<div style="margin-left: 2em;">Return InfNorm - float
+
 
</div>
+
The "greater than" operator. Performs a one-by-one comparison of the matrix array.
-----
+
 
===Inverse===
+
See Also: [[#>=|>=]]
<syntaxhighlight lang="Python">
+
 
RLPy.RMatrix3.Inverse ( self )
+
<syntaxhighlight lang="python" line='line'>
 +
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>
 
</syntaxhighlight>
Inverse of the matrix.
+
 
====Returns====
+
=== >= ===
<div style="margin-left: 2em;">A new matrix containing this matrix's inverse - RLPy.RMatrix3
+
 
</div>
+
The "greater than or equal to" operator. Performs a one-by-one comparison of the matrix array.
-----
+
 
===InverseTranspose===
+
See Also: [[#>|>]]
<syntaxhighlight lang="Python">
+
 
RLPy.RMatrix3.InverseTranspose ( self )
+
<syntaxhighlight lang="python" line='line'>
 +
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>
Transpose of inverse.
+
 
====Returns====
+
=== < ===
<div style="margin-left: 2em;">A new matrix - RLPy.RMatrix3
+
 
</div>
+
The "less than" operator. Performs a one-by-one comparison of the matrix array.
-----
+
 
===IsRightHandCoordinate===
+
See Also: [[#<=|<=]]
<syntaxhighlight lang="Python">
+
 
RLPy.RMatrix3.IsRightHandCoordinate ( self )
+
<syntaxhighlight lang="python" line='line'>
 +
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>
Determine the coordinate is right hand or left hand.
 
====Return Values====
 
<div style="margin-left: 2em;">
 
  
'''true''' Right hand coordinate
+
=== <= ===
  
'''true''' Left hand coordinate
+
The "less than" operator. Performs a one-by-one comparison of the matrix array.
</div>
+
 
-----
+
See Also: [[#<|<]]
===M===
+
 
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python" line='line'>
RLPy.RMatrix3.M ( self, args )
+
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 and column.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''nRow''' [IN] Index of the row in the matrix - int
+
=== += ===
  
'''nCol''' [IN] Index of the column in the matrix - int
+
The "addition assignment" operator.
</div>
+
 
====Returns====
+
See Also: [[#+|+]]
<div style="margin-left: 2em;">The matrix element specified by row and col - float
+
 
</div>
+
<syntaxhighlight lang="python" line='line'>
-----
+
matrix3 =  RLPy.RMatrix3( 1, 2, 3,
===MakeIdentity===
+
                          0, 0, 0,
<syntaxhighlight lang="Python">
+
                          0, 0, 0 )
RLPy.RMatrix3.MakeIdentity ( self )
+
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>
Sets the matrix to the identity.
+
 
====Returns====
+
=== -= ===
<div style="margin-left: 2em;">This object - RLPy.RMatrix3
+
 
</div>
+
The "subtraction assignment" operator.
-----
+
 
===MaxColumn===
+
See Also: [[#-|-]]
<syntaxhighlight lang="Python">
+
 
RLPy.RMatrix3.MaxColumn ( self )
+
<syntaxhighlight lang="python" line='line'>
 +
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>
Get maximum value of the column index in the matrix.
+
 
====Returns====
+
=== *= ===
<div style="margin-left: 2em;">Return index of column of M containing maximum abs entry, or -1 if M = 0 - int
+
 
</div>
+
The "multiplication assignment" operator.
-----
+
 
===MaxRow===
+
See Also: [[#*|*]]
<syntaxhighlight lang="Python">
+
 
RLPy.RMatrix3.MaxRow ( self )
+
<syntaxhighlight lang="python" line='line'>
 +
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>
Get maximum value of the row index in the matrix.
+
 
====Returns====
+
=== /= ===
<div style="margin-left: 2em;">Return index of row of M containing maximum abs entry, or -1 if M = 0 - int
+
 
</div>
+
The "division assignment" operator.
-----
+
 
===OneNorm===
+
See Also: [[#/|/]]
<syntaxhighlight lang="Python">
+
 
RLPy.RMatrix3.OneNorm ( self )
+
<syntaxhighlight lang="python" line='line'>
 +
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>
Norm of the matrix.
+
 
====Returns====
+
== Member Functions ==
<div style="margin-left: 2em;">Return Norm - float
+
 
</div>
+
=== MakeIdentity ( self ) ===
-----
+
 
===RotationX===
+
This function can be used to initialize the 3x3 matrix.  It is equivalent to setting the matrix to:
<syntaxhighlight lang="Python">
+
 
RLPy.RMatrix3.RotationX ( self, fAngle )
+
[1 0 0]
 +
[0 1 0]
 +
[0 0 1]
 +
 
 +
==== Returns ====
 +
 
 +
This object - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
matrix3 = RLPy.RMatrix3()
 +
matrix3.MakeIdentity()
 
</syntaxhighlight>
 
</syntaxhighlight>
Rotation matrix for rotations around x-axis.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''fAngle''' [IN] angle in radians - float
+
=== M ( self, args ) ===
</div>
+
 
====Returns====
+
Get the value of an element in a 3x3 matrix by row and column index.
<div style="margin-left: 2em;">Return a new matrix of for rotations around x-axis - RLPy.RMatrix3
+
 
</div>
+
==== Parameters ====
-----
+
:'''nRow''' [IN] Index of the row in the matrix - int
===RotationY===
+
:'''nCol''' [IN] Index of the column in the matrix - int
<syntaxhighlight lang="Python">
+
 
RLPy.RMatrix3.RotationY ( self, fAngle )
+
==== Returns ====
 +
:The matrix element specified by row and column - float
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
matrix3 = RLPy.RMatrix3()
 +
matrix3.MakeIdentity()
 +
 
 +
print(matrix3.M(0,0))  # <Swig Object of type 'float *' at 0x0000020316B015A0>
 
</syntaxhighlight>
 
</syntaxhighlight>
Rotation matrix for rotations around y-axis.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''fAngle''' [IN] angle in radians - float
+
=== E ( self, args ) ===
</div>
+
 
====Returns====
+
Get the value of an element in a 3x3 matrix by index number (from 0 to 8);
<div style="margin-left: 2em;">Return a new matrix of for rotations around y-axis - RLPy.RMatrix3
+
 
</div>
+
==== Parameters ====
-----
+
:'''nRow''' [IN] Index of the matrix.
===RotationZ===
+
 
<syntaxhighlight lang="Python">
+
==== Returns ====
RLPy.RMatrix3.RotationZ ( self, fAngle )
+
:The matrix element specified by index - float
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
matrix3 = RLPy.RMatrix3()
 +
matrix3.MakeIdentity()
 +
 
 +
print(matrix3.E(0)) #
 
</syntaxhighlight>
 
</syntaxhighlight>
Rotation matrix for rotations around z-axis.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''fAngle''' [IN] angle in radians - float
+
=== GetRow ( self, nRow ) ===
</div>
+
 
====Returns====
+
Retreive a row inside a 3x3 matrix.
<div style="margin-left: 2em;">Return a new matrix of for rotations around z-axis - RLPy.RMatrix3
+
 
</div>
+
==== Parameters ====
-----
+
:'''nRow''' [IN] Index of the row in the matrix - int
===TimesTranspose===
+
 
<syntaxhighlight lang="Python">
+
==== Returns ====
RLPy.RMatrix3.TimesTranspose ( self, mM )
+
:The row vector of the matrix - [[IC_Python_API:RLPy_RVector3|RVector3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
matrix3 = RLPy.RMatrix3()
 +
matrix3.MakeIdentity()
 +
row0 = matrix3.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
+
=== GetColumn( self, nCol ) ===
</div>
+
 
====Returns====
+
Retreive a column inside a 3x3 matrix.
<div style="margin-left: 2em;">A new matrix. (this * M^T) - RLPy.RMatrix3
+
 
</div>
+
==== Parameters ====
-----
+
:'''nCol''' [IN] Index of the row in the matrix - int
===ToEulerAngle===
+
 
<syntaxhighlight lang="Python">
+
==== Returns ====
RLPy.RMatrix3.ToEulerAngle ( self, Oreder, rx, ry, rz )
+
:The column vector of the matrix - [[IC_Python_API:RLPy_RVector3|RVector3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
matrix3 = RLPy.RMatrix3()
 +
matrix3.MakeIdentity()
 +
col0 = matrix3.GetColumn(0)
 +
 
 +
print(col0[0])
 +
print(col0[1])
 +
print(col0[2])
 
</syntaxhighlight>
 
</syntaxhighlight>
Convert matrix to Euler angle.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''Oreder''' [IN] Euler order - RLPy.Rotation_Order
+
=== Transpose( self ) ===
  
'''rx''' [OUT] return angle of x-axis in radians - float
+
Obtain the transposed matrix by transposing the current m * n matrix into an n * m matrix by row-column swapping.
  
'''ry''' [OUT] return angle of y-axis in radians - float
+
==== Returns ====
 +
:A new matrix containing this matrix's transpose - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
  
'''rz''' [OUT] return angle of z-axis in radians - float
+
<syntaxhighlight lang="python" line='line'>
</div>
+
matrix3_orgin = RLPy.RMatrix3( 1, 2, 3,
-----
+
                              4, 5, 6,
===Transpose===
+
                              7, 8, 9 )
<syntaxhighlight lang="Python">
+
matrix3_transpose = matrix3_orgin.Transpose()
RLPy.RMatrix3.Transpose ( self )
+
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>
Transpose of the matrix.
+
 
====Returns====
+
=== TransposeTimes( self, mM ) ===
<div style="margin-left: 2em;">A new matrix containing this matrix's transpose - RLPy.RMatrix3
+
 
</div>
+
Multiply a transposed version of a 3x3 matrix with itself.
-----
+
 
===TransposeTimes===
+
==== Parameters ====
<syntaxhighlight lang="Python">
+
:'''mM''' [IN] the matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
RLPy.RMatrix3.TransposeTimes ( self, mM )
+
 
 +
==== Returns ====
 +
:A new matrix. (this^T * mM) - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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>
 
</syntaxhighlight>
Multiplies of the transpose of the matrix.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''mM''' [IN] the matrix - RLPy.RMatrix3
+
=== TimesTranspose( self, mM ) ===
</div>
+
 
====Returns====
+
Multiply this 3x3 matrix with a transposed version of itself.
<div style="margin-left: 2em;">A new matrix. (this^T * mM) - RLPy.RMatrix3
+
 
</div>
+
==== Parameters ====
 +
:'''mM''' [IN] the matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
==== Returns ====
 +
:A new matrix. (this * M^T) - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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 ) ===
 +
 
 +
Obtain the inverse (reciprocal) of this 3x3 matrix (A^-1).
 +
 
 +
==== Returns ====
 +
:A new matrix containing this matrix's inverse - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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 this 3x3 matrix.
 +
 
 +
==== Returns ====
 +
:A new matrix containing this matrix's adjoint - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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>
 +
 
 +
=== AdjointTranspose( self ) ===
 +
 
 +
Adjugate and transpose this 3x3 matrix.
 +
 
 +
==== Returns ====
 +
:A new adjugated and transposed matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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 this 3x3 matrix.
 +
 
 +
==== Returns ====
 +
:A new inverted and transposed matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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 this 3x3 matrix (|A|).
 +
 
 +
==== Returns ====
 +
:The determinant of the matrix - float
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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 this 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 ====
 +
:Index of column of M containing maximum abs entry, or -1 if M = 0 - int
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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 this 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 ====
 +
:Index of row of M containing maximum abs entry, or -1 if M = 0 - int
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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 ====
 +
:Norm of this 3x3 matrix - float
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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 ====
 +
:InfNorm of this 3x3 matrix - float
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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 - [[IC_Python_API:RLPy_RVector3|RVector3]]
 +
:'''fAngle''' [IN] angle in radians - float
 +
 
 +
==== Returns ====
 +
:A new matrix from specified axis angle - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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 ) ===
 +
 
 +
Rotate this 3x3 matrix around the x-axis.
 +
 
 +
==== Parameters ====
 +
fAngle  [IN] angle in radians - float
 +
 
 +
==== Returns ====
 +
:The rotated 3x3 matrix around the x-axis - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
matrix3_orgin = RLPy.RMatrix3()
 +
matrix3_orgin.MakeIdentity()
 +
matrix3_orgin.RotationX( 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 +
</syntaxhighlight>
 +
 
 +
=== RotationY( self, fAngle ) ===
 +
 
 +
Rotate this 3x3 matrix around the y-axis。
 +
 
 +
==== Parameters ====
 +
:'''fAngle''' [IN] angle in radians - float
 +
 
 +
==== Returns ====
 +
:The rotated 3x3 matrix around the y-axis - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
matrix3_orgin = RLPy.RMatrix3()
 +
matrix3_orgin.MakeIdentity()
 +
matrix3_orgin.RotationY( 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 +
</syntaxhighlight>
 +
 
 +
=== RotationZ( self, fAngle ) ===
 +
 
 +
Rotation this 3x3 matrix around the z-axis.
 +
 
 +
==== Parameters ====
 +
:'''fAngle''' [IN] angle in radians - float
 +
 
 +
==== Returns ====
 +
:A new 3x3 matrix of for rotations around z-axis - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
matrix3_orgin = RLPy.RMatrix3()
 +
matrix3_orgin.MakeIdentity()
 +
matrix3_orgin.RotationZ( 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 +
</syntaxhighlight>
 +
 
 +
=== AccuScale( self, rkScale ) ===
 +
 
 +
Accumulate 3x3 matrix with scale vector.
 +
 
 +
==== Parameters ====
 +
rkScale [IN] Scale vector - [[IC_Python_API:RLPy_RVector3|RVector3]]
 +
 
 +
==== Returns ====
 +
:A newly scaled matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
matrix3_orgin = RLPy.RMatrix3()
 +
matrix3_orgin.MakeIdentity()
 +
scale_vector = RLPy.RVector3( 2, 2, 2 )
 +
matrix3_orgin.AccuScale(scale_vector)
 +
</syntaxhighlight>
 +
 
 +
=== ToEulerAngle( self, rkScaleself, Order, rx, ry, rz ) ===
 +
 
 +
Convert 3x3 matrix to Euler angles.
 +
 
 +
==== Parameters ====
 +
:'''Order''' [IN] Euler order - RLPy.Rotation_Order
 +
:'''rx''' [OUT] Angle of x-axis in radians - float
 +
:'''ry''' [OUT] Angle of y-axis in radians - float
 +
:'''rz''' [OUT] Angle of z-axis in radians - float
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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>
 +
 
 +
=== FromEulerAngle( self, Order, rx, ry, rz ) ===
 +
 
 +
Convert Euler angle to a 3x3 matrix according to a rotation axis order.
 +
 
 +
==== Parameters ====
 +
:'''Order''' [IN] Euler order - RLPy.Rotation_Order
 +
:'''rx''' [IN] Angle of x-axis in radians - float
 +
:'''ry''' [IN] Angle of y-axis in radians - float
 +
:'''rz''' [IN] Angle of z-axis in radians - float
 +
 
 +
==== Returns ====
 +
:A new matrix from specified axis angle - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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>
 +
 
 +
=== FromSphereUnitVec( self, rkVec ) ===
 +
 
 +
Convert Euler angle to matrix.
 +
 
 +
==== Parameters ====
 +
:'''rkVec''' [IN] vector - [[IC_Python_API:RLPy_RVector3|RVector3]]
 +
 
 +
==== Returns ====
 +
:A new 3x3 matrix from sphere unit vector - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
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 this 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" line='line'>
 +
matrix3_value = RLPy.RMatrix3( 1, 0, 0,
 +
                              0, 1, 0,
 +
                              0, 0, 1 )
 +
result = matrix3_value.IsRightHandCoordinate()
 +
 
 +
print(result)
 +
</syntaxhighlight>

Latest revision as of 23:15, 13 April 2020

Contents

Main article: Modules.
Last modified: 04/13/2020

Description

This class represent a standard 3x3 matrix. This class provides access to RLPy's internal 3x3 matrix operators and related functions. 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:

[0, 1, 2]
[3, 4, 5]
[6, 7, 8]

Constructor & Destructor

__init__(self, fM00, fM01, fM02, fM10, fM11, fM12, fM20, fM21, fM22)

The constructor. Initialize a new 3x3 matrix with another RMatrix3 object.

Parameters

fM00 [IN] Initialization value - float
fM01 [IN] Initialization value - float
fM02 [IN] Initialization value - float
fM10 [IN] Initialization value - float
fM11 [IN] Initialization value - float
fM12 [IN] Initialization value - float
fM20 [IN] Initialization value - float
fM21 [IN] Initialization value - float
fM22 [IN] Initialization value - float

Returns

Returns the row vector of the matrix - RMatrix3
1 matrix3 = RLPy.RMatrix3( 1, 0, 0,
2                          0, 2, 0,
3                          0, 0, 3 )

__init__(self, fM00, fM11, fM22)

The constructor. Initialize a new 3x3 matrix with RMatrix3[0,0], RMatrix3[1,1], RMatrix3[2,2].

Parameters

fM00 [IN] Initialization value - float
fM11 [IN] Initialization value - float
fM22 [IN] Initialization value - float

Returns

Returns the row vector of the matrix - RMatrix3
1 matrix3_init = RLPy.RMatrix3(1,2,3)
2 matrix3 = RLPy.RMatrix3( 1, 0, 0,
3                          0, 2, 0,
4                          0, 0, 3 )
5 
6 print( matrix3_init == matrix3 ) # true

__init__(self, args)

The constructor. Initialize a new 3x3 matrix with another RMatrix3 object.

Parameters

args [IN] A 3X3 matrix object - RMatrix3

Returns

Returns the row vector of the matrix - RMatrix3
1 matrix3 = RLPy.RMatrix3( 1, 0, 0,
2                          0, 2, 0,
3                          0, 0, 3 )
4 matrix3_copy = RLPy.RMatrix3(matrix3)                      
5 print( matrix3_copy == matrix3 ) # true

__init__(self, rAxis, fAngle)

The constructor. Initialize a new 3x3 matrix with RVector3 axis object and angle.

Parameters

rAxis [IN] a RVector3 object - RVector3
fAngle [IN] a float object - float

Returns

Returns the row vector of the matrix - RMatrix3
1 matrix3 = RLPy.RMatrix3( RLPy.RVector3( 1, 0, 0 ), 3 )

Operators

+

The "addition" operator.

See Also: +=

 1 matrix3_a = RLPy.RMatrix3( 1, 2, 3,
 2                            0, 0, 0,
 3                            0, 0, 0 )
 4 matrix3_b = RLPy.RMatrix3( 2, 2, 2,
 5                            0, 0, 0,
 6                            0, 0, 0 )
 7 matrix3_result = matrix3_a + matrix3_b
 8 
 9 print( matrix3_result.GetRow(0)[0] == 1+2 ) # true
10 print( matrix3_result.GetRow(0)[1] == 2+2 ) # true
11 print( matrix3_result.GetRow(0)[2] == 3+2 ) # true

-

The "subtraction" operator.

See Also: -=

 1 matrix3_a = RLPy.RMatrix3( 1, 2, 3,
 2                            0, 0, 0,
 3                            0, 0, 0 )
 4 matrix3_b = RLPy.RMatrix3( 2, 2, 2,
 5                            0, 0, 0,
 6                            0, 0, 0 )
 7 matrix3_result = matrix3_a - matrix3_b
 8 
 9 print( matrix3_result.GetRow(0)[0] == 1-2 ) # true
10 print( matrix3_result.GetRow(0)[1] == 2-2 ) # true
11 print( matrix3_result.GetRow(0)[2] == 3-2 ) # true

*

The "multiplication" operator.

See Also: *=

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

/

The "division" operator.

See Also: /=

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

-

The "unary minus" operator.

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

==

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

See Also: !=

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

!=

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

See Also: ==

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

>

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

See Also: >=

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

>=

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

See Also: >

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

<

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

See Also: <=

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

<=

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

See Also: <

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

+=

The "addition assignment" operator.

See Also: +

 1 matrix3 =  RLPy.RMatrix3( 1, 2, 3,
 2                           0, 0, 0,
 3                           0, 0, 0 )
 4 matrix3 += RLPy.RMatrix3( 2, 2, 2,
 5                           0, 0, 0,
 6                           0, 0, 0 )
 7 
 8 print( matrix3.GetRow(0)[0] == 1+2 ) # true
 9 print( matrix3.GetRow(0)[1] == 2+2 ) # true
10 print( matrix3.GetRow(0)[2] == 3+2 ) # true

-=

The "subtraction assignment" operator.

See Also: -

 1 matrix3 =  RLPy.RMatrix3( 1, 2, 3,
 2                           0, 0, 0,
 3                           0, 0, 0 )
 4 matrix3 -= RLPy.RMatrix3( 2, 2, 2,
 5                           0, 0, 0,
 6                           0, 0, 0 )
 7 
 8 print( matrix3.GetRow(0)[0] == 1-2 ) # true
 9 print( matrix3.GetRow(0)[1] == 2-2 ) # true
10 print( matrix3.GetRow(0)[2] == 3-2 ) # true

*=

The "multiplication assignment" operator.

See Also: *

1 matrix3 =  RLPy.RMatrix3( 1, 2, 3,
2                           0, 0, 0,
3                           0, 0, 0 )
4 matrix3 *= 2
5 
6 print( matrix3.GetRow(0)[0] == 1*2 ) # true
7 print( matrix3.GetRow(0)[1] == 2*2 ) # true
8 print( matrix3.GetRow(0)[2] == 3*2 ) # true

/=

The "division assignment" operator.

See Also: /

1 matrix3 =  RLPy.RMatrix3( 1, 2, 3,
2                           0, 0, 0,
3                           0, 0, 0 )
4 matrix3 /= 2
5 
6 print( matrix3.GetRow(0)[0] == 1/2 ) # true
7 print( matrix3.GetRow(0)[1] == 2/2 ) # true
8 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 1 0]
[0 0 1]

Returns

This object - RMatrix3

1 matrix3 = RLPy.RMatrix3()
2 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

The matrix element specified by row and column - float
1 matrix3 = RLPy.RMatrix3()
2 matrix3.MakeIdentity()
3 
4 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

The matrix element specified by index - float
1 matrix3 = RLPy.RMatrix3()
2 matrix3.MakeIdentity()
3 
4 print(matrix3.E(0)) #

GetRow ( self, nRow )

Retreive a row inside a 3x3 matrix.

Parameters

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

Returns

The row vector of the matrix - RVector3
1 matrix3 = RLPy.RMatrix3()
2 matrix3.MakeIdentity()
3 row0 = matrix3.GetRow(0)
4 
5 print(row0[0])
6 print(row0[1])
7 print(row0[2])

GetColumn( self, nCol )

Retreive a column inside a 3x3 matrix.

Parameters

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

Returns

The column vector of the matrix - RVector3
1 matrix3 = RLPy.RMatrix3()
2 matrix3.MakeIdentity()
3 col0 = matrix3.GetColumn(0)
4 
5 print(col0[0])
6 print(col0[1])
7 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

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

TransposeTimes( self, mM )

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

Parameters

mM [IN] the matrix - RMatrix3

Returns

A new matrix. (this^T * mM) - RMatrix3
 1 matrix3_orgin = RLPy.RMatrix3( 1, 2, 3,
 2                                4, 5, 6,
 3                                7, 8, 9 )
 4 matrix3_transpose_value = RLPy.RMatrix3( 2, 0, 0,
 5                                          0, 2, 0,
 6                                          0, 0, 2 )
 7 matrix3_transpose_times = matrix3_orgin.TransposeTimes(matrix3_transpose_value)
 8 row0 = matrix3_orgin.GetRow(0)
 9 col0 = matrix3_transpose_times.GetColumn(0)
10 
11 print(row0[0]*2 == col0[0])
12 print(row0[1]*2 == col0[1])
13 print(row0[2]*2 == col0[2])

TimesTranspose( self, mM )

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

Parameters

mM [IN] the matrix - RMatrix3

Returns

A new matrix. (this * M^T) - RMatrix3
 1 matrix3_orgin = RLPy.RMatrix3( 1, 2, 3,
 2                                4, 5, 6,
 3                                7, 8, 9 )
 4 matrix3_transpose_value = RLPy.RMatrix3( 3, 0, 0,
 5                                          0, 3, 0,
 6                                          0, 0, 3 )
 7 matrix3_times_transpose = matrix3_orgin.TimesTranspose(matrix3_transpose_value)
 8 row0 = matrix3_orgin.GetColumn(0)
 9 col0 = matrix3_times_transpose.GetColumn(0)
10 
11 print(row0[0]*3 == col0[0])
12 print(row0[1]*3 == col0[1])
13 print(row0[2]*3 == col0[2])

Inverse( self )

Obtain the inverse (reciprocal) of this 3x3 matrix (A^-1).

Returns

A new matrix containing this matrix's inverse - RMatrix3
1 matrix3_value = RLPy.RMatrix3( 1, 2, 3,
2                                2, 3, 4,
3                                4, 2, 1 )
4 matrix3_inverse = matrix3_value.Inverse()
5 row0 = matrix3_inverse.GetRow(0)
6 
7 print(row0[0])
8 print(row0[1])
9 print(row0[2])

Adjoint( self )

Adjugate this 3x3 matrix.

Returns

A new matrix containing this matrix's adjoint - RMatrix3
1 matrix3_value = RLPy.RMatrix3( 1, 2, 3,
2                                2, 3, 4,
3                                4, 2, 1 )
4 matrix3_Adjoint = matrix3_value.Adjoint()
5 row0 = matrix3_Adjoint.GetRow(0)
6 
7 print(row0[0])
8 print(row0[1])
9 print(row0[2])

AdjointTranspose( self )

Adjugate and transpose this 3x3 matrix.

Returns

A new adjugated and transposed matrix - RMatrix3
1 matrix3_value = RLPy.RMatrix3( 1, 2, 3,
2                                2, 3, 4,
3                                4, 2, 1 )
4 matrix3_Adjoint_transpose = matrix3_value.AdjointTranspose()
5 col0_Adjoint_transpose = matrix3_Adjoint_transpose.GetColumn(0)
6 
7 print(col0_Adjoint_transpose[0])
8 print(col0_Adjoint_transpose[1])
9 print(col0_Adjoint_transpose[2])

InverseTranspose( self )

Invert and transpose this 3x3 matrix.

Returns

A new inverted and transposed matrix - RMatrix3
1 matrix3_value = RLPy.RMatrix3( 1, 2, 3,
2                                2, 3, 4,
3                                4, 2, 1 )
4 matrix3_inverse_transpose = matrix3_value.InverseTranspose()
5 row0_inverse_transpose = matrix3_inverse_transpose.GetRow(0)
6 
7 print(row0_inverse_transpose[0])
8 print(row0_inverse_transpose[1])
9 print(row0_inverse_transpose[2])

Determinant( self )

Obtain the scalar value for this 3x3 matrix (|A|).

Returns

The determinant of the matrix - float
1 matrix3_value = RLPy.RMatrix3( 1, 2, 3,
2                                2, 3, 4,
3                                4, 2, 1 )
4 
5 print(matrix3_value.Determinant())

MaxColumn( self )

Find the maximum absolute value within this 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

Index of column of M containing maximum abs entry, or -1 if M = 0 - int
1 matrix3_value = RLPy.RMatrix3( 10, 20, -30,
2                                 0,  0,   0,
3                                 0,  0,   0 )
4 
5 print(matrix3_value.MaxColumn()) # column:2 ->abs(-30)

MaxRow( self )

Find the maximum absolute value within this 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

Index of row of M containing maximum abs entry, or -1 if M = 0 - int
1 matrix3_value = RLPy.RMatrix3( 10, 0, 0,
2                                20, 0, 0,
3                               -30, 0, 0 )
4 print(matrix3_value.MaxRow()) # Row:2 ->abs(-30)

OneNorm( self )

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

Returns

Norm of this 3x3 matrix - float
1 matrix3_row_value = RLPy.RMatrix3( 10, 0, 0,
2                                    20, 0, 0,
3                                   -30, 0, 0 )
4 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

InfNorm of this 3x3 matrix - float
1 matrix3_column_value = RLPy.RMatrix3( 10, 20, -30,
2                                        0,  0,   0,
3                                        0,  0,   0 )
4 print(matrix3_column_value.InfNorm()) # 10+20+abs(-30) = 60

FromAxisAngle( self, rkAxis, fAngle )

Rotation matrix from axis angle。

Parameters

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

Returns

A new matrix from specified axis angle - RMatrix3
 1 matrix3_orgin = RLPy.RMatrix3()
 2 matrix3_orgin.MakeIdentity()
 3 
 4 x_axis_vector = RLPy.RVector3( 1, 0, 0 )  # axis = "X"
 5 y_axis_vector = RLPy.RVector3( 0, 1, 0 )  # axis = "Y"
 6 z_axis_vector = RLPy.RVector3( 0, 0, 1 )  # axis = "Z"    
 7 
 8 matrix3_orgin.FromAxisAngle( x_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 9 matrix3_orgin.FromAxisAngle( y_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )
10 matrix3_orgin.FromAxisAngle( z_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )

RotationX( self, fAngle )

Rotate this 3x3 matrix around the x-axis.

Parameters

fAngle [IN] angle in radians - float

Returns

The rotated 3x3 matrix around the x-axis - RMatrix3
1 matrix3_orgin = RLPy.RMatrix3()
2 matrix3_orgin.MakeIdentity()
3 matrix3_orgin.RotationX( 90 * RLPy.RMath.CONST_DEG_TO_RAD )

RotationY( self, fAngle )

Rotate this 3x3 matrix around the y-axis。

Parameters

fAngle [IN] angle in radians - float

Returns

The rotated 3x3 matrix around the y-axis - RMatrix3
1 matrix3_orgin = RLPy.RMatrix3()
2 matrix3_orgin.MakeIdentity()
3 matrix3_orgin.RotationY( 90 * RLPy.RMath.CONST_DEG_TO_RAD )

RotationZ( self, fAngle )

Rotation this 3x3 matrix around the z-axis.

Parameters

fAngle [IN] angle in radians - float

Returns

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

AccuScale( self, rkScale )

Accumulate 3x3 matrix with scale vector.

Parameters

rkScale [IN] Scale vector - RVector3

Returns

A newly scaled matrix - RMatrix3
1 matrix3_orgin = RLPy.RMatrix3()
2 matrix3_orgin.MakeIdentity()
3 scale_vector = RLPy.RVector3( 2, 2, 2 )
4 matrix3_orgin.AccuScale(scale_vector)

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

Convert 3x3 matrix to Euler angles.

Parameters

Order [IN] Euler order - RLPy.Rotation_Order
rx [OUT] Angle of x-axis in radians - float
ry [OUT] Angle of y-axis in radians - float
rz [OUT] Angle of z-axis in radians - float
 1 matrix3_value = RLPy.RMatrix3( -0, -0,  1,
 2                                 0, -1, -0,
 3                                 1,  0, -0 )
 4 euler_angle_x = 0
 5 euler_angle_y = 0
 6 euler_angle_z = 0
 7 result = matrix3_value.ToEulerAngle( RLPy.EEulerOrder_XYZ, euler_angle_x, euler_angle_y, euler_angle_z )
 8 
 9 print(result[0] * RLPy.RMath.CONST_RAD_TO_DEG) # 180
10 print(result[1] * RLPy.RMath.CONST_RAD_TO_DEG) # 90
11 print(result[2] * RLPy.RMath.CONST_RAD_TO_DEG) # 0

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

Convert Euler angle to a 3x3 matrix according to a rotation axis order.

Parameters

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

Returns

A new matrix from specified axis angle - RMatrix3
 1 matrix3_orgin = RLPy.RMatrix3()
 2 euler_angle_x = 90 * RLPy.RMath.CONST_DEG_TO_RAD
 3 euler_angle_y = 0
 4 euler_angle_z = 0
 5 matrix3_result = matrix3_orgin.FromEulerAngle( RLPy.EEulerOrder_XYZ, euler_angle_x, euler_angle_y, euler_angle_z)
 6 row0 = matrix3_result[0].GetRow(0)
 7 
 8 print(row0[0])
 9 print(row0[1])
10 print(row0[2])

FromSphereUnitVec( self, rkVec )

Convert Euler angle to matrix.

Parameters

rkVec [IN] vector - RVector3

Returns

A new 3x3 matrix from sphere unit vector - RMatrix3
1 vector = RLPy.RVector3( 0, 1, 0 )
2 matrix3_result =  RLPy.RMatrix3().FromSphereUnitVec( vector )
3 row0 = matrix3_result.GetRow(0)
4 
5 print(row0[0])
6 print(row0[1])
7 print(row0[2])

IsRightHandCoordinate( self )

Obtain this 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
1 matrix3_value = RLPy.RMatrix3( 1, 0, 0,
2                                0, 1, 0,
3                                0, 0, 1 )
4 result = matrix3_value.IsRightHandCoordinate()
5 
6 print(result)