Difference between revisions of "IC Python API:RLPy RTransform"
Chuck (RL) (Talk | contribs) (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...") |
Chuck (RL) (Talk | contribs) m |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{TOC}} | {{TOC}} | ||
{{Parent|IC_Python_API:RL_Python_Modules|Modules}} | {{Parent|IC_Python_API:RL_Python_Modules|Modules}} | ||
− | == | + | {{last_modified}} |
− | This class represent the transform data. | + | |
− | ==Operators== | + | == Description == |
− | + | ||
− | + | This class represent the object transform matrix data. This class provides access to RLPy's internal 4x4 matrix operators and related functions. | |
− | + | ||
− | + | See also: [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | |
− | + | ||
− | + | == Operators == | |
− | + | ||
− | + | === + === | |
− | + | ||
− | + | The "addition" operator. | |
− | + | ||
− | | | + | See Also: [[#+=|+=]] |
− | + | ||
− | + | <syntaxhighlight lang="python" line='line'> | |
− | + | 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> | ||
− | |||
− | |||
− | |||
− | + | === == === | |
− | + | ||
− | ==== | + | The "equal to" operator. |
− | + | ||
− | + | See Also: [[#!=|!=]] | |
− | + | ||
− | == | + | <syntaxhighlight lang="python" line='line'> |
− | <syntaxhighlight lang=" | + | transform_identity = RLPy.RTransform(RLPy.RTransform.IDENTITY) |
− | RLPy.RTransform. | + | print( transform_identity == transform_identity ) # true |
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
− | === | + | === != === |
− | + | ||
− | + | The "not equal to" operator. | |
− | + | ||
− | == | + | See Also: [[#==|==]] |
− | <syntaxhighlight lang=" | + | |
− | RLPy.RTransform. | + | <syntaxhighlight lang="python" line='line'> |
+ | transform_identity = RLPy.RTransform(RLPy.RTransform.IDENTITY) | ||
+ | print( transform_identity != transform_identity ) # false | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
− | === | + | === += === |
− | < | + | |
− | + | The "addition assignment" operator. | |
− | + | ||
− | === | + | See Also: [[#+|+]] |
− | + | ||
− | + | <syntaxhighlight lang="python" line='line'> | |
+ | 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> | </syntaxhighlight> | ||
− | + | ||
− | ==== | + | == Member Functions == |
− | + | ||
− | + | === D (self, args) === | |
− | + | ||
− | === | + | Get the determinate sign of this transform matrix. |
− | <syntaxhighlight lang=" | + | |
− | RLPy.RTransform. | + | ==== Returns ==== |
+ | :Returns the value of determinate sign - float | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | transform_identity = RLPy.RTransform(RLPy.RTransform.IDENTITY) | ||
+ | print(transform_identity.D()) # <Swig Object of type 'float *' at 0x0000027B8A2D1FC0> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
− | ====Returns==== | + | === S (self, args) === |
− | < | + | |
− | + | Get the Scale of this transform matrix. | |
− | + | ||
− | === | + | ==== Returns ==== |
− | + | :The value of scale in 3D vector - [[IC_Python_API:RLPy_RVector3|RVector3]] | |
− | RLPy.RTransform. | + | |
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | 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> | ||
− | + | ||
− | ====Returns==== | + | === U (self, args) === |
− | < | + | |
− | + | Get the stretch of this transform matrix. | |
− | + | ||
− | === | + | ==== Returns ==== |
− | + | :The value of stretch in quaternion - [[IC_Python_API:RLPy_RQuaternion|RQuaternion]] | |
− | RLPy.RTransform. | + | |
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | 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> | ||
− | + | ||
− | ====Returns==== | + | === R (self, args) === |
− | < | + | |
− | + | Get the rotation of this transform matrix. | |
− | + | ||
− | === | + | ==== Returns ==== |
− | + | :The value of rotation in quaternion - [[IC_Python_API:RLPy_RQuaternion|RQuaternion]] | |
− | RLPy.RTransform.R ( | + | |
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | 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> | ||
− | Get the | + | |
− | ====Returns==== | + | === T (self, args) === |
− | + | ||
− | < | + | Get the translation of this transform matrix. |
− | + | ||
− | === | + | ==== Returns ==== |
− | + | :The value of translation in 3D vector - [[IC_Python_API:RLPy_RVector3|RVector3]]. | |
− | RLPy.RTransform. | + | |
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | 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> | ||
− | + | ||
− | ==== | + | === AlmostEquel (self, kRts) === |
− | + | ||
− | + | Check if this and another transform is almost equal. | |
− | + | ||
− | === | + | ==== Parameters ==== |
− | <syntaxhighlight lang=" | + | :'''kRts''' [IN] The transform - [[IC_Python_API:RLPy_RTransform|RTransform]] |
− | RLPy.RTransform. | + | |
+ | ==== Returns ==== | ||
+ | :'''True''' if this and another transform is almost equal, else '''False''' - bool | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | 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 | + | |
− | ====Returns==== | + | === Inverse (self) === |
− | + | ||
− | + | Get the inverse of this transform. | |
− | + | ||
− | + | ==== Returns ==== | |
− | <syntaxhighlight lang=" | + | :The inverse of this transform - [[IC_Python_API:RLPy_RTransform|RTransform]] |
− | RLPy.RTransform. | + | |
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | 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> | ||
− | + | ||
− | === | + | === From (self, mMatrix) === |
− | + | ||
− | + | Set this transform from a 4x4 matrix. | |
− | + | ||
− | === | + | ==== Returns ==== |
− | <syntaxhighlight lang=" | + | :A transform composited from 4x4 matrix - [[IC_Python_API:RLPy_RTransform|RTransform]] |
− | RLPy.RTransform. | + | |
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | 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 | + | |
− | ====Returns==== | + | === Matrix (self) === |
− | < | + | |
− | </ | + | Get 4x4 matrix from this transform. |
− | ---- | + | |
− | === | + | ==== Returns ==== |
− | <syntaxhighlight lang=" | + | :A 4x4 matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] |
− | RLPy. | + | |
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | 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> | ||
+ | |||
+ | === IsIdentity (self) === | ||
+ | |||
+ | Check if this transform is equal to identity transform. Identity transform corresponds to "no transform" - the object is perfectly aligned with the world or parent axes and positioned at the origin. | ||
+ | |||
+ | ==== Returns ==== | ||
+ | :'''True''' if the transform is equal to identity transform, else '''False''' - bool | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | 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> | ||
+ | |||
+ | === Scale (self) === | ||
+ | |||
+ | Form a scale matrix from this transform. | ||
+ | |||
+ | ==== Returns ==== | ||
+ | :A 3x3 scale matrix from this transform - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | 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 from this transform. | ||
+ | |||
+ | ==== Returns ==== | ||
+ | :A 3x3 rotate matrix from this transform - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | 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 (self)|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 from this transform. | ||
+ | |||
+ | ==== Returns ==== | ||
+ | :A 3x3 matrix from this transform - [[IC_Python_API:RLPy_RMatrix3|RMatrix3]] | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | scale = RLPy.RVector3( 2, 2, 2 ) | ||
+ | rotate = RLPy.RMatrix3( -0,-0, 1, | ||
+ | -1,-0, 0, | ||
+ | 0,-1,-0 ) | ||
+ | matrix4 = RLPy.RMatrix4().FromRTS( [[#Rotate (self)|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> | ||
− | |||
− | |||
− | |||
− |
Latest revision as of 20:31, 13 April 2020
Contents
- 1 Description
- 2 Operators
- 3 Member Functions
- Main article: Modules.
- Last modified: 04/13/2020
Description
This class represent the object transform matrix data. This class provides access to RLPy's internal 4x4 matrix operators and related functions.
See also: RMatrix4
Operators
+
The "addition" operator.
See Also: +=
1 matrix_a = RLPy.RMatrix4( 2, 0, 0, 0,
2 0, 2, 0, 0,
3 0, 0, 2, 0,
4 1, 2, 3, 1 )
5 matrix_b = RLPy.RMatrix4( 3, 0, 0, 0,
6 0, 3, 0, 0,
7 0, 0, 3, 0,
8 2, 2, 2, 1 )
9 transform = RLPy.RTransform().From( matrix_a ) + RLPy.RTransform().From( matrix_b )
10
11 print( transform.Matrix().GetRow(0)[0] == 2*3 ) # true
12 print( transform.Matrix().GetRow(1)[1] == 2*3 ) # true
13 print( transform.Matrix().GetRow(2)[2] == 2*3 ) # true
14 print( transform.Matrix().GetRow(3)[0] == 1+2 ) # true
15 print( transform.Matrix().GetRow(3)[1] == 2+2 ) # true
16 print( transform.Matrix().GetRow(3)[2] == 3+2 ) # true
==
The "equal to" operator.
See Also: !=
1 transform_identity = RLPy.RTransform(RLPy.RTransform.IDENTITY)
2 print( transform_identity == transform_identity ) # true
!=
The "not equal to" operator.
See Also: ==
1 transform_identity = RLPy.RTransform(RLPy.RTransform.IDENTITY)
2 print( transform_identity != transform_identity ) # false
+=
The "addition assignment" operator.
See Also: +
1 matrix_a = RLPy.RMatrix4( 2, 0, 0, 0,
2 0, 2, 0, 0,
3 0, 0, 2, 0,
4 1, 2, 3, 1 )
5 matrix_b = RLPy.RMatrix4( 3, 0, 0, 0,
6 0, 3, 0, 0,
7 0, 0, 3, 0,
8 2, 2, 2, 1 )
9 transform = RLPy.RTransform().From( matrix_a )
10 transform += RLPy.RTransform().From( matrix_b )
11
12 print( transform.Matrix().GetRow(0)[0] == 2*3 ) # true
13 print( transform.Matrix().GetRow(1)[1] == 2*3 ) # true
14 print( transform.Matrix().GetRow(2)[2] == 2*3 ) # true
15 print( transform.Matrix().GetRow(3)[0] == 1+2 ) # true
16 print( transform.Matrix().GetRow(3)[1] == 2+2 ) # true
17 print( transform.Matrix().GetRow(3)[2] == 3+2 ) # true
Member Functions
D (self, args)
Get the determinate sign of this transform matrix.
Returns
- Returns the value of determinate sign - float
1 transform_identity = RLPy.RTransform(RLPy.RTransform.IDENTITY)
2 print(transform_identity.D()) # <Swig Object of type 'float *' at 0x0000027B8A2D1FC0>
S (self, args)
Get the Scale of this transform matrix.
Returns
- The value of scale in 3D vector - RVector3
1 d_determinate = 0
2 s_scale = RLPy.RVector3( RLPy.RVector3.ZERO )
3 u_stretch = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
4 r_rotate = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
5 t_translate = RLPy.RVector3( RLPy.RVector3.ZERO )
6
7 s_scale.x = 1
8 s_scale.y = 2
9 s_scale.z = 3
10 transform_data = RLPy.RTransform(d_determinate,s_scale,u_stretch,r_rotate,t_translate )
11
12 print( transform_data.S().x ) # 1
13 print( transform_data.S().y ) # 2
14 print( transform_data.S().z ) # 3
U (self, args)
Get the stretch of this transform matrix.
Returns
- The value of stretch in quaternion - RQuaternion
1 d_determinate = 0
2 s_scale = RLPy.RVector3( RLPy.RVector3.ZERO )
3 u_stretch = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
4 r_rotate = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
5 t_translate = RLPy.RVector3( RLPy.RVector3.ZERO )
6
7 u_stretch.x = 4
8 u_stretch.y = 5
9 u_stretch.z = 6
10 u_stretch.w = 7
11 transform_data = RLPy.RTransform(d_determinate,s_scale,u_stretch,r_rotate,t_translate )
12
13 print( transform_data.U().x ) # 4
14 print( transform_data.U().y ) # 5
15 print( transform_data.U().z ) # 6
16 print( transform_data.U().w ) # 7
R (self, args)
Get the rotation of this transform matrix.
Returns
- The value of rotation in quaternion - RQuaternion
1 d_determinate = 0
2 s_scale = RLPy.RVector3( RLPy.RVector3.ZERO )
3 u_stretch = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
4 r_rotate = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
5 t_translate = RLPy.RVector3( RLPy.RVector3.ZERO )
6
7 r_rotate.x = 8
8 r_rotate.y = 9
9 r_rotate.z = 10
10 r_rotate.w = 11
11 transform_data = RLPy.RTransform(d_determinate,s_scale,u_stretch,r_rotate,t_translate )
12
13 print( transform_data.R().x ) # 8
14 print( transform_data.R().y ) # 9
15 print( transform_data.R().z ) # 10
16 print( transform_data.R().w ) # 11
T (self, args)
Get the translation of this transform matrix.
Returns
- The value of translation in 3D vector - RVector3.
1 d_determinate = 0
2 s_scale = RLPy.RVector3( RLPy.RVector3.ZERO )
3 u_stretch = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
4 r_rotate = RLPy.RQuaternion( RLPy.RQuaternion.IDENTITY )
5 t_translate = RLPy.RVector3( RLPy.RVector3.ZERO )
6
7 t_translate.x = 12
8 t_translate.y = 13
9 t_translate.z = 14
10 transform_data = RLPy.RTransform(d_determinate,s_scale,u_stretch,r_rotate,t_translate )
11
12 print( transform_data.T().x ) # 12
13 print( transform_data.T().y ) # 13
14 print( transform_data.T().z ) # 14
AlmostEquel (self, kRts)
Check if this and another transform is almost equal.
Parameters
- kRts [IN] The transform - RTransform
Returns
- True if this and another transform is almost equal, else False - bool
1 matrix4 = RLPy.RMatrix4(-1, 0, 0, 0,
2 0,-1, 0, 0,
3 0, 0, 1, 0,
4 -1, 1, 1, 1 )
5
6 transform1 = RLPy.RTransform().From( matrix4 )
7 transform2 = RLPy.RTransform().From( matrix4 )
8
9 print( transform1.AlmostEquel( transform2 )) # True
Inverse (self)
Get the inverse of this transform.
Returns
- The inverse of this transform - RTransform
1 matrix4 = RLPy.RMatrix4(-1, 0, 0, 0,
2 0,-1, 0, 0,
3 0, 0, 1, 0,
4 -1, 1, 1, 1 )
5
6 transform = RLPy.RTransform().From( matrix4 )
7 print( transform.Matrix().GetRow(0)[0] )
8 print( transform.Matrix().GetRow(0)[1] )
From (self, mMatrix)
Set this transform from a 4x4 matrix.
Returns
- A transform composited from 4x4 matrix - RTransform
1 matrix4 = RLPy.RMatrix4(-1, 0, 0, 0,
2 0,-1, 0, 0,
3 0, 0, 1, 0,
4 -1, 1, 1, 1 )
5 transform = RLPy.RTransform().From( matrix4 )
6
7 print( transform.Matrix().GetRow(0)[0] )
8 print( transform.Matrix().GetRow(0)[1] )
Matrix (self)
Get 4x4 matrix from this transform.
Returns
- A 4x4 matrix - RMatrix4
1 matrix4 = RLPy.RMatrix4( 0,-1, 0, 0,
2 -1, 0, 0, 0,
3 0, 0,-1, 0,
4 1,-2, 1, 1 )
5 transform_data = RLPy.RTransform().From( matrix4 )
6 transform_data_matrix = transform_data.Matrix()
7
8 print( transform_data_matrix.GetRow(0)[0] )
9 print( transform_data_matrix.GetRow(0)[1] )
IsIdentity (self)
Check if this transform is equal to identity transform. Identity transform corresponds to "no transform" - the object is perfectly aligned with the world or parent axes and positioned at the origin.
Returns
- True if the transform is equal to identity transform, else False - bool
1 matrix4 = RLPy.RMatrix4( 1, 0, 0, 0,
2 0, 1, 0, 0,
3 0, 0, 1, 0,
4 0, 0, 0, 1 )
5 transform_data = RLPy.RTransform().From( matrix4 )
6 print( transform_data.IsIdentity() ) # True
Scale (self)
Form a scale matrix from this transform.
Returns
- A 3x3 scale matrix from this transform - RMatrix3
1 scale = RLPy.RVector3( 4, 5, 6 )
2 matrix4 = RLPy.RMatrix4().FromRTS( RLPy.RMatrix3.IDENTITY,
3 RLPy.RVector3.UNIT_XYZ,
4 scale )
5 transform_data = RLPy.RTransform().From( matrix4 )
6
7 print( transform_data.Scale().GetRow(0)[0] ) # 4
8 print( transform_data.Scale().GetRow(1)[1] ) # 5
9 print( transform_data.Scale().GetRow(2)[2] ) # 6
Rotate (self)
Form a rotate matrix from this transform.
Returns
- A 3x3 rotate matrix from this transform - RMatrix3
1 rotate = RLPy.RMatrix3( 0.8137977, -0.4698463, 0.3420202,
2 0.5438381, 0.8231729, -0.1631759,
3 -0.2048741, 0.3187958, 0.9254166 )
4 matrix4 = RLPy.RMatrix4().FromRTS( [[#Rotate (self)|Rotate]], RLPy.RVector3.UNIT_XYZ , RLPy.RVector3.UNIT_XYZ )
5 transform_data = RLPy.RTransform().From( matrix4 )
6
7 print( transform_data.Rotate().GetRow(0)[0] )
8 print( transform_data.Rotate().GetRow(0)[1] )
9 print( transform_data.Rotate().GetRow(0)[2] )
GetSR (self)
Form a 3x3 matrix with rotation and scale from this transform.
Returns
- A 3x3 matrix from this transform - RMatrix3
1 scale = RLPy.RVector3( 2, 2, 2 )
2 rotate = RLPy.RMatrix3( -0,-0, 1,
3 -1,-0, 0,
4 0,-1,-0 )
5 matrix4 = RLPy.RMatrix4().FromRTS( [[#Rotate (self)|Rotate]], RLPy.RVector3.UNIT_XYZ , scale )
6 transform_data = RLPy.RTransform().From( matrix4 )
7
8 print( transform_data.GetSR().GetRow(0)[0] ) # -0*2 = 0
9 print( transform_data.GetSR().GetRow(0)[1] ) # -0*2 = 0
10 print( transform_data.GetSR().GetRow(0)[2] ) # 1*2 = 2