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

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 transform data. ==Operators== This class supports the following op...")
 
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 transform data.
+
 
==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
+
See also: [https://wiki.reallusion.com/IC_Python_API:RLPy_RMatrix4 RLPy.RMatrix4()]
!Syntax
+
 
!Description
+
== Operators ==
!Example
+
 
|-
+
=== + ===
! scope="row"|__add__
+
 
|Addition
+
The "addition" operator.
|a + b
+
 
|Adds values on either side of the operator.
+
|a + b = 30
+
|-
+
! 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"|__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
+
|}
+
==Member Functions==
+
===AlmostEquel===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RTransform.AlmostEquel ( self, kRts )
+
matrix_a = RLPy.RMatrix4( 2, 0, 0, 0,
 +
                          0, 2, 0, 0,
 +
                          0, 0, 2, 0,
 +
                          1, 2, 3, 1 )
 +
matrix_b = RLPy.RMatrix4( 3, 0, 0, 0,
 +
                          0, 3, 0, 0,
 +
                          0, 0, 3, 0,
 +
                          2, 2, 2, 1 )
 +
transform =  RLPy.RTransform().From( matrix_a ) + RLPy.RTransform().From( matrix_b )
 +
 
 +
print( transform.Matrix().GetRow(0)[0] == 2*3 ) # true
 +
print( transform.Matrix().GetRow(1)[1] == 2*3 ) # true
 +
print( transform.Matrix().GetRow(2)[2] == 2*3 ) # true
 +
print( transform.Matrix().GetRow(3)[0] == 1+2 ) # true
 +
print( transform.Matrix().GetRow(3)[1] == 2+2 ) # true
 +
