IC8 Python API:RLPy RMatrix4

From Reallusion Wiki!
Revision as of 00:29, 17 January 2023 by Chuck (RL) (Talk | contribs) (Created page with "{{TOC}} {{Parent|IC_8_Python_API:Modules|iC8 Modules}} {{last_modified}} ==Description== This class represent the transform data of RTransform. This class provides access to...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Main article: iC8 Modules.
Last modified: 01/17/2023

Description

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

Public Methods

RLPy.RMatrix4.AccuRotate(self, rkRotate)

Accumulate matrix with rotation matrix.

Parameters

rkRotate[IN] Rotation matrix - RLPy.RMatrix3

Returns

Return a new matrix (*this) *= Accumulate - RLPy.RMatrix4

 1 matrix4_orgin = RLPy.RMatrix4()
 2 matrix4_orgin.MakeIdentity()
 3 matrix3_orgin = RLPy.RMatrix3()
 4 matrix3_orgin.FromAxisAngle( RLPy.RVector3( 0, 1, 0 ), 90 * RLPy.RMath.CONST_DEG_TO_RAD )
 5 matrix4_orgin.AccuRotate(matrix3_orgin)
 6 matrix4_orgin.AccuRotate(matrix3_orgin)
 7 
 8 rotate = RLPy.RMatrix3()
 9 matrix4_orgin.GetSimpleRotate( rotate )
10 row0 = rotate.GetRow(0)
11 
12 print(row0[0])
13 print(row0[1])
14 print(row0[2])

RLPy.RMatrix4.AccuScale(self, rkScale)

Accumulate matrix with scale vector.

Parameters

rkScale[IN] Scale vector - RLPy.RVector3

Returns

Return a new matrix (*this) *= Accumulate - RLPy.RMatrix4

 1 matrix4_orgin = RLPy.RMatrix4()
 2 matrix4_orgin.MakeIdentity()
 3 matrix4_orgin.AccuScale(RLPy.RVector3( 2, 2, 2 ) )
 4 matrix4_orgin.AccuScale(RLPy.RVector3( 3, 3, 3 ) )
 5 
 6 result = matrix4_orgin.GetSR()
 7 
 8 row0 = result.GetRow(0)
 9 print(row0[0] == 2*3)
10 
11 row1 = result.GetRow(1)
12 print(row1[1] == 2*3)
13 
14 row2 = result.GetRow(2)
15 print(row2[2] == 2*3)

RLPy.RMatrix4.AccuTranslate(self, rkTranslate)

Accumulate matrix with translate vector.

Parameters

rkTranslate[IN] Translate vector - RLPy.RVector3

Returns

Return a new matrix (*this) *= Accumulate - RLPy.RMatrix4

 1 matrix4_orgin = RLPy.RMatrix4()
 2 matrix4_orgin.MakeIdentity()
 3 matrix4_orgin.AccuTranslate(RLPy.RVector3( 1, 2, 3 ) )
 4 matrix4_orgin.AccuTranslate(RLPy.RVector3( 2, 2, 2 ) )
 5 
 6 row3 = matrix4_orgin.GetRow(3)
 7 
 8 print(row3[0] == 1+2)
 9 print(row3[1] == 2+2)
10 print(row3[2] == 2+3)

RLPy.RMatrix4.Adjoint(self)

Inverse times determinant.

Returns

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

 1 matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
 2                                1, 1,-1,-2,
 3                                1,-1,-1, 2,
 4                                1,-2, 1,-1 )
 5 
 6 matrix4_Adjoint = matrix4_value.Adjoint()
 7 row0_Adjoint = matrix4_Adjoint.GetRow(0)
 8 
 9 print(row0_Adjoint[0])
10 print(row0_Adjoint[1])
11 print(row0_Adjoint[2])
12 print(row0_Adjoint[3])

RLPy.RMatrix4.AdjointTranspose(self)

Transpose of inverse times determinant.

Returns

Returns a new matrix - RLPy.RMatrix4

 1 matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
 2                                1, 1,-1,-2,
 3                                1,-1,-1, 2,
 4                                1,-2, 1,-1 )
 5 
 6 matrix4_Adjoint_transpose = matrix4_value.AdjointTranspose()
 7 col0_Adjoint_transpose = matrix4_Adjoint_transpose.GetColumn(0)
 8 
 9 print(col0_Adjoint_transpose[0] == row0_Adjoint[0])
10 print(col0_Adjoint_transpose[1] == row0_Adjoint[1])
11 print(col0_Adjoint_transpose[2] == row0_Adjoint[2])
12 print(col0_Adjoint_transpose[3] == row0_Adjoint[3])

RLPy.RMatrix4.AlmostSame(self, kM, fThreshold)

compare each element of matrix with threshold(operator= is memory compare)

Parameters

kM[IN] Matrix to compare - RLPy.RMatrix4 fThreshold[IN] Threshold to compare - float

Returns

Return bool - bool

1 # No example

RLPy.RMatrix4.Determinant(self)

The matrix's determinant.

Returns

Returns the determinant of the matrix - float

1 matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
2                                1, 1,-1,-2,
3                                1,-1,-1, 2,
4                                1,-2, 1,-1 )
5 
6 print(matrix4_value.Determinant())

RLPy.RMatrix4.E(self, args)

