Difference between revisions of "IC Python API:RLPy RMatrix4"
Chuck (RL) (Talk | contribs) m |
Chuck (RL) (Talk | contribs) m |
||
Line 5: | Line 5: | ||
== Description == | == Description == | ||
− | This class represent | + | 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] | ||
== Operators == | == Operators == | ||
Line 13: | Line 17: | ||
The "addition" operator. | The "addition" operator. | ||
− | + | See Also: [[#+=|+=]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | <syntaxhighlight lang="python"> | |
− | print( | + | matrix3_a = RLPy.RMatrix3( 1, 2, 3, |
− | print( | + | 0, 0, 0, |
− | print( | + | 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> | ||
Line 34: | Line 37: | ||
The "subtraction" operator. | The "subtraction" operator. | ||
− | + | See Also: [[#-=|-=]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | <syntaxhighlight lang="python"> | |
− | print( | + | matrix3_a = RLPy.RMatrix3( 1, 2, 3, |
− | print( | + | 0, 0, 0, |
− | print( | + | 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> | ||
=== * === | === * === | ||
− | The "multiplication" operator. | + | The "multiplication" operator. |
− | + | See Also: [[#*=|*=]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | print( | + | <syntaxhighlight lang="python"> |
+ | 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> | ||
Line 73: | Line 74: | ||
The "division" operator. | The "division" operator. | ||
− | <syntaxhighlight lang=" | + | See Also: [[#/=|/=]] |
− | + | ||
− | + | <syntaxhighlight lang="python"> | |
− | + | matrix3_a = RLPy.RMatrix3( 1, 2, 3, | |
− | + | 0, 0, 0, | |
− | + | 0, 0, 0 ) | |
+ | matrix3_result = matrix3_a / 2 | ||
− | print( | + | print( matrix3_result.GetRow(0)[0] == 1/2 ) # true |
− | print( | + | print( matrix3_result.GetRow(0)[1] == 2/2 ) # true |
− | print( | + | print( matrix3_result.GetRow(0)[2] == 3/2 ) # true |
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== - === | === - === | ||
− | The "unary minus" . | + | The "unary minus" operator. |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
− | + | matrix3_a = RLPy.RMatrix3( 1, 2, 3, | |
− | + | 0, 0, 0, | |
− | + | 0, 0, 0 ) | |
− | + | matrix3_result = -matrix3_a | |
− | + | ||
− | print( | + | print( matrix3_result.GetRow(0)[0] == -1 ) # true |
− | print( | + | print( matrix3_result.GetRow(0)[1] == -2 ) # true |
− | print( | + | print( matrix3_result.GetRow(0)[2] == -3 ) # true |
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 107: | Line 106: | ||
The "equal to" operator. Performs a one-by-one comparison of the matrix array. | The "equal to" operator. Performs a one-by-one comparison of the matrix array. | ||
− | + | See Also: [[#!=|!=]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | print( | + | <syntaxhighlight lang="python"> |
+ | 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> | ||
Line 124: | Line 122: | ||
The "not equal to" operator. Performs a one-by-one comparison of the matrix array. | The "not equal to" operator. Performs a one-by-one comparison of the matrix array. | ||
− | + | See Also: [[#==|==]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | print( | + | <syntaxhighlight lang="python"> |
+ | 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> | ||
=== > === | === > === | ||
− | The "greater than" operator. | + | The "greater than" operator. Performs a one-by-one comparison of the matrix array. |
− | + | See Also: [[#>=|>=]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | print( | + | <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> | </syntaxhighlight> | ||
Line 158: | Line 154: | ||
The "greater than or equal to" operator. Performs a one-by-one comparison of the matrix array. | The "greater than or equal to" operator. Performs a one-by-one comparison of the matrix array. | ||
− | + | See Also: [[#>|>]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | print( | + | <syntaxhighlight lang="python"> |
+ | 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> | ||
Line 175: | Line 170: | ||
The "less than" operator. Performs a one-by-one comparison of the matrix array. | The "less than" operator. Performs a one-by-one comparison of the matrix array. | ||
− | < | + | See Also: [[#<=|<=]] |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | print( | + | <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_a< matrix3_b ) # true | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 192: | Line 186: | ||
The "less than" operator. Performs a one-by-one comparison of the matrix array. | The "less than" operator. Performs a one-by-one comparison of the matrix array. | ||
− | < | + | See Also: [[#<|<]] |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | print( | + | <syntaxhighlight lang="python"> |
+ | 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> | ||
Line 209: | Line 202: | ||
The "addition assignment" operator. | The "addition assignment" operator. | ||
− | + | See Also: [[#+|+]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | <syntaxhighlight lang="python"> | |
− | print( | + | matrix3 = RLPy.RMatrix3( 1, 2, 3, |
− | print( | + | 0, 0, 0, |
− | print( | + | 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> | ||
Line 229: | Line 221: | ||
The "subtraction assignment" operator. | The "subtraction assignment" operator. | ||
− | + | See Also: [[#-|-]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | <syntaxhighlight lang="python"> | |
− | print( | + | matrix3 = RLPy.RMatrix3( 1, 2, 3, |
− | print( | + | 0, 0, 0, |
− | print( | + | 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> | ||
=== *= === | === *= === | ||
− | The "multiplication assignment" | + | The "multiplication assignment" operator. |
− | + | See Also: [[#*|*]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | <syntaxhighlight lang="python"> | |
− | print( | + | matrix3 = RLPy.RMatrix3( 1, 2, 3, |
− | print( | + | 0, 0, 0, |
− | print( | + | 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> | ||
=== /= === | === /= === | ||
− | The "division assignment" | + | The "division assignment" operator. |
− | + | See Also: [[#/|/]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | <syntaxhighlight lang="python"> | |
− | print( | + | matrix3 = RLPy.RMatrix3( 1, 2, 3, |
− | print( | + | 0, 0, 0, |
− | print( | + | 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> | ||
== Member Functions == | == Member Functions == | ||
− | === MakeIdentity (self) === | + | === MakeIdentity ( self ) === |
This function can be used to initialize the 3x3 matrix. It is equivalent to setting the matrix to: | 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 ==== | ==== Returns ==== | ||
− | |||
− | <syntaxhighlight lang=" | + | This object - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | + | ||
− | + | <syntaxhighlight lang="python"> | |
+ | matrix3 = RLPy.RMatrix3() | ||
+ | matrix3.MakeIdentity() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === M (self, args) === | + | === M ( self, args ) === |
− | Get the value of an element in a | + | Get the value of an element in a 3x3 matrix by row and column index. |
==== Parameters ==== | ==== Parameters ==== | ||
− | :'''nRow'''[IN] Index of the row in the matrix - int'''nCol'''[IN] Index of the column in the matrix - int | + | :'''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 | + | :The matrix element specified by row and column - float |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
− | + | matrix3 = RLPy.RMatrix3() | |
− | + | matrix3.MakeIdentity() | |
− | print( | + | print(matrix3.M(0,0)) # <Swig Object of type 'float *' at 0x0000020316B015A0> |
</syntaxhighlight> | </syntaxhighlight> | ||
− | === E (self, args) === | + | === E ( self, args ) === |
− | Get the value of an element in a 3x3 matrix by index number (from 0 to | + | Get the value of an element in a 3x3 matrix by index number (from 0 to 8); |
==== Parameters ==== | ==== Parameters ==== | ||
− | :'''nRow'''[IN] Index of the matrix. | + | :'''nRow''' [IN] Index of the matrix. |
==== Returns ==== | ==== Returns ==== | ||
:The matrix element specified by index - float | :The matrix element specified by index - float | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
− | + | matrix3 = RLPy.RMatrix3() | |
− | + | matrix3.MakeIdentity() | |
− | print( | + | print(matrix3.E(0)) # |
</syntaxhighlight> | </syntaxhighlight> | ||
− | === GetRow (self, | + | === GetRow ( self, nRow ) === |
− | Retreive a row inside a | + | Retreive a row inside a 3x3 matrix. |
==== Parameters ==== | ==== Parameters ==== | ||
− | :'''nRow'''[IN] Index of the row in the matrix | + | :'''nRow''' [IN] Index of the row in the matrix - int |
==== Returns ==== | ==== Returns ==== | ||
− | :The row vector of the matrix - | + | :The row vector of the matrix - [[IC_Python_API:RLPy_RVector3|RVector3]] |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
− | + | matrix3 = RLPy.RMatrix3() | |
− | + | matrix3.MakeIdentity() | |
− | row0 = | + | row0 = matrix3.GetRow(0) |
print(row0[0]) | print(row0[0]) | ||
print(row0[1]) | print(row0[1]) | ||
print(row0[2]) | print(row0[2]) | ||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === GetColumn (self, | + | === GetColumn( self, nCol ) === |
− | + | Retreive a column inside a 3x3 matrix. | |
==== Parameters ==== | ==== Parameters ==== | ||
− | :''' | + | :'''nCol''' [IN] Index of the row in the matrix - int |
==== Returns ==== | ==== Returns ==== | ||
− | :The column vector of the matrix - | + | :The column vector of the matrix - [[IC_Python_API:RLPy_RVector3|RVector3]] |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
− | + | matrix3 = RLPy.RMatrix3() | |
− | + | matrix3.MakeIdentity() | |
− | col0 = | + | col0 = matrix3.GetColumn(0) |
print(col0[0]) | print(col0[0]) | ||
print(col0[1]) | print(col0[1]) | ||
print(col0[2]) | print(col0[2]) | ||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === Transpose (self) === | + | === Transpose( self ) === |
Obtain the transposed matrix by transposing the current m * n matrix into an n * m matrix by row-column swapping. | 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 - | + | :A new matrix containing this matrix's transpose - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
− | + | matrix3_orgin = RLPy.RMatrix3( 1, 2, 3, | |
− | + | 4, 5, 6, | |
− | + | 7, 8, 9 ) | |
− | + | matrix3_transpose = matrix3_orgin.Transpose() | |
− | + | row0 = matrix3_orgin.GetRow(0) | |
− | row0 = | + | col0 = matrix3_transpose.GetColumn(0) |
− | col0 = | + | |
print(row0[0] == col0[0]) | print(row0[0] == col0[0]) | ||
print(row0[1] == col0[1]) | print(row0[1] == col0[1]) | ||
print(row0[2] == col0[2]) | print(row0[2] == col0[2]) | ||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === TransposeTimes (self, mM) === | + | === TransposeTimes( self, mM ) === |
− | Multiply a transposed version of a | + | Multiply a transposed version of a 3x3 matrix with itself. |
==== Parameters ==== | ==== Parameters ==== | ||
− | :'''mM'''[IN] the matrix - | + | :'''mM''' [IN] the matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
==== Returns ==== | ==== Returns ==== | ||
− | :A new matrix. (this^T * mM) - | + | :A new matrix. (this^T * mM) - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <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, 2 | + | 0, 0, 2 ) |
− | + | matrix3_transpose_times = matrix3_orgin.TransposeTimes(matrix3_transpose_value) | |
− | + | row0 = matrix3_orgin.GetRow(0) | |
− | + | col0 = matrix3_transpose_times.GetColumn(0) | |
− | row0 = | + | |
− | col0 = | + | |
print(row0[0]*2 == col0[0]) | print(row0[0]*2 == col0[0]) | ||
print(row0[1]*2 == col0[1]) | print(row0[1]*2 == col0[1]) | ||
print(row0[2]*2 == col0[2]) | print(row0[2]*2 == col0[2]) | ||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === TimesTranspose (self, mM) === | + | === TimesTranspose( self, mM ) === |
− | Multiply this | + | Multiply this 3x3 matrix with a transposed version of itself. |
==== Parameters ==== | ==== Parameters ==== | ||
− | :'''mM'''[IN] the matrix - | + | :'''mM''' [IN] the matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
==== Returns ==== | ==== Returns ==== | ||
− | :A new matrix. (this * M^T) - | + | :A new matrix. (this * M^T) - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <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, 3 | + | 0, 0, 3 ) |
− | + | matrix3_times_transpose = matrix3_orgin.TimesTranspose(matrix3_transpose_value) | |
− | + | row0 = matrix3_orgin.GetColumn(0) | |
− | + | col0 = matrix3_times_transpose.GetColumn(0) | |
− | row0 = | + | |
− | col0 = | + | |
print(row0[0]*3 == col0[0]) | print(row0[0]*3 == col0[0]) | ||
print(row0[1]*3 == col0[1]) | print(row0[1]*3 == col0[1]) | ||
print(row0[2]*3 == col0[2]) | print(row0[2]*3 == col0[2]) | ||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === Inverse (self) === | + | === Inverse( self ) === |
− | Obtain the inverse (reciprocal) of this | + | Obtain the inverse (reciprocal) of this 3x3 matrix (A^-1). |
==== Returns ==== | ==== Returns ==== | ||
− | :A new matrix containing this matrix's inverse - | + | :A new matrix containing this matrix's inverse - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <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( | + | print(row0[0]) |
− | print( | + | print(row0[1]) |
− | print( | + | print(row0[2]) |
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === Adjoint (self) === | + | === Adjoint( self ) === |
− | Adjugate this | + | Adjugate this 3x3 matrix. |
==== Returns ==== | ==== Returns ==== | ||
− | :A new matrix containing this matrix's adjoint - | + | :A new matrix containing this matrix's adjoint - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <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( | + | print(row0[0]) |
− | print( | + | print(row0[1]) |
− | print( | + | print(row0[2]) |
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === AdjointTranspose (self) === | + | === AdjointTranspose( self ) === |
− | Adjugate and transpose this | + | Adjugate and transpose this 3x3 matrix. |
==== Returns ==== | ==== Returns ==== | ||
− | :A new matrix - | + | :A new adjugated and transposed matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <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) | |
− | col0_Adjoint_transpose = | + | |
− | print(col0_Adjoint_transpose | + | print(col0_Adjoint_transpose[0]) |
− | print(col0_Adjoint_transpose | + | print(col0_Adjoint_transpose[1]) |
− | print(col0_Adjoint_transpose[2 | + | print(col0_Adjoint_transpose[2]) |
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === InverseTranspose (self) === | + | === InverseTranspose( self ) === |
− | Invert and transpose this | + | Invert and transpose this 3x3 matrix. |
==== Returns ==== | ==== Returns ==== | ||
− | :A new matrix - | + | :A new inverted and transposed matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <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( | + | print(row0_inverse_transpose[0]) |
− | print( | + | print(row0_inverse_transpose[1]) |
− | print( | + | print(row0_inverse_transpose[2]) |
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === Determinant (self) === | + | === Determinant( self ) === |
− | Obtain the scalar value for this | + | Obtain the scalar value for this 3x3 matrix (|A|). |
==== Returns ==== | ==== Returns ==== | ||
:The determinant of the matrix - float | :The determinant of the matrix - float | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
− | + | matrix3_value = RLPy.RMatrix3( 1, 2, 3, | |
− | + | 2, 3, 4, | |
− | + | 4, 2, 1 ) | |
− | + | ||
− | print( | + | print(matrix3_value.Determinant()) |
</syntaxhighlight> | </syntaxhighlight> | ||
− | === MaxColumn (self) === | + | === MaxColumn( self ) === |
− | Find the maximum absolute value within this | + | 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 ==== | ==== Returns ==== | ||
− | : | + | :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) | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | print( | + | |
</syntaxhighlight> | </syntaxhighlight> | ||
− | === MaxRow (self) === | + | === MaxRow( self ) === |
− | Find the maximum absolute value within this | + | 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 ==== | ==== Returns ==== | ||
− | : | + | :Index of row of M containing maximum abs entry, or -1 if M = 0 - int |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
− | + | matrix3_value = RLPy.RMatrix3( 10, 0, 0, | |
− | + | 20, 0, 0, | |
− | + | -30, 0, 0 ) | |
− | + | print(matrix3_value.MaxRow()) # Row:2 ->abs(-30) | |
− | print( | + | |
</syntaxhighlight> | </syntaxhighlight> | ||
− | === OneNorm (self) === | + | === OneNorm( self ) === |
Return the sum of the column elements that contain the largest absolute values. | Return the sum of the column elements that contain the largest absolute values. | ||
==== Returns ==== | ==== Returns ==== | ||
− | : | + | :Norm of this 3x3 matrix - float |
− | <syntaxhighlight lang=" | + | <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 |
− | print( | + | |
</syntaxhighlight> | </syntaxhighlight> | ||
− | === InfNorm (self) === | + | === InfNorm( self ) === |
Return the sum of the row elements that contain the largest absolute values. | Return the sum of the row elements that contain the largest absolute values. | ||
==== Returns ==== | ==== Returns ==== | ||
− | : | + | :InfNorm of this 3x3 matrix - float |
− | <syntaxhighlight lang=" | + | <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 | |
− | print( | + | |
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | === FromAxisAngle( self, rkAxis, fAngle ) === |
− | + | Rotation matrix from axis angle。 | |
==== Parameters ==== | ==== Parameters ==== | ||
− | :''' | + | :'''rkAxis''' [IN] axis vector - [[IC_Python_API:RLPy_RVector3|RVector3]] |
− | : | + | :'''fAngle''' [IN] angle in radians - float |
− | :''' | + | |
==== Returns ==== | ==== Returns ==== | ||
− | : | + | :A new matrix from specified axis angle - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <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> | </syntaxhighlight> | ||
− | === | + | === RotationX( self, fAngle ) === |
− | + | Rotate this 3x3 matrix around the x-axis. | |
==== Parameters ==== | ==== Parameters ==== | ||
− | + | fAngle [IN] angle in radians - float | |
==== Returns ==== | ==== Returns ==== | ||
− | : | + | :The rotated 3x3 matrix around the x-axis - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
− | + | matrix3_orgin = RLPy.RMatrix3() | |
− | + | matrix3_orgin.MakeIdentity() | |
− | + | matrix3_orgin.RotationX( 90 * RLPy.RMath.CONST_DEG_TO_RAD ) | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | === RotationY( self, fAngle ) === |
− | + | Rotate this 3x3 matrix around the y-axis。 | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
==== Parameters ==== | ==== Parameters ==== | ||
− | :'''fAngle'''[IN] angle in radians - float | + | :'''fAngle''' [IN] angle in radians - float |
==== Returns ==== | ==== Returns ==== | ||
− | : | + | :The rotated 3x3 matrix around the y-axis - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
− | + | matrix3_orgin = RLPy.RMatrix3() | |
− | + | matrix3_orgin.MakeIdentity() | |
− | + | matrix3_orgin.RotationY( 90 * RLPy.RMath.CONST_DEG_TO_RAD ) | |
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | === RotationZ( self, fAngle ) === |
− | Rotation matrix | + | Rotation this 3x3 matrix around the z-axis. |
==== Parameters ==== | ==== Parameters ==== | ||
− | :'''fAngle'''[IN] angle in radians - float | + | :'''fAngle''' [IN] angle in radians - float |
==== Returns ==== | ==== Returns ==== | ||
− | : | + | :A new 3x3 matrix of for rotations around z-axis - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
− | + | matrix3_orgin = RLPy.RMatrix3() | |
− | + | matrix3_orgin.MakeIdentity() | |
− | + | matrix3_orgin.RotationZ( 90 * RLPy.RMath.CONST_DEG_TO_RAD ) | |
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | === AccuScale( self, rkScale ) === |
− | + | Accumulate 3x3 matrix with scale vector. | |
==== Parameters ==== | ==== Parameters ==== | ||
− | + | rkScale [IN] Scale vector - [[IC_Python_API:RLPy_RVector3|RVector3]] | |
==== Returns ==== | ==== Returns ==== | ||
− | : | + | :A newly scaled matrix - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
− | + | matrix3_orgin = RLPy.RMatrix3() | |
− | + | matrix3_orgin.MakeIdentity() | |
− | + | scale_vector = RLPy.RVector3( 2, 2, 2 ) | |
+ | matrix3_orgin.AccuScale(scale_vector) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | === ToEulerAngle( self, rkScaleself, Order, rx, ry, rz ) === |
− | + | Convert 3x3 matrix to Euler angles. | |
==== Parameters ==== | ==== 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"> |
− | + | 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> | ||
− | === FromEulerAngle (self, | + | === FromEulerAngle( self, Order, rx, ry, rz ) === |
− | Convert Euler angle to a | + | Convert Euler angle to a 3x3 matrix according to a rotation axis order. |
==== Parameters ==== | ==== 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 ==== | ==== Returns ==== | ||
− | : | + | :A new matrix from specified axis angle - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
+ | matrix3_orgin = RLPy.RMatrix3() | ||
euler_angle_x = 90 * RLPy.RMath.CONST_DEG_TO_RAD | euler_angle_x = 90 * RLPy.RMath.CONST_DEG_TO_RAD | ||
euler_angle_y = 0 | euler_angle_y = 0 | ||
euler_angle_z = 0 | euler_angle_z = 0 | ||
− | + | matrix3_result = matrix3_orgin.FromEulerAngle( RLPy.EEulerOrder_XYZ, euler_angle_x, euler_angle_y, euler_angle_z) | |
− | row0 = | + | row0 = matrix3_result[0].GetRow(0) |
print(row0[0]) | print(row0[0]) | ||
print(row0[1]) | print(row0[1]) | ||
print(row0[2]) | print(row0[2]) | ||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | === FromSphereUnitVec( self, rkVec ) === |
− | + | Convert Euler angle to matrix. | |
==== Parameters ==== | ==== Parameters ==== | ||
− | :''' | + | :'''rkVec''' [IN] vector - [[IC_Python_API:RLPy_RVector3|RVector3]] |
==== Returns ==== | ==== Returns ==== | ||
− | : | + | :A new 3x3 matrix from sphere unit vector - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] |
− | <syntaxhighlight lang=" | + | <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[0]) | ||
print(row0[1]) | print(row0[1]) | ||
Line 849: | Line 743: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | === IsRightHandCoordinate( self ) === |
− | + | Obtain this 3x3 matrix's coordinate system. '''True''' stands for right-handed coordinate system while '''False''' for left-handed. | |
− | + | ||
− | + | ||
− | + | ||
==== Returns ==== | ==== Returns ==== | ||
− | : | + | :'''True''' Right hand coordinate - bool |
+ | :'''False''' Left hand coordinate - bool | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python"> |
− | + | matrix3_value = RLPy.RMatrix3( 1, 0, 0, | |
− | + | 0, 1, 0, | |
− | + | 0, 0, 1 ) | |
− | + | result = matrix3_value.IsRightHandCoordinate() | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | = | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | print(result) | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | print( | + | |
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 18:38, 7 April 2020
Contents
- 1 Description
- 2 Operators
- 3 Member Functions
- 3.1 MakeIdentity ( self )
- 3.2 M ( self, args )
- 3.3 E ( self, args )
- 3.4 GetRow ( self, nRow )
- 3.5 GetColumn( self, nCol )
- 3.6 Transpose( self )
- 3.7 TransposeTimes( self, mM )
- 3.8 TimesTranspose( self, mM )
- 3.9 Inverse( self )
- 3.10 Adjoint( self )
- 3.11 AdjointTranspose( self )
- 3.12 InverseTranspose( self )
- 3.13 Determinant( self )
- 3.14 MaxColumn( self )
- 3.15 MaxRow( self )
- 3.16 OneNorm( self )
- 3.17 InfNorm( self )
- 3.18 FromAxisAngle( self, rkAxis, fAngle )
- 3.19 RotationX( self, fAngle )
- 3.20 RotationY( self, fAngle )
- 3.21 RotationZ( self, fAngle )
- 3.22 AccuScale( self, rkScale )
- 3.23 ToEulerAngle( self, rkScaleself, Order, rx, ry, rz )
- 3.24 FromEulerAngle( self, Order, rx, ry, rz )
- 3.25 FromSphereUnitVec( self, rkVec )
- 3.26 IsRightHandCoordinate( self )
- Main article: Modules.
- Last modified: 04/7/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]
Operators
+
The "addition" operator.
See Also: +=
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.
See Also: -=
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.
See Also: *=
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.
See Also: /=
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" operator.
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.
See Also: !=
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.
See Also: ==
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.
See Also: >=
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.
See Also: >
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.
See Also: <=
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.
See Also: <
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.
See Also: +
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.
See Also: -
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.
See Also: *
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.
See Also: /
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 1 0] [0 0 1]
Returns
This object - 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
- The matrix element specified by row and column - 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
- The matrix element specified by index - float
matrix3 = RLPy.RMatrix3()
matrix3.MakeIdentity()
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
matrix3 = RLPy.RMatrix3()
matrix3.MakeIdentity()
row0 = matrix3.GetRow(0)
print(row0[0])
print(row0[1])
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
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
- A new matrix containing this matrix's transpose - 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 - RMatrix3
Returns
- A new matrix. (this^T * mM) - 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 this 3x3 matrix with a transposed version of itself.
Parameters
- mM [IN] the matrix - RMatrix3
Returns
- A new matrix. (this * M^T) - 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 )
Obtain the inverse (reciprocal) of this 3x3 matrix (A^-1).
Returns
- A new matrix containing this matrix's inverse - 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 this 3x3 matrix.
Returns
- A new matrix containing this matrix's adjoint - RMatrix3
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])
AdjointTranspose( self )
Adjugate and transpose this 3x3 matrix.
Returns
- A new adjugated and transposed matrix - 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 this 3x3 matrix.
Returns
- A new inverted and transposed matrix - 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 this 3x3 matrix (|A|).
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 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
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 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
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
- Norm of this 3x3 matrix - 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
- InfNorm of this 3x3 matrix - 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 - RVector3
- fAngle [IN] angle in radians - float
Returns
- A new matrix from specified axis angle - 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 )
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
matrix3_orgin = RLPy.RMatrix3()
matrix3_orgin.MakeIdentity()
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
matrix3_orgin = RLPy.RMatrix3()
matrix3_orgin.MakeIdentity()
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
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 - RVector3
Returns
- A newly scaled matrix - 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 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
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 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
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 - RVector3
Returns
- A new 3x3 matrix from sphere unit vector - 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 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
matrix3_value = RLPy.RMatrix3( 1, 0, 0,
0, 1, 0,
0, 0, 1 )
result = matrix3_value.IsRightHandCoordinate()
print(result)