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

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 4x4 matrix. ==Operators== This class supports the following operat...")
 
m
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
==Detailed Description==
+
{{last_modified}}
This class represent the 4x4 matrix.
+
 
==Operators==
+
== Description ==
This class supports the following operators:
+
 
{| class="wikitable"
+
This class represent the transform data of RTransform. This class provides access to RLPy's internal 4x4 matrix operators and related functions.
!Member
+
 
!Operation
+
== Operators ==
!Syntax
+
 
!Description
+
=== + ===
!Example
+
 
|-
+
The "addition" operator.
! scope="row"|__add__
+
 
|Addition
+
|a + b
+
|Adds values on either side of the operator.
+
|a + b = 30
+
|-
+
! scope="row"|__sub__
+
|Subtraction
+
|a - b
+
|Subtracts right hand operand from left hand operand.
+
|a – b = -10
+
|-
+
! scope="row"|__mul__
+
|Multiplication
+
|a * b
+
|Multiplies values on either side of the operator.
+
|a * b = 200
+
|-
+
! scope="row"|__truediv__
+
|Division
+
|a / b
+
|Divides left hand operand by right hand operand.
+
|b / a = 2
+
|-
+
! scope="row"|__neg__
+
|Negation
+
| -a
+
|Return the value negated.
+
| a = -b
+
|-
+
! scope="row"|__eq__
+
|Equality
+
|a == b
+
|If the values of two operands are equal, then the condition becomes true.
+
|(a == b) is not true.
+
|-
+
! scope="row"|__ne__
+
|Difference
+
|a != b
+
|If values of two operands are not equal, then condition becomes true.
+
|(a != b) is true.
+
|-
+
! scope="row"|__gt__
+
|Greater Than
+
|a > b
+
|If the value of left operand is greater than the value of right operand, then condition becomes true.
+
|(a > b) is not true.
+
|-
+
! scope="row"|__lt__
+
|Less Than
+
|a < b
+
|If the value of left operand is less than the value of right operand, then condition becomes true.
+
|(a < b) is true.
+
|-
+
! scope="row"|__ge__
+
|Greater Than or Equal
+
|a >= b
+
|If the value of left operand is greater than or equal to the value of right operand, then condition becomes true.
+
|(a >= b) is not true.
+
|-
+
! scope="row"|__le__
+
|Less or Equal
+
|a <= b
+
|If the value of left operand is less than or equal to the value of right operand, then condition becomes true.
+
|(a <= b) is true.
+
|-
+
! scope="row"|__iadd__
+
|Addition (Inplace)
+
|a += b
+
|It adds right operand to the left operand and assign the result to left operand.
+
|c += a is equivalent to c = c + a
+
|-
+
! scope="row"|__isub__
+
|Subtraction (Inplace)
+
|a -= b
+
|It subtracts right operand from the left operand and assign the result to left operand.
+
|c -= a is equivalent to c = c - a
+
|-
+
! scope="row"|__imul__
+
|Multiply (Inplace)
+
|a *= b
+
|It multiplies right operand with the left operand and assign the result to left operand.
+
|c *= a is equivalent to c = c * a
+
|-
+
! scope="row"|__itruediv__
+
|Divide (Inplace)
+
|a /= b
+
|It divides left operand with the right operand and assign the result to left operand.
+
|c /= a is equivalent to c = c / ac /= a is equivalent to c = c / a
+
|}
+
==Member Functions==
+
===AccuRotate===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.AccuRotate ( self, rkRotate )
+
matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4_b = RLPy.RMatrix4( 2, 2, 2, 2,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4_result = matrix4_a + matrix4_b
 +
 
 +
print( matrix4_result.GetRow(0)[0] == 1+2 ) # true
 +
print( matrix4_result.GetRow(0)[1] == 2+2 ) # true
 +
print( matrix4_result.GetRow(0)[2] == 3+2 ) # true
 +
print( matrix4_result.GetRow(0)[3] == 4+2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Accumulate matrix with rotation matrix.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''rkRotate''' [IN] Rotation matrix - RLPy.RMatrix3
+
=== - ===
</div>
+
 
====Returns====
+
The "subtraction" operator.
<div style="margin-left: 2em;">Return a new matrix (*this) *= Accumulate - RLPy.RMatrix4
+
 
</div>
+
-----
+
===AccuScale===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.AccuScale ( self, rkScale )
+
matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4_b = RLPy.RMatrix4( 2, 2, 2, 2,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4_result = matrix4_a - matrix4_b
 +
 
 +
print( matrix4_result.GetRow(0)[0] == 1-2 ) # true
 +
print( matrix4_result.GetRow(0)[1] == 2-2 ) # true
 +
print( matrix4_result.GetRow(0)[2] == 3-2 ) # true
 +
print( matrix4_result.GetRow(0)[3] == 4-2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Accumulate matrix with scale vector.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''rkScale''' [IN] Scale vector - RLPy.RVector3
+
=== * ===
</div>
+
 
====Returns====
+
The "multiplication" operator.  
<div style="margin-left: 2em;">Return a new matrix (*this) *= Accumulate - RLPy.RMatrix4
+
 
</div>
+
-----
+
===AccuTranslate===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.AccuTranslate ( self, rkTranslate )
+
matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4_b = RLPy.RMatrix4( 2, 0, 0, 0,
 +
                          2, 0, 0, 0,
 +
                          2, 0, 0, 0,
 +
                          2, 0, 0, 0 )
 +
matrix4_result = matrix4_a * matrix4_b
 +
 
 +
print( matrix4_result.GetRow(0)[0] == 1*2 + 2*2 + 3*2 + 4*2  ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Accumulate matrix with translate vector.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''rkTranslate''' [IN] Translate vector - RLPy.RVector3
+
=== / ===
</div>
+
 
====Returns====
+
The "division" operator.  
<div style="margin-left: 2em;">Return a new matrix (*this) *= Accumulate - RLPy.RMatrix4
+
 
</div>
+
-----
+
===Adjoint===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.Adjoint ( self )
+
matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4_result = matrix4_a / 2
 +
 
 +
print( matrix4_result.GetRow(0)[0] == 1/2 ) # true
 +
print( matrix4_result.GetRow(0)[1] == 2/2 ) # true
 +
print( matrix4_result.GetRow(0)[2] == 3/2 ) # true
 +
print( matrix4_result.GetRow(0)[3] == 4/2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Inverse times determinant.
+
 
====Returns====
+
=== - ===
<div style="margin-left: 2em;">A new matrix containing this matrix's adjoint - RLPy.RMatrix4
+
 
</div>
+
The "unary minus" .
-----
+
 
===AdjointTranspose===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.AdjointTranspose ( self )
+
matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4_result = -matrix4_a
 +
 
 +
print( matrix4_result.GetRow(0)[0] == -1 ) # true
 +
print( matrix4_result.GetRow(0)[1] == -2 ) # true
 +
print( matrix4_result.GetRow(0)[2] == -3 ) # true
 +
print( matrix4_result.GetRow(0)[3] == -4 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Transpose of inverse times determinant.
+
 
====Returns====
+
=== == ===
<div style="margin-left: 2em;">A new matrix - RLPy.RMatrix4
+
 
</div>
+
The "equal to" operator. Performs a one-by-one comparison of the matrix array.
-----
+
 
===Determinant===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.Determinant ( self )
+
matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4_b = RLPy.RMatrix4( 1, 2, 3, 4,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
 
 +
print( matrix4_a == matrix4_b ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
The matrix's determinant.
+
 
====Returns====
+
=== != ===
<div style="margin-left: 2em;">The determinant of the matrix - float
+
 
</div>
+
The "not equal to" operator. Performs a one-by-one comparison of the matrix array.
-----
+
 
===E===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.E ( self, args )
+
matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4_b = RLPy.RMatrix4( 2, 2, 2, 2,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
 
 +
print( matrix4_a != matrix4_b ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the matrix element for the specified index(0~15).
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''nRow''' [IN] Index of the matrix.
+
=== > ===
</div>
+
 
====Returns====
+
The "greater than" operator.  Performs a one-by-one comparison of the matrix array.
<div style="margin-left: 2em;">The matrix element specified by index - float
+
 
</div>
+
-----
+
===FromEulerAngle===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.FromEulerAngle ( self, Oreder, rx, ry, rz )
+
matrix4_a = RLPy.RMatrix4( 1, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4_b = RLPy.RMatrix4( 2, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
 
 +
print( matrix4_b > matrix4_a ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Rotation matrix from Euler angle.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''Oreder''' [IN] Euler order - RLPy.Rotation_Order
+
=== >= ===
  
'''rx''' [IN] Angle of x-axis in radians - float
+
The "greater than or equal to" operator. Performs a one-by-one comparison of the matrix array.
  
'''ry''' [IN] Angle of y-axis in radians - float
+
<syntaxhighlight lang="Python">
 +
matrix4_a = RLPy.RMatrix4( 1, 1, 1, 4,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4_b = RLPy.RMatrix4( 1, 1, 1, 8,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
 
 +
print( matrix4_b >= matrix4_a ) # true
 +
</syntaxhighlight>
 +
 
 +
=== < ===
 +
 
 +
The "less than" operator. Performs a one-by-one comparison of the matrix array.
  
'''rz''' [IN] Angle of z-axis in radians - float
 
</div>
 
====Returns====
 
<div style="margin-left: 2em;">Return a new matrix from specified axis angle - RLPy.RMatrix4
 
</div>
 
-----
 
===GetColumn===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.GetColumn ( self, nC )
+
matrix4_a = RLPy.RMatrix4( 2, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4_b = RLPy.RMatrix4( 3, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
 
 +
print( matrix4_a < matrix4_b ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the matrix element for the specified column.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''nRow''' [IN] Index of the column in the matrix.
+
=== <= ===
</div>
+
 
====Returns====
+
The "less than" operator. Performs a one-by-one comparison of the matrix array.
<div style="margin-left: 2em;">The column vector of the matrix - RLPy.RVector4
+
 
</div>
+
-----
+
===GetRow===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.GetRow ( self, nR )
+
matrix4_a = RLPy.RMatrix4( 2, 2, 1, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4_b = RLPy.RMatrix4( 2, 2, 5, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
 
 +
print( matrix4_a <= matrix4_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.
+
=== += ===
</div>
+
 
====Returns====
+
The "addition assignment" operator.
<div style="margin-left: 2em;">The row vector of the matrix - RLPy.RVector4
+
 
</div>
+
-----
+
===GetSR===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.GetSR ( self )
+
matrix4 =  RLPy.RMatrix4( 1, 2, 3, 4,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4 += RLPy.RMatrix4( 2, 2, 2, 2,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
 
 +
print( matrix4.GetRow(0)[0] == 1+2 ) # true
 +
print( matrix4.GetRow(0)[1] == 2+2 ) # true
 +
print( matrix4.GetRow(0)[2] == 3+2 ) # true
 +
print( matrix4.GetRow(0)[3] == 4+2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Get scale and rotation part of the matrix.
+
 
====Returns====
+
=== -= ===
<div style="margin-left: 2em;">Return a 3x3 matrix - RLPy.RMatrix3
+
 
</div>
+
The "subtraction assignment" operator.
-----
+
 
===GetTranslate===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.GetTranslate ( self )
+
matrix4 =  RLPy.RMatrix4( 1, 2, 3, 4,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
matrix4 -= RLPy.RMatrix4( 2, 2, 2, 2,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0,
 +
                          0, 0, 0, 0 )
 +
 
 +
print( matrix4.GetRow(0)[0] == 1-2 ) # true
 +
print( matrix4.GetRow(0)[1] == 2-2 ) # true
 +
print( matrix4.GetRow(0)[2] == 3-2 ) # true
 +
print( matrix4.GetRow(0)[3] == 4-2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Get translate of the matrix.
+
 
====Returns====
+
=== *= ===
<div style="margin-left: 2em;">Return a translate vector - RLPy.RVector3
+
 
</div>
+
The "multiplication assignment" operator. For the calculation method, refer to the '''*''' operator.
-----
+
 
===InfNorm===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.InfNorm ( self )
+
matrix4 = RLPy.RMatrix4( 1, 2, 3, 4,
 +
                        0, 0, 0, 0,
 +
                        0, 0, 0, 0,
 +
                        0, 0, 0, 0 )
 +
matrix4 *= 2
 +
 
 +
print( matrix4.GetRow(0)[0] == 1*2 ) # true
 +
print( matrix4.GetRow(0)[1] == 2*2 ) # true
 +
print( matrix4.GetRow(0)[2] == 3*2 ) # true
 +
print( matrix4.GetRow(0)[3] == 4*2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
InfNorm of the matrix.
+
 
====Returns====
+
=== /= ===
<div style="margin-left: 2em;">Return InfNorm - float
+
 
</div>
+
The "division assignment" operator. For the calculation method, refer to the '''/''' operator.
-----
+
 
===Inverse===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.Inverse ( self )
+
matrix4 = RLPy.RMatrix4( 1, 2, 3, 4,
 +
                        0, 0, 0, 0,
 +
                        0, 0, 0, 0,
 +
                        0, 0, 0, 0 )
 +
matrix4 /= 2
 +
 
 +
print( matrix4.GetRow(0)[0] == 1/2 ) # true
 +
print( matrix4.GetRow(0)[1] == 2/2 ) # true
 +
print( matrix4.GetRow(0)[2] == 3/2 ) # true
 +
print( matrix4.GetRow(0)[3] == 4/2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Inverse of the matrix.
+
 
====Returns====
+
== Member Functions ==
<div style="margin-left: 2em;">A new matrix containing this matrix's inverse - RLPy.RMatrix4
+
 
</div>
+
=== MakeIdentity (self) ===
-----
+
 
===InverseTranspose===
+
This function can be used to initialize the 3x3 matrix. It is equivalent to setting the matrix to:
 +
 
 +
:[1  0  0  0]
 +
:[0  1  0  0]
 +
:[0  0  1  0]
 +
:[0  0  0  1]
 +
 
 +
==== Returns ====
 +
:This object - RLPy.RMatrix4
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.InverseTranspose ( self )
+
matrix4 = RLPy.RMatrix4()
 +
matrix4.MakeIdentity()
 
</syntaxhighlight>
 
</syntaxhighlight>
Transpose of inverse.
+
 
====Returns====
+
=== M (self, args) ===
<div style="margin-left: 2em;">A new matrix - RLPy.RMatrix4
+
 
</div>
+
Get the value of an element in a 4x4 matrix by row and column index.
-----
+
 
===M===
+
==== 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 col - float
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.M ( self, args )
+
matrix4 = RLPy.RMatrix4()
 +
matrix4.MakeIdentity()
 +
 
 +
print(matrix4.M(0,0)) #
 
</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
+
=== E (self, args) ===
 +
 
 +
Get the value of an element in a 3x3 matrix by index number (from 0 to 15);
 +
 
 +
==== Parameters ====
 +
:'''nRow'''[IN] Index of the matrix.
 +
 
 +
==== Returns ====
 +
:The matrix element specified by index - float
  
'''nCol''' [IN] Index of the column in the matrix - int
 
</div>
 
====Returns====
 
<div style="margin-left: 2em;">The matrix element specified by row and col - float
 
</div>
 
-----
 
===MakeIdentity===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.MakeIdentity ( self )
+
matrix4 = RLPy.RMatrix4()
 +
matrix4.MakeIdentity()
 +
 
 +
print(matrix4.E(0)) #
 
</syntaxhighlight>
 
</syntaxhighlight>
Sets the matrix to the identity.
+
 
====Returns====
+
=== GetRow (self, nR) ===
<div style="margin-left: 2em;">This object - RLPy.RMatrix4
+
 
</div>
+
Retreive a row inside a 4x4 matrix.
-----
+
 
===MaxColumn===
+
==== Parameters ====
 +
:'''nRow'''[IN] Index of the row in the matrix.
 +
 
 +
==== Returns ====
 +
:The row vector of the matrix - RLPy.RVector4
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.MaxColumn ( self )
+
matrix4 = RLPy.RMatrix4()
 +
matrix4.MakeIdentity()
 +
row0 = matrix4.GetRow(0)
 +
 
 +
print(row0[0])
 +
print(row0[1])
 +
print(row0[2])
 +
print(row0[3])
 
</syntaxhighlight>
 
</syntaxhighlight>
Get maximum value of the column index in the matrix.
+
 
====Returns====
+
=== GetColumn (self, nC) ===
<div style="margin-left: 2em;">Return index of column of M containing maximum abs entry, or -1 if M = 0 - int
+
 
</div>
+
Retrieve a column inside a 4x4 matrix.
-----
+
 
===MaxRow===
+
==== Parameters ====
 +
:'''nRow'''[IN] Index of the column in the matrix.
 +
 
 +
==== Returns ====
 +
:The column vector of the matrix - RLPy.RVector4
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.MaxRow ( self )
+
matrix4 = RLPy.RMatrix4()
 +
matrix4.MakeIdentity()
 +
col0 = matrix4.GetColumn(0)
 +
 
 +
print(col0[0])
 +
print(col0[1])
 +
print(col0[2])
 +
print(col0[3])
 
</syntaxhighlight>
 
</syntaxhighlight>
Get maximum value of the row index in the matrix.
+
 
====Returns====
+
=== Transpose (self) ===
<div style="margin-left: 2em;">Return index of row of M containing maximum abs entry, or -1 if M = 0 - int
+
 
</div>
+
Obtain the transposed matrix by transposing the current m * n matrix into an n * m matrix by row-column swapping.
-----
+
 
===OneNorm===
+
==== Returns ====
 +
:A new matrix containing this matrix's transpose - RLPy.RMatrix4
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.OneNorm ( self )
+
matrix4_orgin = RLPy.RMatrix4(  1,  2,  3,  4,
 +
                                5,  6,  7,  8,
 +
                                9, 10, 11, 12,
 +
                              13, 14, 15, 16 )
 +
matrix4_transpose = matrix4_orgin.Transpose()
 +
row0 = matrix4_orgin.GetRow(0)
 +
col0 = matrix4_transpose.GetColumn(0)
 +
 
 +
print(row0[0] == col0[0])
 +
print(row0[1] == col0[1])
 +
print(row0[2] == col0[2])
 +
print(row0[3] == col0[3])
 
</syntaxhighlight>
 
</syntaxhighlight>
Norm of the matrix.
+
 
====Returns====
+
=== TransposeTimes (self, mM) ===
<div style="margin-left: 2em;">Return Norm - float
+
 
</div>
+
Multiply a transposed version of a 4x4 matrix with itself.
-----
+
 
===RotateAxisAngle===
+
==== Parameters ====
 +
:'''mM'''[IN] the matrix - RLPy.RMatrix4
 +
 
 +
==== Returns ====
 +
:A new matrix. (this^T * mM) - RLPy.RMatrix4
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.RotateAxisAngle ( self, rkAxis, fAngle )
+
matrix4_orgin = RLPy.RMatrix4(  1,  2,  3,  4,
 +
                                5,  6,  7,  8,
 +
                                9, 10, 11, 12,
 +
                              13, 14, 15, 16 )
 +
matrix4_transpose_value = RLPy.RMatrix4( 2, 0, 0, 0,
 +
                                        0, 2, 0, 0,
 +
                                        0, 0, 2, 0,
 +
                                        0, 0, 0, 2 )
 +
matrix4_transpose_times = matrix4_orgin.TransposeTimes(matrix4_transpose_value)
 +
row0 = matrix4_orgin.GetRow(0)
 +
col0 = matrix4_transpose_times.GetColumn(0)
 +
 
 +
print(row0[0]*2 == col0[0])
 +
print(row0[1]*2 == col0[1])
 +
print(row0[2]*2 == col0[2])
 +
print(row0[3]*2 == col0[3])
 
</syntaxhighlight>
 
</syntaxhighlight>
Rotation matrix from axis angle.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''rkAxis''' [IN] axis vector - RLPy.RVector3
+
=== TimesTranspose (self, mM) ===
 +
 
 +
Multiply this 4x4 matrix with a transposed version of itself.
 +
 
 +
==== Parameters ====
 +
:'''mM'''[IN] the matrix - RLPy.RMatrix4
 +
 
 +
==== Returns ====
 +
:A new matrix. (this * M^T) - RLPy.RMatrix4
  
'''fAngle''' [IN] angle in radians - float
 
</div>
 
====Returns====
 
<div style="margin-left: 2em;">Return a new matrix from specified axis angle - RLPy.RMatrix4
 
</div>
 
-----
 
===RotationX===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.RotationX ( self, fAngle )
+
matrix4_orgin = RLPy.RMatrix4(  1,  2,  3,  4,
 +
                                5,  6,  7,  8,
 +
                                9, 10, 11, 12,
 +
                              13, 14, 15, 16 )
 +
matrix4_transpose_value = RLPy.RMatrix4( 3, 0, 0, 0,
 +
                                        0, 3, 0, 0,
 +
                                        0, 0, 3, 0,
 +
                                        0, 0, 0, 3 )
 +
matrix4_times_transpose = matrix4_orgin.TimesTranspose(matrix4_transpose_value)
 +
row0 = matrix4_orgin.GetColumn(0)
 +
col0 = matrix4_times_transpose.GetColumn(0)
 +
 
 +
print(row0[0]*3 == col0[0])
 +
print(row0[1]*3 == col0[1])
 +
print(row0[2]*3 == col0[2])
 +
print(row0[3]*3 == col0[3])
 
</syntaxhighlight>
 
</syntaxhighlight>
Rotation matrix for rotations around x-axis.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''fAngle''' [IN] angle in radians - float
+
=== Inverse (self) ===
</div>
+
 
====Returns====
+
Obtain the inverse (reciprocal) of this 4x4 matrix (A^-1).
<div style="margin-left: 2em;">Return a new matrix of for rotations around x-axis - RLPy.RMatrix4
+
 
</div>
+
==== Returns ====
-----
+
:A new matrix containing this matrix's inverse - RLPy.RMatrix4
===RotationY===
+
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.RotationY ( self, fAngle )
+
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
 +
                              1, 1,-1,-2,
 +
                              1,-1,-1, 2,
 +
                              1,-2, 1,-1 )
 +
matrix4_inverse = matrix4_value.Inverse()
 +
row0_inverse = matrix4_inverse.GetRow(0)
 +
 
 +
print(row0_inverse[0])
 +
print(row0_inverse[1])
 +
print(row0_inverse[2])
 +
print(row0_inverse[3])
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=== Adjoint (self) ===
 +
 +
Adjugate this 4x4 matrix.
 +
 +
==== Returns ====
 +
:A new matrix containing this matrix's adjoint - RLPy.RMatrix4
 +
 +
<syntaxhighlight lang="Python">
 +
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
 +
                              1, 1,-1,-2,
 +
                              1,-1,-1, 2,
 +
                              1,-2, 1,-1 )
 +
matrix4_Adjoint = matrix4_value.Adjoint()
 +
row0_Adjoint = matrix4_Adjoint.GetRow(0)
 +
 +
print(row0_Adjoint[0])
 +
print(row0_Adjoint[1])
 +
print(row0_Adjoint[2])
 +
print(row0_Adjoint[3])
 +
</syntaxhighlight>
 +
 +
=== AdjointTranspose (self) ===
 +
 +
Adjugate and transpose this 4x4 matrix.
 +
 +
==== Returns ====
 +
:A new matrix - RLPy.RMatrix4
 +
 +
<syntaxhighlight lang="Python">
 +
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
 +
                              1, 1,-1,-2,
 +
                              1,-1,-1, 2,
 +
                              1,-2, 1,-1 )
 +
matrix4_Adjoint_transpose = matrix4_value.AdjointTranspose()
 +
col0_Adjoint_transpose = matrix4_Adjoint_transpose.GetColumn(0)
 +
 +
print(col0_Adjoint_transpose[0] == row0_Adjoint[0])
 +
print(col0_Adjoint_transpose[1] == row0_Adjoint[1])
 +
print(col0_Adjoint_transpose[2] == row0_Adjoint[2])
 +
print(col0_Adjoint_transpose[3] == row0_Adjoint[3])
 +
</syntaxhighlight>
 +
 +
=== InverseTranspose (self) ===
 +
 +
Invert and transpose this 4x4 matrix.
 +
 +
==== Returns ====
 +
:A new matrix - RLPy.RMatrix4
 +
 +
<syntaxhighlight lang="Python">
 +
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
 +
                              1, 1,-1,-2,
 +
                              1,-1,-1, 2,
 +
                              1,-2, 1,-1 )
 +
matrix4_inverse_transpose = matrix4_value.InverseTranspose()
 +
col0_inverse_transpose = matrix4_inverse_transpose.GetColumn(0)
 +
 +
print(col0_inverse_transpose[0] == row0_inverse[0])
 +
print(col0_inverse_transpose[1] == row0_inverse[1])
 +
print(col0_inverse_transpose[2] == row0_inverse[2])
 +
print(col0_inverse_transpose[3] == row0_inverse[3])
 +
</syntaxhighlight>
 +
 +
=== Determinant (self) ===
 +
 +
Obtain the scalar value for this 4x4 matrix (|A|).
 +
 +
==== Returns ====
 +
:The determinant of the matrix - float
 +
 +
<syntaxhighlight lang="Python">
 +
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
 +
                              1, 1,-1,-2,
 +
                              1,-1,-1, 2,
 +
                              1,-2, 1,-1 )
 +
print(matrix4_value.Determinant())
 +
</syntaxhighlight>
 +
 +
=== MaxColumn (self) ===
 +
 +
Find the maximum absolute value within this 4x4 matrix, and return the column in which the value is located.  If all of the elements within the 4x4 matrix are 0 then return -1.
 +
 +
==== Returns ====
 +
:Return index of column of M containing maximum abs entry, or -1 if M = 0 - int
 +
 +
<syntaxhighlight lang="Python">
 +
matrix4_column_value = RLPy.RMatrix4( 1, 2, 3,-5,
 +
                                      0, 0, 0, 0,
 +
                                      0, 0, 0, 0,
 +
                                      0, 0, 0, 0 )
 +
print(matrix4_column_value.MaxColumn()) # column:3 -> abs(-5)
 +
</syntaxhighlight>
 +
 +
=== MaxRow (self) ===
 +
 +
Find the maximum absolute value within this 4x4 matrix, and return the row in which the value is located.  If all of the elements within the 4x4 matrix are 0 then return -1.
 +
 +
==== Returns ====
 +
:Return index of row of M containing maximum abs entry, or -1 if M = 0 - int
 +
 +
<syntaxhighlight lang="Python">
 +
matrix4_row_value = RLPy.RMatrix4( 1, 0, 0, 0,
 +
                                  2, 0, 0, 0,
 +
                                  3, 0, 0, 0,
 +
                                  -5, 0, 0, 0 )
 +
print(matrix4_value.MaxRow()) # Row:3 -> abs(-5)
 +
</syntaxhighlight>
 +
 +
=== OneNorm (self) ===
 +
 +
Return the sum of the column elements that contain the largest absolute values.
 +
 +
==== Returns ====
 +
:Return Norm - float
 +
 +
<syntaxhighlight lang="Python">
 +
matrix4_row_value = RLPy.RMatrix4( 1, 0, 0, 0,
 +
                                  2, 0, 0, 0,
 +
                                  3, 0, 0, 0,
 +
                                  -5, 0, 0, 0 )
 +
print(matrix4_row_value.OneNorm()) # 11 -> 1+2+abs(-5)
 +
</syntaxhighlight>
 +
 +
=== InfNorm (self) ===
 +
 +
Return the sum of the row elements that contain the largest absolute values.
 +
 +
==== Returns ====
 +
:Return InfNorm - float
 +
 +
<syntaxhighlight lang="Python">
 +
matrix4_column_value = RLPy.RMatrix4( 1, 2, 3,-5,
 +
                                      0, 0, 0, 0,
 +
                                      0, 0, 0, 0,
 +
                                      0, 0, 0, 0 )
 +
print(matrix4_column_value.InfNorm()) # 11 -> 1+2+abs(-5)
 +
</syntaxhighlight>
 +
 +
=== FromRTS (self, kRotate, kTranslate, kScale) ===
 +
 +
Apply rotate, translate, and scale data to a 4x4 matrix.
 +
 +
==== Parameters ====
 +
:'''kRotate  '''[IN] Rotate Matrix - RLPy.RMatrix3
 +
:'''kTranslate'''[IN] Translate vector - RLPy.RVector3
 +
:'''kScale  '''[IN] Scale vector - RLPy.RVector3
 +
 +
==== Returns ====
 +
:Return a new matrix from RTS - RLPy.RMatrix4
 +
 +
<syntaxhighlight lang="Python">
 +
rotate = RLPy.RMatrix3( 1, 0, 0,
 +
                        0, 1, 0,
 +
                        0, 0, 1 )
 +
translate = RLPy.RVector3( 1, 0, 0 )
 +
scale = RLPy.RVector3( 2, 2, 2 )
 +
matrix4_result =  RLPy.RMatrix4().FromRTS( rotate, translate, scale )
 +
row0 = matrix4_result.GetRow(0)
 +
 +
print(row0[0])
 +
print(row0[1])
 +
print(row0[2])
 +
print(row0[3])
 +
</syntaxhighlight>
 +
 +
=== GetSimpleRTS (self, rkRotate, rkTranslate, rkScale) ===
 +
 +
Retrieve rotation, translation, and scale data from this 4x4 matrix.
 +
 +
==== Parameters ====
 +
:'''rkRotate'''  [IN] Angle of x-axis in radians - float
 +
:'''rkTranslate'''[IN] Angle of y-axis in radians - float
 +
:'''rkScale  '''[IN] Angle of z-axis in radians - float
 +
 +
==== Returns ====
 +
 +
<syntaxhighlight lang="Python">
 +
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
 +
                              1, 1,-1,-2,
 +
                              1,-1,-1, 2,
 +
                              1,-2, 1,-1 )
 +
rotate = RLPy.RMatrix3()
 +
translate = RLPy.RVector3()
 +
scale = RLPy.RVector3()
 +
matrix4_value.GetSimpleRTS( rotate, translate, scale )
 +
row0 = rotate.GetRow(0)
 +
 +
print(row0[0])
 +
print(row0[1])
 +
print(row0[2])
 +
 +
print(translate[0])
 +
print(translate[1])
 +
print(translate[2])
 +
 +
print(scale[0])
 +
print(scale[1])
 +
print(scale[2])       
 +
</syntaxhighlight>
 +
 +
=== GetSimpleRotate (self, rkRotate) ===
 +
 +
Retrieve rotation data from this 4x4 matrix.
 +
 +
==== Parameters ====
 +
:'''rkRotate'''[IN] Rotation Matrix - RLPy.RMatrix3
 +
 +
==== Returns ====
 +
:
 +
 +
<syntaxhighlight lang="Python">
 +
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
 +
                              1, 1,-1,-2,
 +
                              1,-1,-1, 2,
 +
                              1,-2, 1,-1
 +
rotate = RLPy.RMatrix3()
 +
matrix4_value.GetSimpleRotate( rotate )
 +
row0 = rotate.GetRow(0)
 +
 +
print(row0[0])
 +
print(row0[1])
 +
print(row0[2])
 +
</syntaxhighlight>
 +
 +
=== SetTranslateZero (self) ===
 +
 +
Set the translation data in this 4x4 matrix to 0.
 +
 +
<syntaxhighlight lang="Python">
 +
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
 +
                              1, 1,-1,-2,
 +
                              1,-1,-1, 2,
 +
                              1,-2, 1,-1
 +
matrix4_value.SetTranslateZero()
 +
row3 = matrix4_value.GetRow(3)
 +
 +
print(row3[0] == 0)
 +
print(row3[1] == 0)
 +
print(row3[2] == 0)
 +
</syntaxhighlight>
 +
 +
=== RotationX (self, fAngle) ===
 +
 +
Rotation matrix for rotations around x-axis。
 +
 +
==== Parameters ====
 +
:'''fAngle'''[IN] angle in radians - float
 +
 +
==== Returns ====
 +
:Return a new matrix of for rotations around x-axis - RLPy.RMatrix4
 +
 +
<syntaxhighlight lang="Python">
 +
matrix4_orgin = RLPy.RMatrix4()
 +
matrix4_orgin.MakeIdentity()
 +
matrix4_orgin.RotationX( 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 +
</syntaxhighlight>
 +
 +
=== RotationY (self, fAngle) ===
 +
 
Rotation matrix for rotations around y-axis.
 
Rotation matrix for rotations around y-axis.
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''fAngle''' [IN] angle in radians - float
+
==== Parameters ====
</div>
+
:'''fAngle'''[IN] angle in radians - float
====Returns====
+
 
<div style="margin-left: 2em;">Return a new matrix of for rotations around y-axis - RLPy.RMatrix4
+
==== Returns ====
</div>
+
:Return a new matrix of for rotations around y-axis - RLPy.RMatrix4
-----
+
 
===RotationZ===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.RotationZ ( self, fAngle )
+
matrix4_orgin = RLPy.RMatrix4()
 +
matrix4_orgin.MakeIdentity()
 +
matrix4_orgin.RotationY( 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=== RotationZ (self, fAngle) ===
 +
 
Rotation matrix for rotations around z-axis.
 
Rotation matrix for rotations around z-axis.
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''fAngle''' [IN] angle in radians - float
+
==== Parameters ====
</div>
+
:'''fAngle'''[IN] angle in radians - float
====Returns====
+
 
<div style="margin-left: 2em;">Return a new matrix of for rotations around z-axis - RLPy.RMatrix4
+
==== Returns ====
</div>
+
:Return a new matrix of for rotations around z-axis - RLPy.RMatrix4
-----
+
 
===SetSR===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.SetSR ( self, mSR )
+
matrix4_orgin = RLPy.RMatrix4()
 +
matrix4_orgin.MakeIdentity()
 +
matrix4_orgin.RotationZ( 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 
</syntaxhighlight>
 
</syntaxhighlight>
Set scale and rotation part of the matrix.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''mSR''' [IN] 3x3 matrix - RLPy.RMatrix3
+
=== RotateAxisAngle (self, rkAxis, fAngle) ===
</div>
+
 
====Returns====
+
Rotation matrix from axis angle.
<div style="margin-left: 2em;">Return a new 4x4 matrix - RLPy.RMatrix4
+
 
</div>
+
==== Parameters ====
-----
+
:'''rkAxis'''[IN] axis vector - RLPy.RVector3
===SetTranslate===
+
:'''fAngle'''[IN] angle in radians - float
 +
 
 +
==== Returns ====
 +
:Return a new matrix from specified axis angle - RLPy.RMatrix4
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.SetTranslate ( self, vTranslate )
+
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
 +
                              1, 1,-1,-2,
 +
                              1,-1,-1, 2,
 +
                              1,-2, 1,-1
 +
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"   
 +
matrix4_value.RotateAxisAngle( x_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 +
matrix4_value.RotateAxisAngle( y_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 +
matrix4_value.RotateAxisAngle( z_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 
</syntaxhighlight>
 
</syntaxhighlight>
Set translate of the matrix.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''vTranslate''' [IN] Translate vector - RLPy.RVector3
+
=== FromEulerAngle (self, Oreder, rx, ry, rz) ===
</div>
+
 
====Returns====
+
Convert Euler angle to a 4x4 matrix according to a rotation axis order.
<div style="margin-left: 2em;">Return a new matrix with the specified translation - RLPy.RMatrix4
+
 
</div>
+
==== Parameters ====
-----
+
:'''Oreder'''[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
===TimesTranspose===
+
 
 +
==== Returns ====
 +
:Return a new matrix from specified axis angle - RLPy.RMatrix4
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.TimesTranspose ( self, mM )
+
euler_angle_x = 90 * RLPy.RMath.CONST_DEG_TO_RAD
 +
euler_angle_y = 0
 +
euler_angle_z = 0
 +
matrix4_result = RLPy.RMatrix4().FromEulerAngle( RLPy.EEulerOrder_XYZ, euler_angle_x, euler_angle_y, euler_angle_z)
 +
row0 = matrix4_result[0].GetRow(0)
 +
 
 +
print(row0[0])
 +
print(row0[1])
 +
print(row0[2])
 +
print(row0[3])
 
</syntaxhighlight>
 
</syntaxhighlight>
Multiplies of the transpose of the matrix.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''mM''' [IN] the matrix - RLPy.RMatrix4
+
=== SetSR (self, mSR) ===
</div>
+
 
====Returns====
+
Set scale and rotation part of the matrix。
<div style="margin-left: 2em;">A new matrix. (this * M^T) - RLPy.RMatrix4
+
 
</div>
+
==== Parameters ====
-----
+
:'''mSR'''[IN] 3x3 matrix - RLPy.RMatrix3
===Transpose===
+
 
 +
==== Returns ====
 +
:Return a new 4x4 matrix - RLPy.RMatrix4
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.Transpose ( self )
+
matrix4_orgin = RLPy.RMatrix4()
 +
matrix4_orgin.MakeIdentity()
 +
matrix3_rotate_value = RLPy.RMatrix3( 1, 0, 0,
 +
                                      0, 1, 0,
 +
                                      0, 0, 1 )
 +
matrix4_orgin.SetSR(matrix3_rotate_value)
 
</syntaxhighlight>
 
</syntaxhighlight>
Transpose of the matrix.
+
 
====Returns====
+
=== GetSR (self) ===
<div style="margin-left: 2em;">A new matrix containing this matrix's transpose - RLPy.RMatrix4
+
 
</div>
+
Get scale and rotation part of the matrix。
-----
+
 
===TransposeTimes===
+
==== Returns ====
 +
:Return a 3x3 matrix - RLPy.RMatrix3
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RMatrix4.TransposeTimes ( self, mM )
+
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
 +
                              1, 1,-1,-2,
 +
                              1,-1,-1, 2,
 +
                              1,-2, 1,-1
 +
result = matrix4_value.GetSR()
 +
row0 = result.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.RMatrix4
+
=== SetTranslate (self, vTranslate) ===
</div>
+
 
====Returns====
+
Set translate of the matrix。
<div style="margin-left: 2em;">A new matrix. (this^T * mM) - RLPy.RMatrix4
+
 
</div>
+
==== Parameters ====
 +
:'''vTranslate'''[IN] Translate vector - RLPy.RVector3
 +
 
 +
==== Returns ====
 +
:Return a new matrix with the specified translation - RLPy.RMatrix4
 +
 
 +
<syntaxhighlight lang="Python">
 +
matrix4_orgin = RLPy.RMatrix4()
 +
matrix4_orgin.MakeIdentity()
 +
matrix4_orgin.SetTranslate(RLPy.RVector3( 1, 2, 3 ) )
 +
</syntaxhighlight>
 +
 
 +
=== GetTranslate (self) ===
 +
 
 +
Get translate of the matrix。
 +
 
 +
==== Returns ====
 +
:Return a translate vector - RLPy.RVector3
 +
 
 +
<syntaxhighlight lang="Python">
 +
matrix4_orgin = RLPy.RMatrix4()
 +
matrix4_orgin.MakeIdentity()
 +
matrix4_orgin.SetTranslate(RLPy.RVector3( 1, 2, 3 ) )
 +
result = matrix4_orgin.GetTranslate()
 +
 
 +
print(result[0] == 1)
 +
print(result[1] == 2)
 +
print(result[2] == 3)
 +
</syntaxhighlight>
 +
 
 +
=== AccuScale (self, rkScale) ===
 +
 
 +
Accumulate matrix with scale vector。
 +
 
 +
==== Parameters ====
 +
:'''rkScale'''[IN] Scale vector - RLPy.RVector3
 +
 
 +
==== Returns ====
 +
:Return a new matrix (*this) *= Accumulate - RLPy.RMatrix4
 +
 
 +
<syntaxhighlight lang="Python">
 +
matrix4_orgin = RLPy.RMatrix4()
 +
matrix4_orgin.MakeIdentity()
 +
matrix4_orgin.AccuScale(RLPy.RVector3( 2, 2, 2 ) )
 +
matrix4_orgin.AccuScale(RLPy.RVector3( 3, 3, 3 ) )
 +
result = matrix4_orgin.GetSR()
 +
row0 = result.GetRow(0)
 +
print(row0[0] == 2*3)
 +
row1 = result.GetRow(1)
 +
print(row1[1] == 2*3)
 +
row2 = result.GetRow(2)
 +
print(row2[2] == 2*3)
 +
</syntaxhighlight>
 +
 
 +
=== AccuRotate (self, rkRotate) ===
 +
 
 +
Accumulate matrix with rotation matrix。
 +
 
 +
==== Parameters ====
 +
:'''rkRotate'''[IN] Rotation matrix - RLPy.RMatrix3
 +
 
 +
==== Returns ====
 +
:Return a new matrix (*this) *= Accumulate - RLPy.RMatrix4
 +
 
 +
<syntaxhighlight lang="Python">
 +
matrix4_orgin = RLPy.RMatrix4()
 +
matrix4_orgin.MakeIdentity()
 +
matrix3_orgin = RLPy.RMatrix3()
 +
matrix3_orgin.FromAxisAngle( RLPy.RVector3( 0, 1, 0 ), 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 +
matrix4_orgin.AccuRotate(matrix3_orgin)
 +
matrix4_orgin.AccuRotate(matrix3_orgin)
 +
rotate = RLPy.RMatrix3()
 +
matrix4_orgin.GetSimpleRotate( rotate )
 +
row0 = rotate.GetRow(0)
 +
print(row0[0])
 +
print(row0[1])
 +
print(row0[2])
 +
</syntaxhighlight>
 +
 
 +
=== AccuTranslate (self, rkTranslate) ===
 +
 
 +
Accumulate matrix with translate vector。
 +
 
 +
==== Parameters ====
 +
:'''rkTranslate'''[IN] Translate vector - RLPy.RVector3
 +
 
 +
==== Returns ====
 +
:Return a new matrix (*this) *= Accumulate - RLPy.RMatrix4
 +
 
 +
<syntaxhighlight lang="Python">
 +
matrix4_orgin = RLPy.RMatrix4()
 +
matrix4_orgin.MakeIdentity()
 +
matrix4_orgin.AccuTranslate(RLPy.RVector3( 1, 2, 3 ) )
 +
matrix4_orgin.AccuTranslate(RLPy.RVector3( 2, 2, 2 ) )
 +
row3 = matrix4_orgin.GetRow(3)
 +
print(row3[0] == 1+2)
 +
print(row3[1] == 2+2)
 +
print(row3[2] == 2+3)
 +
</syntaxhighlight>

Revision as of 22:24, 25 February 2020

Contents

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

Description

This class represent the transform data of RTransform. This class provides access to RLPy's internal 4x4 matrix operators and related functions.

Operators

+

The "addition" operator.

matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )
matrix4_b = RLPy.RMatrix4( 2, 2, 2, 2,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )
matrix4_result = matrix4_a + matrix4_b

print( matrix4_result.GetRow(0)[0] == 1+2 ) # true
print( matrix4_result.GetRow(0)[1] == 2+2 ) # true
print( matrix4_result.GetRow(0)[2] == 3+2 ) # true
print( matrix4_result.GetRow(0)[3] == 4+2 ) # true

-

The "subtraction" operator.

matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )
matrix4_b = RLPy.RMatrix4( 2, 2, 2, 2,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )
matrix4_result = matrix4_a - matrix4_b

print( matrix4_result.GetRow(0)[0] == 1-2 ) # true
print( matrix4_result.GetRow(0)[1] == 2-2 ) # true
print( matrix4_result.GetRow(0)[2] == 3-2 ) # true
print( matrix4_result.GetRow(0)[3] == 4-2 ) # true

*

The "multiplication" operator.

matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )
matrix4_b = RLPy.RMatrix4( 2, 0, 0, 0,
                           2, 0, 0, 0,
                           2, 0, 0, 0,
                           2, 0, 0, 0 )
matrix4_result = matrix4_a * matrix4_b

print( matrix4_result.GetRow(0)[0] == 1*2 + 2*2 + 3*2 + 4*2  ) # true

/

The "division" operator.

matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )
matrix4_result = matrix4_a / 2

print( matrix4_result.GetRow(0)[0] == 1/2 ) # true
print( matrix4_result.GetRow(0)[1] == 2/2 ) # true
print( matrix4_result.GetRow(0)[2] == 3/2 ) # true
print( matrix4_result.GetRow(0)[3] == 4/2 ) # true

-

The "unary minus" .

matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )
matrix4_result = -matrix4_a

print( matrix4_result.GetRow(0)[0] == -1 ) # true
print( matrix4_result.GetRow(0)[1] == -2 ) # true
print( matrix4_result.GetRow(0)[2] == -3 ) # true
print( matrix4_result.GetRow(0)[3] == -4 ) # true

==

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

matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )
matrix4_b = RLPy.RMatrix4( 1, 2, 3, 4,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )

print( matrix4_a == matrix4_b ) # true

!=

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

matrix4_a = RLPy.RMatrix4( 1, 2, 3, 4,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )
matrix4_b = RLPy.RMatrix4( 2, 2, 2, 2,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )

print( matrix4_a != matrix4_b ) # true

>

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

matrix4_a = RLPy.RMatrix4( 1, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )
matrix4_b = RLPy.RMatrix4( 2, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )

print( matrix4_b > matrix4_a ) # true

>=

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

matrix4_a = RLPy.RMatrix4( 1, 1, 1, 4,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )
matrix4_b = RLPy.RMatrix4( 1, 1, 1, 8,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )

print( matrix4_b >= matrix4_a ) # true

<

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

matrix4_a = RLPy.RMatrix4( 2, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )
matrix4_b = RLPy.RMatrix4( 3, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )

print( matrix4_a < matrix4_b ) # true

<=

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

matrix4_a = RLPy.RMatrix4( 2, 2, 1, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )
matrix4_b = RLPy.RMatrix4( 2, 2, 5, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0 )

print( matrix4_a <= matrix4_b ) # true

+=

The "addition assignment" operator.

matrix4 =  RLPy.RMatrix4( 1, 2, 3, 4,
                          0, 0, 0, 0,
                          0, 0, 0, 0, 
                          0, 0, 0, 0 )
matrix4 += RLPy.RMatrix4( 2, 2, 2, 2,
                          0, 0, 0, 0,
                          0, 0, 0, 0,
                          0, 0, 0, 0 )

print( matrix4.GetRow(0)[0] == 1+2 ) # true
print( matrix4.GetRow(0)[1] == 2+2 ) # true
print( matrix4.GetRow(0)[2] == 3+2 ) # true
print( matrix4.GetRow(0)[3] == 4+2 ) # true

-=

The "subtraction assignment" operator.

matrix4 =  RLPy.RMatrix4( 1, 2, 3, 4,
                          0, 0, 0, 0,
                          0, 0, 0, 0,
                          0, 0, 0, 0 )
matrix4 -= RLPy.RMatrix4( 2, 2, 2, 2,
                          0, 0, 0, 0,
                          0, 0, 0, 0,
                          0, 0, 0, 0 )

print( matrix4.GetRow(0)[0] == 1-2 ) # true
print( matrix4.GetRow(0)[1] == 2-2 ) # true
print( matrix4.GetRow(0)[2] == 3-2 ) # true
print( matrix4.GetRow(0)[3] == 4-2 ) # true

*=

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

matrix4 = RLPy.RMatrix4( 1, 2, 3, 4,
                         0, 0, 0, 0,
                         0, 0, 0, 0,
                         0, 0, 0, 0 )
matrix4 *= 2

print( matrix4.GetRow(0)[0] == 1*2 ) # true
print( matrix4.GetRow(0)[1] == 2*2 ) # true
print( matrix4.GetRow(0)[2] == 3*2 ) # true
print( matrix4.GetRow(0)[3] == 4*2 ) # true

/=

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

matrix4 = RLPy.RMatrix4( 1, 2, 3, 4,
                         0, 0, 0, 0,
                         0, 0, 0, 0,
                         0, 0, 0, 0 )
matrix4 /= 2

print( matrix4.GetRow(0)[0] == 1/2 ) # true
print( matrix4.GetRow(0)[1] == 2/2 ) # true
print( matrix4.GetRow(0)[2] == 3/2 ) # true
print( matrix4.GetRow(0)[3] == 4/2 ) # true

Member Functions

MakeIdentity (self)

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

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

Returns

This object - RLPy.RMatrix4
matrix4 = RLPy.RMatrix4()
matrix4.MakeIdentity()

M (self, args)

Get the value of an element in a 4x4 matrix by row and column index.

Parameters

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

Returns

The matrix element specified by row and col - float
matrix4 = RLPy.RMatrix4()
matrix4.MakeIdentity()

print(matrix4.M(0,0)) #

E (self, args)

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

Parameters

nRow[IN] Index of the matrix.

Returns

The matrix element specified by index - float
matrix4 = RLPy.RMatrix4()
matrix4.MakeIdentity()

print(matrix4.E(0)) #

GetRow (self, nR)

Retreive a row inside a 4x4 matrix.

Parameters

nRow[IN] Index of the row in the matrix.

Returns

The row vector of the matrix - RLPy.RVector4
matrix4 = RLPy.RMatrix4()
matrix4.MakeIdentity()
row0 = matrix4.GetRow(0)

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

GetColumn (self, nC)

Retrieve a column inside a 4x4 matrix.

Parameters

nRow[IN] Index of the column in the matrix.

Returns

The column vector of the matrix - RLPy.RVector4
matrix4 = RLPy.RMatrix4()
matrix4.MakeIdentity()
col0 = matrix4.GetColumn(0)

print(col0[0])
print(col0[1])
print(col0[2])
print(col0[3])

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 - RLPy.RMatrix4
matrix4_orgin = RLPy.RMatrix4(  1,  2,  3,  4,
                                5,  6,  7,  8,
                                9, 10, 11, 12,
                               13, 14, 15, 16 )
matrix4_transpose = matrix4_orgin.Transpose()
row0 = matrix4_orgin.GetRow(0)
col0 = matrix4_transpose.GetColumn(0)

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

TransposeTimes (self, mM)

Multiply a transposed version of a 4x4 matrix with itself.

Parameters

mM[IN] the matrix - RLPy.RMatrix4

Returns

A new matrix. (this^T * mM) - RLPy.RMatrix4
matrix4_orgin = RLPy.RMatrix4(  1,  2,  3,  4,
                                5,  6,  7,  8,
                                9, 10, 11, 12,
                               13, 14, 15, 16 )
matrix4_transpose_value = RLPy.RMatrix4( 2, 0, 0, 0,
                                         0, 2, 0, 0,
                                         0, 0, 2, 0,
                                         0, 0, 0, 2 )
matrix4_transpose_times = matrix4_orgin.TransposeTimes(matrix4_transpose_value)
row0 = matrix4_orgin.GetRow(0)
col0 = matrix4_transpose_times.GetColumn(0)

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

TimesTranspose (self, mM)

Multiply this 4x4 matrix with a transposed version of itself.

Parameters

mM[IN] the matrix - RLPy.RMatrix4

Returns

A new matrix. (this * M^T) - RLPy.RMatrix4
matrix4_orgin = RLPy.RMatrix4(  1,  2,  3,  4,
                                5,  6,  7,  8,
                                9, 10, 11, 12,
                               13, 14, 15, 16 )
matrix4_transpose_value = RLPy.RMatrix4( 3, 0, 0, 0,
                                         0, 3, 0, 0,
                                         0, 0, 3, 0,
                                         0, 0, 0, 3 )
matrix4_times_transpose = matrix4_orgin.TimesTranspose(matrix4_transpose_value)
row0 = matrix4_orgin.GetColumn(0)
col0 = matrix4_times_transpose.GetColumn(0)

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

Inverse (self)

Obtain the inverse (reciprocal) of this 4x4 matrix (A^-1).

Returns

A new matrix containing this matrix's inverse - RLPy.RMatrix4
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
                               1, 1,-1,-2,
                               1,-1,-1, 2,
                               1,-2, 1,-1 )
matrix4_inverse = matrix4_value.Inverse()
row0_inverse = matrix4_inverse.GetRow(0)

print(row0_inverse[0])
print(row0_inverse[1])
print(row0_inverse[2])
print(row0_inverse[3])

Adjoint (self)

Adjugate this 4x4 matrix.

Returns

A new matrix containing this matrix's adjoint - RLPy.RMatrix4
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
                               1, 1,-1,-2,
                               1,-1,-1, 2,
                               1,-2, 1,-1 )
matrix4_Adjoint = matrix4_value.Adjoint()
row0_Adjoint = matrix4_Adjoint.GetRow(0)

print(row0_Adjoint[0])
print(row0_Adjoint[1])
print(row0_Adjoint[2])
print(row0_Adjoint[3])

AdjointTranspose (self)

Adjugate and transpose this 4x4 matrix.

Returns

A new matrix - RLPy.RMatrix4
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
                               1, 1,-1,-2,
                               1,-1,-1, 2,
                               1,-2, 1,-1 )
matrix4_Adjoint_transpose = matrix4_value.AdjointTranspose()
col0_Adjoint_transpose = matrix4_Adjoint_transpose.GetColumn(0)

print(col0_Adjoint_transpose[0] == row0_Adjoint[0])
print(col0_Adjoint_transpose[1] == row0_Adjoint[1])
print(col0_Adjoint_transpose[2] == row0_Adjoint[2])
print(col0_Adjoint_transpose[3] == row0_Adjoint[3])

InverseTranspose (self)

Invert and transpose this 4x4 matrix.

Returns

A new matrix - RLPy.RMatrix4
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
                               1, 1,-1,-2,
                               1,-1,-1, 2,
                               1,-2, 1,-1 )
matrix4_inverse_transpose = matrix4_value.InverseTranspose()
col0_inverse_transpose = matrix4_inverse_transpose.GetColumn(0)

print(col0_inverse_transpose[0] == row0_inverse[0])
print(col0_inverse_transpose[1] == row0_inverse[1])
print(col0_inverse_transpose[2] == row0_inverse[2])
print(col0_inverse_transpose[3] == row0_inverse[3])

Determinant (self)

Obtain the scalar value for this 4x4 matrix (|A|).

Returns

The determinant of the matrix - float
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
                               1, 1,-1,-2,
                               1,-1,-1, 2,
                               1,-2, 1,-1 )
print(matrix4_value.Determinant())

MaxColumn (self)

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

Returns

Return index of column of M containing maximum abs entry, or -1 if M = 0 - int
matrix4_column_value = RLPy.RMatrix4( 1, 2, 3,-5,
                                      0, 0, 0, 0,
                                      0, 0, 0, 0,
                                      0, 0, 0, 0 )
print(matrix4_column_value.MaxColumn()) # column:3 -> abs(-5)

MaxRow (self)

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

Returns

Return index of row of M containing maximum abs entry, or -1 if M = 0 - int
matrix4_row_value = RLPy.RMatrix4( 1, 0, 0, 0,
                                   2, 0, 0, 0,
                                   3, 0, 0, 0,
                                  -5, 0, 0, 0 )
print(matrix4_value.MaxRow()) # Row:3 -> abs(-5)

OneNorm (self)

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

Returns

Return Norm - float
matrix4_row_value = RLPy.RMatrix4( 1, 0, 0, 0,
                                   2, 0, 0, 0,
                                   3, 0, 0, 0,
                                  -5, 0, 0, 0 )
print(matrix4_row_value.OneNorm()) # 11 -> 1+2+abs(-5)

InfNorm (self)

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

Returns

Return InfNorm - float
matrix4_column_value = RLPy.RMatrix4( 1, 2, 3,-5,
                                      0, 0, 0, 0,
                                      0, 0, 0, 0,
                                      0, 0, 0, 0 )
print(matrix4_column_value.InfNorm()) # 11 -> 1+2+abs(-5)

FromRTS (self, kRotate, kTranslate, kScale)

Apply rotate, translate, and scale data to a 4x4 matrix.

Parameters

kRotate [IN] Rotate Matrix - RLPy.RMatrix3
kTranslate[IN] Translate vector - RLPy.RVector3
kScale [IN] Scale vector - RLPy.RVector3

Returns

Return a new matrix from RTS - RLPy.RMatrix4
rotate = RLPy.RMatrix3( 1, 0, 0,
                        0, 1, 0,
                        0, 0, 1 )
translate = RLPy.RVector3( 1, 0, 0 )
scale = RLPy.RVector3( 2, 2, 2 )
matrix4_result =  RLPy.RMatrix4().FromRTS( rotate, translate, scale )
row0 = matrix4_result.GetRow(0)

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

GetSimpleRTS (self, rkRotate, rkTranslate, rkScale)

Retrieve rotation, translation, and scale data from this 4x4 matrix.

Parameters

rkRotate [IN] Angle of x-axis in radians - float
rkTranslate[IN] Angle of y-axis in radians - float
rkScale [IN] Angle of z-axis in radians - float

Returns

matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
                               1, 1,-1,-2,
                               1,-1,-1, 2,
                               1,-2, 1,-1 )
rotate = RLPy.RMatrix3()
translate = RLPy.RVector3()
scale = RLPy.RVector3()
matrix4_value.GetSimpleRTS( rotate, translate, scale )
row0 = rotate.GetRow(0)

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

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

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

GetSimpleRotate (self, rkRotate)

Retrieve rotation data from this 4x4 matrix.

Parameters

rkRotate[IN] Rotation Matrix - RLPy.RMatrix3

Returns

matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
                               1, 1,-1,-2,
                               1,-1,-1, 2,
                               1,-2, 1,-1 
rotate = RLPy.RMatrix3()
matrix4_value.GetSimpleRotate( rotate )
row0 = rotate.GetRow(0)

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

SetTranslateZero (self)

Set the translation data in this 4x4 matrix to 0.

matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
                               1, 1,-1,-2,
                               1,-1,-1, 2,
                               1,-2, 1,-1 
matrix4_value.SetTranslateZero()
row3 = matrix4_value.GetRow(3)

print(row3[0] == 0)
print(row3[1] == 0)
print(row3[2] == 0)

RotationX (self, fAngle)

Rotation matrix for rotations around x-axis。

Parameters

fAngle[IN] angle in radians - float

Returns

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

RotationY (self, fAngle)

Rotation matrix for rotations around y-axis.

Parameters

fAngle[IN] angle in radians - float

Returns

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

RotationZ (self, fAngle)

Rotation matrix for rotations around z-axis.

Parameters

fAngle[IN] angle in radians - float

Returns

Return a new matrix of for rotations around z-axis - RLPy.RMatrix4
matrix4_orgin = RLPy.RMatrix4()
matrix4_orgin.MakeIdentity()
matrix4_orgin.RotationZ( 90 * RLPy.RMath.CONST_DEG_TO_RAD )

RotateAxisAngle (self, rkAxis, fAngle)

Rotation matrix from axis angle.

Parameters

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

Returns

Return a new matrix from specified axis angle - RLPy.RMatrix4
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
                               1, 1,-1,-2,
                               1,-1,-1, 2,
                               1,-2, 1,-1 
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"    
matrix4_value.RotateAxisAngle( x_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )
matrix4_value.RotateAxisAngle( y_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )
matrix4_value.RotateAxisAngle( z_axis_vector, 90 * RLPy.RMath.CONST_DEG_TO_RAD )

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

Convert Euler angle to a 4x4 matrix according to a rotation axis order.

Parameters

Oreder[IN] Euler order - RLPy.Rotation_Orderrx[IN] Angle of x-axis in radians - floatry[IN] Angle of y-axis in radians - floatrz[IN] Angle of z-axis in radians - float

Returns

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

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

SetSR (self, mSR)

Set scale and rotation part of the matrix。

Parameters

mSR[IN] 3x3 matrix - RLPy.RMatrix3

Returns

Return a new 4x4 matrix - RLPy.RMatrix4
matrix4_orgin = RLPy.RMatrix4()
matrix4_orgin.MakeIdentity()
matrix3_rotate_value = RLPy.RMatrix3( 1, 0, 0,
                                      0, 1, 0,
                                      0, 0, 1 )
matrix4_orgin.SetSR(matrix3_rotate_value)

GetSR (self)

Get scale and rotation part of the matrix。

Returns

Return a 3x3 matrix - RLPy.RMatrix3
matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
                               1, 1,-1,-2,
                               1,-1,-1, 2,
                               1,-2, 1,-1 
result = matrix4_value.GetSR()
row0 = result.GetRow(0)
print(row0[0])
print(row0[1])
print(row0[2])

SetTranslate (self, vTranslate)

Set translate of the matrix。

Parameters

vTranslate[IN] Translate vector - RLPy.RVector3

Returns

Return a new matrix with the specified translation - RLPy.RMatrix4
matrix4_orgin = RLPy.RMatrix4()
matrix4_orgin.MakeIdentity()
matrix4_orgin.SetTranslate(RLPy.RVector3( 1, 2, 3 ) )

GetTranslate (self)

Get translate of the matrix。

Returns

Return a translate vector - RLPy.RVector3
matrix4_orgin = RLPy.RMatrix4()
matrix4_orgin.MakeIdentity()
matrix4_orgin.SetTranslate(RLPy.RVector3( 1, 2, 3 ) )
result = matrix4_orgin.GetTranslate()

print(result[0] == 1)
print(result[1] == 2)
print(result[2] == 3)

AccuScale (self, rkScale)

Accumulate matrix with scale vector。

Parameters

rkScale[IN] Scale vector - RLPy.RVector3

Returns

Return a new matrix (*this) *= Accumulate - RLPy.RMatrix4
matrix4_orgin = RLPy.RMatrix4()
matrix4_orgin.MakeIdentity()
matrix4_orgin.AccuScale(RLPy.RVector3( 2, 2, 2 ) )
matrix4_orgin.AccuScale(RLPy.RVector3( 3, 3, 3 ) )
result = matrix4_orgin.GetSR()
row0 = result.GetRow(0)
print(row0[0] == 2*3)
row1 = result.GetRow(1)
print(row1[1] == 2*3)
row2 = result.GetRow(2)
print(row2[2] == 2*3)

AccuRotate (self, rkRotate)

Accumulate matrix with rotation matrix。

Parameters

rkRotate[IN] Rotation matrix - RLPy.RMatrix3

Returns

Return a new matrix (*this) *= Accumulate - RLPy.RMatrix4
matrix4_orgin = RLPy.RMatrix4()
matrix4_orgin.MakeIdentity()
matrix3_orgin = RLPy.RMatrix3()
matrix3_orgin.FromAxisAngle( RLPy.RVector3( 0, 1, 0 ), 90 * RLPy.RMath.CONST_DEG_TO_RAD )
matrix4_orgin.AccuRotate(matrix3_orgin)
matrix4_orgin.AccuRotate(matrix3_orgin)
rotate = RLPy.RMatrix3()
matrix4_orgin.GetSimpleRotate( rotate )
row0 = rotate.GetRow(0)
print(row0[0])
print(row0[1])
print(row0[2])

AccuTranslate (self, rkTranslate)

Accumulate matrix with translate vector。

Parameters

rkTranslate[IN] Translate vector - RLPy.RVector3

Returns

Return a new matrix (*this) *= Accumulate - RLPy.RMatrix4
matrix4_orgin = RLPy.RMatrix4()
matrix4_orgin.MakeIdentity()
matrix4_orgin.AccuTranslate(RLPy.RVector3( 1, 2, 3 ) )
matrix4_orgin.AccuTranslate(RLPy.RVector3( 2, 2, 2 ) )
row3 = matrix4_orgin.GetRow(3)
print(row3[0] == 1+2)
print(row3[1] == 2+2)
print(row3[2] == 2+3)