Get the matrix element for the specified index(0~15).

Parameters

nEle[IN] Index of the matrix - int

Returns

Returns the matrix element specified by index - float

1 matrix4 = RLPy.RMatrix4()
2 matrix4.MakeIdentity()
3 print(matrix4.E(0))

RLPy.RMatrix4.FromEulerAngle(self, Oreder, rx, ry, rz)

Rotation matrix from Euler angle.

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

Returns

Return a new matrix from specified axis angle - RLPy.RMatrix4

1 # No example

RLPy.RMatrix4.GetColumn(self, nC)

Get the matrix element for the specified column.

Parameters

nC[IN] Index of the column in the matrix - int

Returns

Returns the column vector of the matrix - RLPy.RVector4

1 # No example

RLPy.RMatrix4.GetRow(self, nR)

Get the matrix element for the specified row.

Parameters

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

Returns

Returns the row vector of the matrix - RLPy.RVector4

1 matrix4 = RLPy.RMatrix4()
2 matrix4.MakeIdentity()
3 row0 = matrix4.GetRow(0)
4 
5 print(row0[0])
6 print(row0[1])
7 print(row0[2])
8 print(row0[3])

RLPy.RMatrix4.GetSR(self)

Get scale and rotation part of the matrix.

Returns

Return a 3x3 matrix - RLPy.RMatrix3

1 # No example

RLPy.RMatrix4.GetTranslate(self)

Get translate of the matrix.

Returns

Return a translate vector - RLPy.RVector3

1 # No example

RLPy.RMatrix4.InfNorm(self)

InfNorm of the matrix.

Returns

Return InfNorm - float

1 # No example

RLPy.RMatrix4.Inverse(self)

Inverse of the matrix.

Returns

Returns a new matrix containing this matrix's inverse - RLPy.RMatrix4

1 # No example

RLPy.RMatrix4.InverseTranspose(self)

Transpose of inverse.

Returns

Returns a new matrix - RLPy.RMatrix4

 1 matrix4_value = RLPy.RMatrix4( 1, 2, 1, 1,
 2                                1, 1,-1,-2,
 3                                1,-1,-1, 2,
 4                                1,-2, 1,-1 )
 5 
 6 matrix4_inverse_transpose = matrix4_value.InverseTranspose()
 7 col0_inverse_transpose = matrix4_inverse_transpose.GetColumn(0)
 8 
 9 print(col0_inverse_transpose[0] == row0_inverse[0])
10 print(col0_inverse_transpose[1] == row0_inverse[1])
11 print(col0_inverse_transpose[2] == row0_inverse[2])
12 print(col0_inverse_transpose[3] == row0_inverse[3])

RLPy.RMatrix4.M(self, args)

Get the matrix element for the specified row and column.

Parameters

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

Returns

Returns the matrix element specified by row and col - float

1 matrix4 = RLPy.RMatrix4()
2 matrix4.MakeIdentity()
3 print(matrix4.M(0,0)) #

RLPy.RMatrix4.MakeIdentity(self)

Sets the matrix to the identity.

Returns

this object - RLPy.RMatrix4

1 matrix4 = RLPy.RMatrix4()
2 matrix4.MakeIdentity()

RLPy.RMatrix4.MaxColumn(self)

Get maximum value of the column index in the matrix.

Returns

Return index of column of M containing maximum abs entry, or -1 if M = 0 - int

1 matrix4_column_value = RLPy.RMatrix4( 1, 2, 3,-5,
2                                       0, 0, 0, 0,
3                                       0, 0, 0, 0,
4                                       0, 0, 0, 0 )
5 
6 print(matrix4_column_value.MaxColumn()) # column:3 -> abs(-5)

RLPy.RMatrix4.MaxRow(self)

Get maximum value of the row index in the matrix.

Returns

Return index of row of M containing maximum abs entry, or -1 if M = 0 - int

1 matrix4_row_value = RLPy.RMatrix4( 1, 0, 0, 0,
2                                    2, 0, 0, 0,
3                                    3, 0, 0, 0,
4                                   -5, 0, 0, 0 )
5 
6 print(matrix4_value.MaxRow()) # Row:3 -> abs(-5)

RLPy.RMatrix4.OneNorm(self)

Norm of the matrix.

Returns

Return Norm - float

1 # No example

RLPy.RMatrix4.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

1 # No example

RLPy.RMatrix4.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

1 # No example

RLPy.RMatrix4.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

1 # No example

RLPy.RMatrix4.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

1 # No example

RLPy.RMatrix4.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

1 # No example

RLPy.RMatrix4.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

1 # No example

RLPy.RMatrix4.TimesTranspose(self, mM)

Multiplies of the transpose of the matrix.

Parameters

mM[IN] the matrix - RLPy.RMatrix4

Returns

Returns a new matrix. (this * M^T) - RLPy.RMatrix4

1 # No example

RLPy.RMatrix4.Transpose(self)

Transpose of the matrix.

Returns

Returns a new matrix containing this matrix's transpose - RLPy.RMatrix4

1 # No example

RLPy.RMatrix4.TransposeTimes(self, mM)

Multiplies of the transpose of the matrix.

Parameters

mM[IN] the matrix - RLPy.RMatrix4

Returns

Returns a new matrix. (this^T * mM) - RLPy.RMatrix4

1 # No example