print( transform.Matrix().GetRow(3)[2] == 3+2 ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
Two transform are almost equal or not.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kRts''' [IN] The transform - RLPy.RTransform
+
=== == ===
</div>
+
 
====Returns====
+
The "equal to" operator.
<div style="margin-left: 2em;">Return true while two transform is almost equal - bool
+
 
</div>
+
-----
+
===D===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RTransform.D ( self, args )
+
transform_identity = RLPy.RTransform(RLPy.RTransform.IDENTITY)
 +
print( transform_identity == transform_identity ) # true
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=== != ===
 +
 +
The "not equal to" operator.
 +
 +
<syntaxhighlight lang="Python">
 +
transform_identity = RLPy.RTransform(RLPy.RTransform.IDENTITY)
 +
print( transform_identity != transform_identity ) # false
 +
</syntaxhighlight>
 +
 +
=== += ===
 +
 +
The "addition assignment" operator.
 +
 +
<syntaxhighlight lang="Python">
 +
matrix_a = RLPy.RMatrix4( 2, 0, 0, 0,
 +
                          0, 2, 0, 0,
 +
                          0, 0, 2, 0,
 +
                          1, 2, 3, 1 )
 +
matrix_b = RLPy.RMatrix4( 3, 0, 0, 0,
 +
                          0, 3, 0, 0,
 +
                          0, 0, 3, 0,
 +
                          2, 2, 2, 1 )
 +
transform = RLPy.RTransform().From( matrix_a )
 +
transform += RLPy.RTransform().From( matrix_b )
 +
 +
print( transform.Matrix().GetRow(0)[0] == 2*3 ) # true
 +
print( transform.Matrix().GetRow(1)[1] == 2*3 ) # true
 +
print( transform.Matrix().GetRow(2)[2] == 2*3 ) # true
 +
print( transform.Matrix().GetRow(3)[0] == 1+2 ) # true
 +
print( transform.Matrix().GetRow(3)[1] == 2+2 ) # true
 +
print( transform.Matrix().GetRow(3)[2] == 3+2 ) # true
 +
</syntaxhighlight>
 +
 +
== Member Functions ==
 +
 +
=== D (self, args) ===
 +
 
Get the determinate sign.
 
Get the determinate sign.
====Returns====
+
 
<div style="margin-left: 2em;">The value of determinate sign - float
+
==== Returns ====
</div>
+
:Returns the value of determinate sign - float
-----
+
 
===From===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RTransform.From ( self, mMatrix )
+
transform_identity = RLPy.RTransform(RLPy.RTransform.IDENTITY)
 +
print(transform_identity.D()) # <Swig Object of type 'float *' at 0x0000027B8A2D1FC0>
 
</syntaxhighlight>
 
</syntaxhighlight>
Set a transform from 4x4 matrix.
+
 
====Returns====
+
=== S (self, args) ===
<div style="margin-left: 2em;">A transform composited from 4x4 matrix - RLPy.RTransform
+
 
</div>
+
Get the Scale of a Transform matrix.
-----
+
 
===GetSR===
+
==== Returns ====
 +
:The value of scale in 3D vector - RLPy.RVector3
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RTransform.GetSR ( self )
+
d_determinate = 0
 +
s_scale      = RLPy.RVector3( RLPy.RVector3.ZERO )
 +
u_stretch    = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
 +
r_rotate      = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
 +
t_translate  = RLPy.RVector3( RLPy.RVector3.ZERO )
 +
 
 +
s_scale.x = 1
 +
s_scale.y = 2
 +
s_scale.z = 3
 +
transform_data = RLPy.RTransform(d_determinate,s_scale,u_stretch,r_rotate,t_translate )
 +
 
 +
print( transform_data.S().x ) # 1
 +
print( transform_data.S().y ) # 2
 +
print( transform_data.S().z ) # 3
 
</syntaxhighlight>
 
</syntaxhighlight>
Form a 3x3 matrix with rotation and scale.
+
 
====Returns====
+
=== U (self, args) ===
<div style="margin-left: 2em;">A 3x3 matrix from this transform - RLPy.RMatrix3
+
 
</div>
+
Get the stretch of Transform matrix.
-----
+
 
===Inverse===
+
==== Returns ====
 +
:The value of stretch in quaternion - RLPy.RQuaternion
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RTransform.Inverse ( self )
+
d_determinate = 0
 +
s_scale      = RLPy.RVector3( RLPy.RVector3.ZERO )
 +
u_stretch    = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
 +
r_rotate      = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
 +
t_translate  = RLPy.RVector3( RLPy.RVector3.ZERO )
 +
 
 +
u_stretch.x = 4
 +
u_stretch.y = 5
 +
u_stretch.z = 6
 +
u_stretch.w = 7
 +
transform_data = RLPy.RTransform(d_determinate,s_scale,u_stretch,r_rotate,t_translate )
 +
 
 +
print( transform_data.U().x ) # 4
 +
print( transform_data.U().y ) # 5
 +
print( transform_data.U().z ) # 6
 +
print( transform_data.U().w ) # 7
 
</syntaxhighlight>
 
</syntaxhighlight>
Inverse of the transform.
+
 
====Returns====
+
=== R (self, args) ===
<div style="margin-left: 2em;">A inversed transform - RLPy.RTransform
+
 
</div>
+
Get the rotation of Transform matrix.
-----
+
 
===IsIdentity===
+
==== Returns ====
 +
:The value of rotation in quaternion - RLPy.RQuaternion
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RTransform.IsIdentity ( self )
+
d_determinate = 0
 +
s_scale      = RLPy.RVector3( RLPy.RVector3.ZERO )
 +
u_stretch    = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
 +
r_rotate      = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
 +
t_translate  = RLPy.RVector3( RLPy.RVector3.ZERO )
 +
 
 +
r_rotate.x = 8
 +
r_rotate.y = 9
 +
r_rotate.z = 10
 +
r_rotate.w = 11
 +
transform_data = RLPy.RTransform(d_determinate,s_scale,u_stretch,r_rotate,t_translate )
 +
 
 +
print( transform_data.R().x ) # 8
 +
print( transform_data.R().y ) # 9
 +
print( transform_data.R().z ) # 10
 +
print( transform_data.R().w ) # 11
 
</syntaxhighlight>
 
</syntaxhighlight>
Is this transform identity.
+
 
====Returns====
+
=== T (self, args) ===
<div style="margin-left: 2em;">True if the transform is identity - bool
+
 
</div>
+
Get the translation of Transform matrix.
-----
+
 
===Matrix===
+
==== Returns ====
 +
:The value of translation in 3D vector - RLPy.RVector3.
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RTransform.Matrix ( self )
+
d_determinate = 0
 +
s_scale      = RLPy.RVector3( RLPy.RVector3.ZERO )
 +
u_stretch    = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
 +
r_rotate      = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
 +
t_translate  = RLPy.RVector3( RLPy.RVector3.ZERO ) 
 +
 
 +
t_translate.x = 12
 +
t_translate.y = 13
 +
t_translate.z = 14
 +
transform_data = RLPy.RTransform(d_determinate,s_scale,u_stretch,r_rotate,t_translate )
 +
 
 +
print( transform_data.T().x ) # 12
 +
print( transform_data.T().y ) # 13
 +
print( transform_data.T().z ) # 14
 
</syntaxhighlight>
 
</syntaxhighlight>
Form a 4x4 matrix.
+
 
====Returns====
+
=== AlmostEquel (self, kRts) ===
<div style="margin-left: 2em;">A 4x4 matrix - RLPy.RMatrix4
+
 
</div>
+
Two transform are almost equal or not.
-----
+
 
===R===
+
==== Parameters ====
 +
:kRts [IN] The transform - RLPy.RTransform
 +
 
 +
==== Returns ====
 +
:Return true while two transform is almost equal - bool
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RTransform.R ( self, args )
+
matrix4 = RLPy.RMatrix4(-1, 0, 0, 0,
 +
                        0,-1, 0, 0,
 +
                        0, 0, 1, 0,
 +
                        -1, 1, 1, 1 )
 +
                       
 +
transform1  = RLPy.RTransform().From( matrix4 )       
 +
transform2  = RLPy.RTransform().From( matrix4 )
 +
 
 +
print( transform1.AlmostEquel( transform2 )) # True
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the rotation.
+
 
====Returns====
+
=== Inverse (self) ===
<div style="margin-left: 2em;">The value of rotation in quaternion - RLPy.RQuaternion
+
 
</div>
+
Inverse of the transform..
-----
+
 
===Rotate===
+
==== Returns ====
 +
:A inversed transform - RLPy.RTransform
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RTransform.Rotate ( self )
+
matrix4 = RLPy.RMatrix4(-1, 0, 0, 0,
 +
                        0,-1, 0, 0,
 +
                        0, 0, 1, 0,
 +
                        -1, 1, 1, 1 )
 +
                       
 +
transform = RLPy.RTransform().From( matrix4 )
 +
print( transform.Matrix().GetRow(0)[0] )
 +
print( transform.Matrix().GetRow(0)[1] )
 
</syntaxhighlight>
 
</syntaxhighlight>
Form a rotate matrix.
+
 
====Returns====
+
=== From (self, mMatrix) ===
<div style="margin-left: 2em;">A 3x3 rotate matrix from this transform - RLPy.RMatrix3
+
 
</div>
+
Set a transform from 4x4 matrix.
-----
+
 
===S===
+
==== Returns ====
 +
:A transform composited from 4x4 matrix - RLPy.RTransform
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RTransform.S ( self, args )
+
matrix4 = RLPy.RMatrix4(-1, 0, 0, 0,
 +
                        0,-1, 0, 0,
 +
                        0, 0, 1, 0,
 +
                        -1, 1, 1, 1 )
 +
transform = RLPy.RTransform().From( matrix4 )
 +
 
 +
print( transform.Matrix().GetRow(0)[0] )
 +
print( transform.Matrix().GetRow(0)[1] )
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the scale.
+
 
====Returns====
+
=== Matrix (self) ===
<div style="margin-left: 2em;">The value of scale in 3D vector - RLPy.RVector3
+
 
</div>
+
Get 4x4 matrix from Transform.
-----
+
 
===Scale===
+
==== Returns ====
 +
:A 4x4 matrix - RLPy.RMatrix4
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RTransform.Scale ( self )
+
matrix4 = RLPy.RMatrix4( 0,-1, 0, 0,
 +
                        -1, 0, 0, 0,
 +
                        0, 0,-1, 0,
 +
                        1,-2, 1, 1 )
 +
transform_data = RLPy.RTransform().From( matrix4 )
 +
transform_data_matrix = transform_data.Matrix()
 +
 
 +
print( transform_data_matrix.GetRow(0)[0] )
 +
print( transform_data_matrix.GetRow(0)[1] )
 
</syntaxhighlight>
 
</syntaxhighlight>
Form a scale matrix.
+
 
====Returns====
+
=== IsIdentity (self) ===
<div style="margin-left: 2em;">A 3x3 scale matrix from this transform - RLPy.RMatrix3
+
 
</div>
+
Check if this transform is identity.
-----
+
 
===T===
+
==== Returns ====
 +
:True if the transform is identity - bool
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RTransform.T ( self, args )
+
matrix4 = RLPy.RMatrix4( 1, 0, 0, 0,
 +
                        0, 1, 0, 0,
 +
                        0, 0, 1, 0,
 +
                        0, 0, 0, 1 )
 +
transform_data = RLPy.RTransform().From( matrix4 )
 +
print( transform_data.IsIdentity() ) # True
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the translation.
+
 
====Returns====
+
=== Scale (self) ===
<div style="margin-left: 2em;">The value of translation in 3D vector - RLPy.RVector3
+
 
</div>
+
Form a scale matrix..
-----
+
 
===U===
+
==== Returns ====
 +
:A 3x3 scale matrix from this transform - RLPy.RMatrix3
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RTransform.U ( self, args )
+
scale = RLPy.RVector3( 4, 5, 6 )
 +
matrix4 = RLPy.RMatrix4().FromRTS( RLPy.RMatrix3.IDENTITY,
 +
                                      RLPy.RVector3.UNIT_XYZ,
 +
                                      scale )
 +
transform_data = RLPy.RTransform().From( matrix4 )
 +
 
 +
print( transform_data.Scale().GetRow(0)[0] ) # 4
 +
print( transform_data.Scale().GetRow(1)[1] ) # 5
 +
print( transform_data.Scale().GetRow(2)[2] ) # 6
 +
</syntaxhighlight>
 +
 
 +
=== Rotate (self) ===
 +
 
 +
Form a rotate matrix.
 +
 
 +
==== Returns ====
 +
:A 3x3 rotate matrix from this transform - RLPy.RMatrix3
 +
 
 +
<syntaxhighlight lang="Python">
 +
rotate = RLPy.RMatrix3( 0.8137977, -0.4698463,  0.3420202,
 +
                          0.5438381,  0.8231729, -0.1631759,
 +
                          -0.2048741,  0.3187958,  0.9254166 )
 +
matrix4  = RLPy.RMatrix4().FromRTS( rotate, RLPy.RVector3.UNIT_XYZ , RLPy.RVector3.UNIT_XYZ )
 +
    transform_data = RLPy.RTransform().From( matrix4 )
 +
 
 +
print( transform_data.Rotate().GetRow(0)[0] )
 +
print( transform_data.Rotate().GetRow(0)[1] )
 +
print( transform_data.Rotate().GetRow(0)[2] )
 +
</syntaxhighlight>
 +
 
 +
=== GetSR (self) ===
 +
 
 +
Form a 3x3 matrix with rotation and scale.
 +
 
 +
==== Returns ====
 +
:A 3x3 matrix from this transform - RLPy.RMatrix3
 +
 
 +
<syntaxhighlight lang="Python">
 +
scale  = RLPy.RVector3( 2, 2, 2 )
 +
rotate = RLPy.RMatrix3( -0,-0, 1,
 +
                        -1,-0, 0,
 +
                        0,-1,-0 )
 +
matrix4 = RLPy.RMatrix4().FromRTS( rotate, RLPy.RVector3.UNIT_XYZ , scale )
 +
transform_data = RLPy.RTransform().From( matrix4 )
 +
 
 +
print( transform_data.GetSR().GetRow(0)[0] ) # -0*2 = 0
 +
print( transform_data.GetSR().GetRow(0)[1] ) # -0*2 = 0
 +
print( transform_data.GetSR().GetRow(0)[2] ) #  1*2 = 2
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the stretch.
 
====Returns====
 
<div style="margin-left: 2em;">The value of stretch in quaternion - RLPy.RQuaternion
 
</div>
 

Revision as of 23:09, 25 February 2020

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.

See also: RLPy.RMatrix4()

Operators

+

The "addition" operator.

matrix_a = RLPy.RMatrix4( 2, 0, 0, 0,
                          0, 2, 0, 0,
                          0, 0, 2, 0,
                          1, 2, 3, 1 )
matrix_b = RLPy.RMatrix4( 3, 0, 0, 0,
                          0, 3, 0, 0,
                          0, 0, 3, 0,
                          2, 2, 2, 1 )
transform =  RLPy.RTransform().From( matrix_a ) + RLPy.RTransform().From( matrix_b )

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

==

The "equal to" operator.

transform_identity = RLPy.RTransform(RLPy.RTransform.IDENTITY)
print( transform_identity == transform_identity ) # true

!=

The "not equal to" operator.

transform_identity = RLPy.RTransform(RLPy.RTransform.IDENTITY)
print( transform_identity != transform_identity ) # false

+=

The "addition assignment" operator.

matrix_a = RLPy.RMatrix4( 2, 0, 0, 0,
                          0, 2, 0, 0,
                          0, 0, 2, 0,
                          1, 2, 3, 1 )
matrix_b = RLPy.RMatrix4( 3, 0, 0, 0,
                          0, 3, 0, 0,
                          0, 0, 3, 0,
                          2, 2, 2, 1 )
transform = RLPy.RTransform().From( matrix_a )
transform += RLPy.RTransform().From( matrix_b )

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

Member Functions

D (self, args)

Get the determinate sign.

Returns

Returns the value of determinate sign - float
transform_identity = RLPy.RTransform(RLPy.RTransform.IDENTITY)
print(transform_identity.D()) # <Swig Object of type 'float *' at 0x0000027B8A2D1FC0>

S (self, args)

Get the Scale of a Transform matrix.

Returns

The value of scale in 3D vector - RLPy.RVector3
d_determinate = 0
s_scale       = RLPy.RVector3( RLPy.RVector3.ZERO )
u_stretch     = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
r_rotate      = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
t_translate   = RLPy.RVector3( RLPy.RVector3.ZERO )

s_scale.x = 1
s_scale.y = 2
s_scale.z = 3
transform_data = RLPy.RTransform(d_determinate,s_scale,u_stretch,r_rotate,t_translate )

print( transform_data.S().x ) # 1
print( transform_data.S().y ) # 2
print( transform_data.S().z ) # 3

U (self, args)

Get the stretch of Transform matrix.

Returns

The value of stretch in quaternion - RLPy.RQuaternion
d_determinate = 0
s_scale       = RLPy.RVector3( RLPy.RVector3.ZERO )
u_stretch     = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
r_rotate      = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
t_translate   = RLPy.RVector3( RLPy.RVector3.ZERO )

u_stretch.x = 4
u_stretch.y = 5
u_stretch.z = 6
u_stretch.w = 7
transform_data = RLPy.RTransform(d_determinate,s_scale,u_stretch,r_rotate,t_translate )

print( transform_data.U().x ) # 4
print( transform_data.U().y ) # 5
print( transform_data.U().z ) # 6
print( transform_data.U().w ) # 7

R (self, args)

Get the rotation of Transform matrix.

Returns

The value of rotation in quaternion - RLPy.RQuaternion
d_determinate = 0
s_scale       = RLPy.RVector3( RLPy.RVector3.ZERO )
u_stretch     = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
r_rotate      = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
t_translate   = RLPy.RVector3( RLPy.RVector3.ZERO )

r_rotate.x = 8
r_rotate.y = 9
r_rotate.z = 10
r_rotate.w = 11
transform_data = RLPy.RTransform(d_determinate,s_scale,u_stretch,r_rotate,t_translate )

print( transform_data.R().x ) # 8
print( transform_data.R().y ) # 9
print( transform_data.R().z ) # 10
print( transform_data.R().w ) # 11

T (self, args)

Get the translation of Transform matrix.

Returns

The value of translation in 3D vector - RLPy.RVector3.
d_determinate = 0
s_scale       = RLPy.RVector3( RLPy.RVector3.ZERO )
u_stretch     = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
r_rotate      = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
t_translate   = RLPy.RVector3( RLPy.RVector3.ZERO )  

t_translate.x = 12
t_translate.y = 13
t_translate.z = 14
transform_data = RLPy.RTransform(d_determinate,s_scale,u_stretch,r_rotate,t_translate )

print( transform_data.T().x ) # 12
print( transform_data.T().y ) # 13
print( transform_data.T().z ) # 14

AlmostEquel (self, kRts)

Two transform are almost equal or not.

Parameters

kRts [IN] The transform - RLPy.RTransform

Returns

Return true while two transform is almost equal - bool
matrix4 = RLPy.RMatrix4(-1, 0, 0, 0,
                         0,-1, 0, 0,
                         0, 0, 1, 0,
                        -1, 1, 1, 1 )
                        
transform1  = RLPy.RTransform().From( matrix4 )        
transform2  = RLPy.RTransform().From( matrix4 ) 

print( transform1.AlmostEquel( transform2 )) # True

Inverse (self)

Inverse of the transform..

Returns

A inversed transform - RLPy.RTransform
matrix4 = RLPy.RMatrix4(-1, 0, 0, 0,
                         0,-1, 0, 0,
                         0, 0, 1, 0,
                        -1, 1, 1, 1 )
                        
transform = RLPy.RTransform().From( matrix4 )
print( transform.Matrix().GetRow(0)[0] ) 
print( transform.Matrix().GetRow(0)[1] )

From (self, mMatrix)

Set a transform from 4x4 matrix.

Returns

A transform composited from 4x4 matrix - RLPy.RTransform
matrix4 = RLPy.RMatrix4(-1, 0, 0, 0,
                         0,-1, 0, 0,
                         0, 0, 1, 0,
                        -1, 1, 1, 1 )
transform = RLPy.RTransform().From( matrix4 )

print( transform.Matrix().GetRow(0)[0] ) 
print( transform.Matrix().GetRow(0)[1] )

Matrix (self)

Get 4x4 matrix from Transform.

Returns

A 4x4 matrix - RLPy.RMatrix4
matrix4 = RLPy.RMatrix4( 0,-1, 0, 0, 
                        -1, 0, 0, 0,
                         0, 0,-1, 0,
                         1,-2, 1, 1 )
transform_data = RLPy.RTransform().From( matrix4 )
transform_data_matrix = transform_data.Matrix()

print( transform_data_matrix.GetRow(0)[0] ) 
print( transform_data_matrix.GetRow(0)[1] )

IsIdentity (self)

Check if this transform is identity.

Returns

True if the transform is identity - bool
matrix4 = RLPy.RMatrix4( 1, 0, 0, 0,
                         0, 1, 0, 0,
                         0, 0, 1, 0,
                         0, 0, 0, 1 )
transform_data = RLPy.RTransform().From( matrix4 )
print( transform_data.IsIdentity() ) # True

Scale (self)

Form a scale matrix..

Returns

A 3x3 scale matrix from this transform - RLPy.RMatrix3
scale = RLPy.RVector3( 4, 5, 6 )
matrix4 = RLPy.RMatrix4().FromRTS( RLPy.RMatrix3.IDENTITY,
                                       RLPy.RVector3.UNIT_XYZ,
                                       scale )
transform_data = RLPy.RTransform().From( matrix4 )

print( transform_data.Scale().GetRow(0)[0] ) # 4
print( transform_data.Scale().GetRow(1)[1] ) # 5
print( transform_data.Scale().GetRow(2)[2] ) # 6

Rotate (self)

Form a rotate matrix.

Returns

A 3x3 rotate matrix from this transform - RLPy.RMatrix3
rotate = RLPy.RMatrix3( 0.8137977, -0.4698463,  0.3420202,
                           0.5438381,  0.8231729, -0.1631759,
                          -0.2048741,  0.3187958,  0.9254166 )
matrix4  = RLPy.RMatrix4().FromRTS( rotate, RLPy.RVector3.UNIT_XYZ , RLPy.RVector3.UNIT_XYZ )
    transform_data = RLPy.RTransform().From( matrix4 )

print( transform_data.Rotate().GetRow(0)[0] )
print( transform_data.Rotate().GetRow(0)[1] )
print( transform_data.Rotate().GetRow(0)[2] )

GetSR (self)

Form a 3x3 matrix with rotation and scale.

Returns

A 3x3 matrix from this transform - RLPy.RMatrix3
scale  = RLPy.RVector3( 2, 2, 2 )
rotate = RLPy.RMatrix3( -0,-0, 1,
                        -1,-0, 0,
                        0,-1,-0 )
matrix4 = RLPy.RMatrix4().FromRTS( rotate, RLPy.RVector3.UNIT_XYZ , scale )
transform_data = RLPy.RTransform().From( matrix4 )

print( transform_data.GetSR().GetRow(0)[0] ) # -0*2 = 0
print( transform_data.GetSR().GetRow(0)[1] ) # -0*2 = 0
print( transform_data.GetSR().GetRow(0)[2] ) #  1*2 = 2