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

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 quaternion in math. Quaternions represent orientations as a single...")
 
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 quaternion in math.
+
 
Quaternions represent orientations as a single rotation, just as
+
== Detailed Description ==
rectangular co- ordinates represent position as a single vector.
+
 
==Operators==
+
This class represents a quaternion in mathematics. Quaternions represetn directions as a single rotation, just as rectangular coordinates represent positions as single vector. RQuaternion also defines some constants that can be used directly:
This class supports the following operators:
+
 
 
{| class="wikitable"
 
{| class="wikitable"
!Member
+
!Constant
!Operation
+
!Syntax
+
 
!Description
 
!Description
!Example
 
|-
 
! 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__
+
|RQuaternion.IDENTITY
|Equality
+
|4D zero vector: (0, 0, 0, 1)
|a == b
+
|If the values of two operands are equal, then the condition becomes true.
+
|(a == b) is not true.
+
 
|-
 
|-
! scope="row"|__ne__
+
|RQuaternion.ZERO
|Difference
+
|4D x unit vector: (0, 0, 0, 0)
|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==
+
 
===AlmostEquel===
+
== Constructor & Destructor ==
 +
 
 +
=== __init__( self ) ===
 +
 
 +
The constructor. Initialize a new RQuaternion object without initialization.
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.AlmostEquel ( self, qQ )
+
q = RLPy.RQuaternion()
 +
 
 +
print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # random values
 
</syntaxhighlight>
 
</syntaxhighlight>
Equality test.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''qQ''' [IN] The quaternion - RLPy.RQuaternion
+
=== __init__( self, vV ) ===
</div>
+
 
====Returns====
+
The constructor. Initialize a new RQuaternion object from a 4D vector RVector4.
<div style="margin-left: 2em;">True if each of the elements of the quaternion is almost equal to the corresponding element in the second matrix - bool
+
 
</div>
+
-----
+
===Conjugate===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.Conjugate ( self )
+
v = RLPy.RVector4(1, 2, 3, 4)
 +
q = RLPy.RQuaternion(v)
 +
 
 +
print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # 1.0, 2.0, 3.0, 4.0
 
</syntaxhighlight>
 
</syntaxhighlight>
Conjugate this quaternion.
+
 
====Returns====
+
==== Parameters ====
<div style="margin-left: 2em;">The conjugated quaternion. The result is a quaternion whose x, y, and z values have been negated - RLPy.RQuaternion
+
:'''vV''' [IN]  a 4D vector - RLPy.RVector4
</div>
+
 
-----
+
=== __init__( self, qQ ) ===
===Dot===
+
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.Dot ( self, qQ )
+
v = RLPy.RVector4(1, 2, 3, 4)
 +
q = RLPy.RQuaternion(v)
 +
p = RLPy.RQuaternion(q)
 +
 
 +
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 1.0, 2.0, 3.0, 4.0
 
</syntaxhighlight>
 
</syntaxhighlight>
Calculate dot production of the two quaternion.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''qQ''' [IN] The quaternion - RLPy.RQuaternion
+
==== Parameters ====
</div>
+
:'''qQ''' [IN] a quaternion - RLPy.RQuaternion
====Returns====
+
 
<div style="margin-left: 2em;">The value of the dot production - float
+
=== __init__( self, kAxis, fAngle ) ===
</div>
+
 
-----
+
The constructor. Initialize a new RQuaternion object with Axis-angle. The axis is specified by a 3D vector, and the angle is specified by a float value.
===FromAxisAngle===
+
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.FromAxisAngle ( self, rkAxis, fAngle )
+
v = RLPy.RVector3(0, 0, 1)
 +
q = RLPy.RQuaternion(v, math.pi/2)
 +
 
 +
print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w))
 +
    # 0.0, 0.0, 0.7071067094802856, 0.7071067690849304
 
</syntaxhighlight>
 
</syntaxhighlight>
Quaternion from a axis angle.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''rkAxis''' [IN] axis vector - RLPy.RVector3
+
==== Parameters ====
 +
:'''kAxis''' [IN] the rotation axis - RLPy.RVector3
 +
:'''fAngle''' [IN] the rotation angle - float
 +
 
 +
=== __init__( self, kRot ) ===
 +
 
 +
The constructor. Initialize a new RQuaternion object with a 3x3 rotation matrix.
 +
 
 +
==== Parameters ====
 +
:'''kRot''' [IN]  a 3x3 rotation matrix - RLPy.RMatrix3
  
'''fAngle''' [IN] angle in radians - float
 
</div>
 
====Returns====
 
<div style="margin-left: 2em;">Return a new quaternion from a axis angle - RLPy.RQuaternion
 
</div>
 
-----
 
===FromRotationMatrix===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.FromRotationMatrix ( self, rkRot )
+
v = RLPy.RVector3(0, 0, 1)
 +
m = RLPy.RMatrix3(v, math.pi/2)
 +
q = RLPy.RQuaternion(m)
 +
 
 +
print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w))
 +
    # 0.0, 0.0, 0.7071067690849304, 0.7071067690849304
 
</syntaxhighlight>
 
</syntaxhighlight>
Quaternion from a rotation matrix.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''rkRot''' [IN] Rotation matrix - RLPy.RMatrix3
+
== Operator ==
</div>
+
 
====Returns====
+
=== = ===
<div style="margin-left: 2em;">Return a new quaternion from a rotation matrix - RLPy.RQuaternion
+
 
</div>
+
The "equal to" operator.
-----
+
 
===Inverse===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.Inverse ( self )
+
q = RLPy.RQuaternion()
 +
p = q
 +
if q == p:                        # True
 +
    print("equal")
 
</syntaxhighlight>
 
</syntaxhighlight>
Inverse this quaternion.
+
 
====Returns====
+
=== != ===
<div style="margin-left: 2em;">The inversed quaternion - RLPy.RQuaternion
+
 
</div>
+
The "not equal to" operator.
-----
+
 
===Multiply===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.Multiply ( self, qQ )
+
a = RLPy.RVector4(1, 2, 3, 4)
 +
q = RLPy.RQuaternion(a)
 +
b = RLPy.RVector4(2, 2, 3, 4)
 +
p = RLPy.RQuaternion(b)
 +
if a != b:                        #True
 +
    print("not equal")
 
</syntaxhighlight>
 
</syntaxhighlight>
Multiply quaternion.
+
 
====Returns====
+
=== < ===
<div style="margin-left: 2em;">The multiplied quaternion - RLPy.RQuaternion
+
 
</div>
+
The "less than" operator. Similar to string comparison: Returns '''True''' upon the first match that is less than and '''False''' if it is greater than.  If the current comparison is equal, continue onto the next element.  If all elements are equal then return '''False'''.
-----
+
 
===MultiplyEqual===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.MultiplyEqual ( self, qQ )
+
a = RLPy.RVector4(0, 1, 5, 2)
 +
b = RLPy.RVector4(0, 1, 5, 3)
 +
c = RLPy.RVector4(1, 0, 1, 0)
 +
d = RLPy.RVector4(0, 1, 5, 2)
 +
 
 +
p = RLPy.RQuaternion(a)
 +
q = RLPy.RQuaternion(b)
 +
r = RLPy.RQuaternion(c)
 +
s = RLPy.RQuaternion(d)
 +
 
 +
if p< q:                      #True
 +
    print('p< q')
 +
if q< r:                      #True
 +
    print('q< r')
 +
if p< s:                      #False
 +
    print('p< s')
 
</syntaxhighlight>
 
</syntaxhighlight>
Multiply quaternion.
+
 
====Returns====
+
=== > ===
<div style="margin-left: 2em;">The multiplied quaternion - RLPy.RQuaternion
+
 
</div>
+
The "greater than" operator. Similar to string comparison: Returns '''True''' upon the first match that is greater than and '''False''' if it is less than.  If the current comparison is equal, continue onto the next element.  If all elements are equal then return '''False'''.
-----
+
 
===Normalize===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.Normalize ( self )
+
a = RLPy.RVector4(0, 1, 5, 2)
 +
b = RLPy.RVector4(0, 1, 5, 3)
 +
c = RLPy.RVector4(1, 0, 1, 0)
 +
d = RLPy.RVector4(0, 1, 5, 2)
 +
 
 +
p = RLPy.RQuaternion(a)
 +
q = RLPy.RQuaternion(b)
 +
r = RLPy.RQuaternion(c)
 +
s = RLPy.RQuaternion(d)
 +
 
 +
if q >p:                      #True
 +
    print('q >p')
 +
if r >q:                      #True
 +
    print('r >q')
 +
if p >s:                      #False
 +
    print('p >s')
 
</syntaxhighlight>
 
</syntaxhighlight>
Normalizes this quaternion.
+
 
====Returns====
+
=== <= ===
<div style="margin-left: 2em;">The normalized quaternion - RLPy.RQuaternion
+
 
</div>
+
The "less than or equal" operator. Similar to string comparison: Returns '''True''' upon the first match that is less than and '''False''' if it is greater than.  If the current comparison is equal, continue onto the next element.  If all elements are equal then return '''True'''.
-----
+
 
===Rotate180===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.Rotate180 ( self )
+
a = RLPy.RVector4(0, 1, 5, 2)
 +
b = RLPy.RVector4(0, 1, 5, 3)
 +
c = RLPy.RVector4(1, 0, 1, 0)
 +
d = RLPy.RVector4(0, 1, 5, 2)
 +
 
 +
p = RLPy.RQuaternion(a)
 +
q = RLPy.RQuaternion(b)
 +
r = RLPy.RQuaternion(c)
 +
s = RLPy.RQuaternion(d)
 +
 
 +
if p<= q:                      #True
 +
    print('p<= q')
 +
if q<= r:                      #True
 +
    print('q<= r')
 +
if p<= s:                      #True
 +
    print('p<= s')
 
</syntaxhighlight>
 
</syntaxhighlight>
Rotate 180 degree of this quaternion.
+
 
====Returns====
+
=== >= ===
<div style="margin-left: 2em;">The rotated quaternion - RLPy.RQuaternion
+
 
</div>
+
The "greater than or equal" operator. Similar to string comparison: Returns '''True''' upon the first match that is greater than and '''False''' if it is less than.  If the current comparison is equal, continue onto the next element.  If all elements are equal then return '''True'''.
-----
+
 
===SetW===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.SetW ( self, tW )
+
a = RLPy.RVector4(0, 1, 5, 2)
 +
b = RLPy.RVector4(0, 1, 5, 3)
 +
c = RLPy.RVector4(1, 0, 1, 0)
 +
d = RLPy.RVector4(0, 1, 5, 2)
 +
 
 +
p = RLPy.RQuaternion(a)
 +
q = RLPy.RQuaternion(b)
 +
r = RLPy.RQuaternion(c)
 +
s = RLPy.RQuaternion(d)
 +
 
 +
if q >= p:                      #True
 +
    print('q >= p')
 +
if r >= q:                      #True
 +
    print('r >= q')
 +
if p >= s:                      #True
 +
    print('p >= s')
 
</syntaxhighlight>
 
</syntaxhighlight>
Set the w value of the quaternion.
+
 
====Returns====
+
=== + ===
<div style="margin-left: 2em;">The value of the w - RLPy.void
+
 
</div>
+
The "addition" operator. Perform quaternion addition.
-----
+
 
===SetX===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.SetX ( self, tX )
+
a = RLPy.RVector4(0, 1, 2, 3)
 +
b = RLPy.RVector4(1, 2, 3, 4)
 +
p = RLPy.RQuaternion(a)
 +
q = RLPy.RQuaternion(b)
 +
r = p + q
 +
 
 +
print(str(r.x) + ', ' + str(r.y) + ', ' + str(r.z) + ', ' + str(r.w))  # 1.0, 3.0, 5.0, 7.0
 
</syntaxhighlight>
 
</syntaxhighlight>
Set the x value of the quaternion.
+
 
====Returns====
+
=== - ===
<div style="margin-left: 2em;">The value of the x - RLPy.void
+
 
</div>
+
The "subtraction" operator. Perform quaternion subtraction.
-----
+
 
===SetY===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.SetY ( self, tY )
+
a = RLPy.RVector4(0, 1, 2, 3)
 +
b = RLPy.RVector4(3, 2, 1, 0)
 +
p = RLPy.RQuaternion(a)
 +
q = RLPy.RQuaternion(b)
 +
r = q - p
 +
 
 +
print(str(r.x) + ', ' + str(r.y) + ', ' + str(r.z) + ', ' + str(r.w)) # 3.0, 1.0, -1.0, -3.0
 
</syntaxhighlight>
 
</syntaxhighlight>
Set the y value of the quaternion.
+
 
====Returns====
+
=== * ===
<div style="margin-left: 2em;">The value of the y - RLPy.void
+
 
</div>
+
The "multiplication" operator. Perform a scalar multiplication when the second operand is an integer or float. If the second operand is another quaternion, then the respective elements are multiplied.
-----
+
 
===SetZ===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.SetZ ( self, tZ )
+
a = RLPy.RVector4(1, 2, 3, 4)
 +
p = RLPy.RQuaternion(a)
 +
q = p * 2
 +
r = p * p
 +
 
 +
print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # 2.0, 4.0, 6.0, 8.0
 +
print(str(r.x) + ', ' + str(r.y) + ', ' + str(r.z) + ', ' + str(r.w)) # 1.0, 4.0, 9.0, 16.0
 
</syntaxhighlight>
 
</syntaxhighlight>
Set the z value of the quaternion.
+
 
====Returns====
+
=== / ===
<div style="margin-left: 2em;">The value of the z - RLPy.void
+
 
</div>
+
The "division" operator. Perform a scalar division with a int or float value which the second operand is limited to.
-----
+
 
===ToAxisAngle===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.ToAxisAngle ( self, rkAxis, rfAngle )
+
a = RLPy.RVector4(1, 2, 3, 4)
 +
p = RLPy.RQuaternion(a)
 +
q = p / 2
 +
 
 +
print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # 0.5, 1.0, 1.5, 2.0
 
</syntaxhighlight>
 
</syntaxhighlight>
Convert quaternion to axis angle.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''rkAxis''' [OUT] Returns axis vector - RLPy.RVector3
+
=== - ===
 +
 
 +
The "unary minus" operator. Inverse the sign of each element.
  
'''fAngle''' [OUT] Returns angle in radians.
 
</div>
 
-----
 
===ToRotationMatrix===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.ToRotationMatrix ( self )
+
a = RLPy.RVector4(1, 2, 3, 4)
 +
p = RLPy.RQuaternion(a)
 +
q = -p
 +
 
 +
print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # -1.0, -2.0, -3.0, -4.0
 
</syntaxhighlight>
 
</syntaxhighlight>
Convert quaternion to a rotation matrix.
+
 
====Returns====
+
=== + ====
<div style="margin-left: 2em;">Return a new 3x3 matrix from a quaternion - RLPy.RMatrix3
+
 
</div>
+
The "addition assignment" operator.
-----
+
 
===W===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.W ( self, args )
+
a = RLPy.RVector4(0, 1, 2, 3)
 +
b = RLPy.RVector4(1, 2, 3, 4)
 +
p = RLPy.RQuaternion(a)
 +
q = RLPy.RQuaternion(b)
 +
p += q
 +
 
 +
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 1.0, 3.0, 5.0, 7.0
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the w value of the quaternion.
+
 
====Returns====
+
=== - ====
<div style="margin-left: 2em;">The value of the w - float
+
 
</div>
+
The "subtraction assignment" operator.
-----
+
 
===X===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.X ( self, args )
+
a = RLPy.RVector4(0, 1, 4, 5)
 +
b = RLPy.RVector4(1, 2, 3, 1)
 +
p = RLPy.RQuaternion(a)
 +
q = RLPy.RQuaternion(b)
 +
p -= q
 +
 
 +
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # -1.0, -1.0, 1.0, 4.0
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the x value of the quaternion.
+
 
====Returns====
+
=== *= ===
<div style="margin-left: 2em;">The value of the x - float
+
 
</div>
+
The "multiplication assignment" operator. For calculation method, refer to the '''*''' operator.
-----
+
 
===Y===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.Y ( self, args )
+
a = RLPy.RVector4(1, 2, 3, 4)
 +
p = RLPy.RQuaternion(a)
 +
p *= 2
 +
 
 +
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 2.0, 4.0, 6.0, 8.0
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the y value of the quaternion.
+
 
====Returns====
+
=== /= ===
<div style="margin-left: 2em;">The value of the y - float
+
 
</div>
+
The "division assignment" operator. For calculation method, refer to the '''/''' operator.
-----
+
 
===Z===
+
<syntaxhighlight lang="Python">
 +
a = RLPy.RVector4(1, 2, 3, 4)
 +
p = RLPy.RQuaternion(a)
 +
p /= 2
 +
 
 +
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 0.5, 1.0, 1.5, 2.0
 +
</syntaxhighlight>
 +
 
 +
== Member Functions ==
 +
 
 +
=== AlmostEqual( self, qQ ) ===
 +
 
 +
<syntaxhighlight lang="Python">
 +
a = RLPy.RVector4(1, 2, 3, 4)
 +
p = RLPy.RQuaternion(a)
 +
q = RLPy.RQuaternion(a)
 +
r = RLPy.RQuaternion(a)
 +
 
 +
q.w = 4.000000001
 +
r.w = 4.00001
 +
 
 +
if p.AlmostEqual(q):              #True
 +
    print("p ≈ q")
 +
if q.AlmostEqual(r):              #False
 +
    print("p ≈ r")
 +
</syntaxhighlight>
 +
 
 +
==== Parameters ====
 +
:'''qQ''' [IN] The target quaternion to check for equivalence - RLPy.RQuaternion
 +
 
 +
==== Returns ====
 +
:True if the two quaternions are almost the same - bool
 +
 
 +
=== Conjugate( self ) ===
 +
 
 +
Conjugate this quaternion.
 +
 
 +
<syntaxhighlight lang="Python">
 +
a = RLPy.RVector4(1, 2, 3, 4)
 +
p = RLPy.RQuaternion(a)
 +
q = p.Conjugate()
 +
 
 +
print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # -1.0, -2.0, -3.0, 4.0
 +
</syntaxhighlight>
 +
 
 +
==== Returns ====
 +
:Returns the conjugated quaternion. The result is a quaternion whose x, y, and z values have been negated - RLPy.RQuaternion
 +
 
 +
=== Dot( self, qQ ) ===
 +
 
 +
Calculate dot product of the two quaternions.
 +
 
 +
==== Parameters ====
 +
:'''qQ''' [IN] The quaternion to compute dot product - RLPy.RQuaternion
 +
 
 +
==== Returns ====
 +
:Returns the value of the dot product - float
 +
 
 +
<syntaxhighlight lang="Python">
 +
a = RLPy.RVector4(1, 2, 3, 4)
 +
b = RLPy.RVector4(1, 2, 3, 0)
 +
p = RLPy.RQuaternion(a)
 +
q = RLPy.RQuaternion(b)
 +
f = p.Dot(q)
 +
 
 +
print(f)    # 14.0
 +
</syntaxhighlight>
 +
 
 +
=== FromAxisAngle( self, rkAxis, fAngle ) ===
 +
 
 +
Quaternion from axis angle.
 +
 
 +
==== Parameters ====
 +
:'''rkAxis''' [IN] axis vector - RLPy.RVector3
 +
:'''fAngle''' [IN] angle in radians - float
 +
 
 +
==== Returns ====
 +
:Return a new quaternion from a axis angle - RLPy.RQuaternion
 +
 
 +
<syntaxhighlight lang="Python">
 +
p = RLPy.RQuaternion()
 +
v = RLPy.RVector3(0, 0, 1)
 +
p.FromAxisAngle(v, math.pi/2)
 +
 
 +
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 0.0, 0.0, 0.7071067094802856, 0.7071067690849304
 +
</syntaxhighlight>
 +
 
 +
=== FromRotationMatrix( self, rkRot ) ===
 +
 
 +
Quaternion from a rotation matrix.
 +
 
 +
==== Parameters ====
 +
:rkRot [IN] Rotation matrix - RLPy.RMatrix3
 +
 
 +
==== Returns ====
 +
:Return a new quaternion from a rotation matrix - RLPy.RQuaternion
 +
 
 +
<syntaxhighlight lang="Python">
 +
v = RLPy.RVector3(0, 0, 1)
 +
m = RLPy.RMatrix3(v, math.pi/2)
 +
p = RLPy.RQuaternion()
 +
p.FromRotationMatrix(m)
 +
 
 +
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 0.0, 0.0, 0.7071067690849304, 0.7071067690849304
 +
</syntaxhighlight>
 +
 
 +
=== Inverse( self, rkRot ) ===
 +
 
 +
Obtain the inverse of this quaternion.
 +
 
 +
==== Returns ====
 +
:The inversed quaternion - RLPy.RQuaternion
 +
 
 +
<syntaxhighlight lang="Python">
 +
a = RLPy.RVector4(1, 1, 1, 1)
 +
p = RLPy.RQuaternion(a)
 +
q = p.Inverse()
 +
 
 +
print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # -0.25, -0.25, -0.25, 0.25
 +
</syntaxhighlight>
 +
 
 +
=== Multiply( self, qQ ) ===
 +
 
 +
Multiply by another quaternion.
 +
 
 +
==== Parameters ====
 +
:'''qQ''' [IN] The quaternion to multiply - RLPy.RQuaternion
 +
 
 +
==== Returns ====
 +
:Returns the multiplied quaternion - RLPy.RQuaternion
 +
 
 +
<syntaxhighlight lang="Python">
 +
a = RLPy.RVector4(1, 2, 3, 4)
 +
b = RLPy.RVector4(1, 2, 2, 1)
 +
 
 +
p = RLPy.RQuaternion(a)
 +
q = RLPy.RQuaternion(b)
 +
r = p.Multiply(q)
 +
 
 +
print(str(r.x) + ', ' + str(r.y) + ', ' + str(r.z) + ', ' + str(r.w)) # 3.0, 11.0, 11.0, -7.0
 +
</syntaxhighlight>
 +
 
 +
=== MultiplyEqual( self, qQ ) ===
 +
 
 +
==== Parameters ====
 +
:'''qQ''' [IN] The quaternion to multiply - RLPy.RQuaternion
 +
 
 +
==== Returns ====
 +
:Returns the multiplied quaternion - RLPy.RQuaternion
 +
 
 +
<syntaxhighlight lang="Python">
 +
a = RLPy.RVector4(1, 2, 3, 4)
 +
b = RLPy.RVector4(1, 2, 2, 1)
 +
 
 +
p = RLPy.RQuaternion(a)
 +
q = RLPy.RQuaternion(b)
 +
r = p.MultiplyEqual(q)
 +
 
 +
print(str(r.x) + ', ' + str(r.y) + ', ' + str(r.z) + ', ' + str(r.w)) # 3.0, 11.0, 11.0, -7.0
 +
</syntaxhighlight>
 +
 
 +
=== Normalize( self ) ===
 +
 
 +
Normalizes this quaternion.
 +
 
 +
==== Returns ====
 +
:Returns the normalized quaternion - RLPy.RQuaternion
 +
 
 +
<syntaxhighlight lang="Python">
 +
a = RLPy.RVector4(1, 1, 1, 1)
 +
p = RLPy.RQuaternion(a)
 +
q = p.Normalize()
 +
 
 +
print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w))
 +
    # 0.4999999701976776, 0.4999999701976776, 0.4999999701976776, 0.4999999701976776
 +
</syntaxhighlight>
 +
 
 +
=== Rotate180( self ) ===
 +
 
 +
Rotate 180 degree of this quaternion.
 +
 
 +
==== Returns ====
 +
:Returns the rotated quaternion - RLPy.RQuaternion
 +
 
 +
<syntaxhighlight lang="Python">
 +
a = RLPy.RVector4(1, 1, 1, 1)
 +
p = RLPy.RQuaternion(a)
 +
q = p.Normalize()
 +
 
 +
print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w))
 +
  #0.4999999701976776, 0.4999999701976776, 0.4999999701976776, 0.4999999701976776
 +
</syntaxhighlight>
 +
 
 +
=== SetX( self, tX ) ===
 +
 
 +
Set the value of the x-axis.
 +
 
 +
==== Parameters ====
 +
:'''tX''' [IN] the value of the x-axis - float
 +
 
 +
<syntaxhighlight lang="Python">
 +
a = RLPy.RVector4(1, 2, 3, 4)
 +
p = RLPy.RQuaternion(a)
 +
p.SetX(9)
 +
 
 +
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 9.0, 2.0, 3.0, 4.0
 +
</syntaxhighlight>
 +
 
 +
=== SetY( self, tY ) ===
 +
 
 +
Set the value of the y-axis.
 +
 
 +
==== Parameters ====
 +
:'''tY''' [IN] the value of the y-axis - float
 +
 
 +
<syntaxhighlight lang="Python">
 +
a = RLPy.RVector4(1, 2, 3, 4)
 +
p = RLPy.RQuaternion(a)
 +
p.SetY(9)
 +
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w))
 +
    #1.0, 9.0, 3.0, 4.0
 +
</syntaxhighlight>
 +
 
 +
=== SetZ( self, tZ ) ===
 +
 
 +
Set the value of the z-axis.
 +
 
 +
==== Parameters ====
 +
:'''tZ''' [IN] the value of the z-axis - float
 +
 
 +
<syntaxhighlight lang="Python">
 +
a = RLPy.RVector4(1, 2, 3, 4)
 +
p = RLPy.RQuaternion(a)
 +
p.SetZ(9)
 +
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w))
 +
    #1.0, 2.0, 9.0, 4.0
 +
</syntaxhighlight>
 +
 
 +
=== SetW( self, tW ) ===
 +
 
 +
Set the value of the w-axis.
 +
 
 +
==== Parameters ====
 +
:'''tW''' [IN] the value of the w-axis - float
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RQuaternion.Z ( self, args )
+
a = RLPy.RVector4(1, 2, 3, 4)
 +
p = RLPy.RQuaternion(a)
 +
p.SetW(9)
 +
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w))
 +
    #1.0, 2.0, 3.0, 9.0
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the z value of the quaternion.
 
====Returns====
 
<div style="margin-left: 2em;">The value of the z - float
 
</div>
 

Revision as of 00:11, 25 February 2020

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

Detailed Description

This class represents a quaternion in mathematics. Quaternions represetn directions as a single rotation, just as rectangular coordinates represent positions as single vector. RQuaternion also defines some constants that can be used directly:

Constant Description
RQuaternion.IDENTITY 4D zero vector: (0, 0, 0, 1)
RQuaternion.ZERO 4D x unit vector: (0, 0, 0, 0)

Constructor & Destructor

__init__( self )

The constructor. Initialize a new RQuaternion object without initialization.

q = RLPy.RQuaternion()

print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # random values

__init__( self, vV )

The constructor. Initialize a new RQuaternion object from a 4D vector RVector4.

v = RLPy.RVector4(1, 2, 3, 4)
q = RLPy.RQuaternion(v)

print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # 1.0, 2.0, 3.0, 4.0

Parameters

vV [IN] a 4D vector - RLPy.RVector4

__init__( self, qQ )

v = RLPy.RVector4(1, 2, 3, 4)
q = RLPy.RQuaternion(v)
p = RLPy.RQuaternion(q)

print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 1.0, 2.0, 3.0, 4.0

Parameters

qQ [IN] a quaternion - RLPy.RQuaternion

__init__( self, kAxis, fAngle )

The constructor. Initialize a new RQuaternion object with Axis-angle. The axis is specified by a 3D vector, and the angle is specified by a float value.

v = RLPy.RVector3(0, 0, 1)
q = RLPy.RQuaternion(v, math.pi/2)

print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w))
    # 0.0, 0.0, 0.7071067094802856, 0.7071067690849304

Parameters

kAxis [IN] the rotation axis - RLPy.RVector3
fAngle [IN] the rotation angle - float

__init__( self, kRot )

The constructor. Initialize a new RQuaternion object with a 3x3 rotation matrix.

Parameters

kRot [IN] a 3x3 rotation matrix - RLPy.RMatrix3
v = RLPy.RVector3(0, 0, 1)
m = RLPy.RMatrix3(v, math.pi/2)
q = RLPy.RQuaternion(m)

print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w))
    # 0.0, 0.0, 0.7071067690849304, 0.7071067690849304

Operator

=

The "equal to" operator.

q = RLPy.RQuaternion()
p = q
if q == p:                         # True
    print("equal")

!=

The "not equal to" operator.

a = RLPy.RVector4(1, 2, 3, 4)
q = RLPy.RQuaternion(a)
b = RLPy.RVector4(2, 2, 3, 4)
p = RLPy.RQuaternion(b)
if a != b:                         #True
    print("not equal")

<

The "less than" operator. Similar to string comparison: Returns True upon the first match that is less than and False if it is greater than. If the current comparison is equal, continue onto the next element. If all elements are equal then return False.

a = RLPy.RVector4(0, 1, 5, 2)
b = RLPy.RVector4(0, 1, 5, 3)
c = RLPy.RVector4(1, 0, 1, 0)
d = RLPy.RVector4(0, 1, 5, 2)

p = RLPy.RQuaternion(a)
q = RLPy.RQuaternion(b)
r = RLPy.RQuaternion(c)
s = RLPy.RQuaternion(d)

if p< q:                       #True
    print('p< q')
if q< r:                       #True
    print('q< r')
if p< s:                       #False
    print('p< s')

>

The "greater than" operator. Similar to string comparison: Returns True upon the first match that is greater than and False if it is less than. If the current comparison is equal, continue onto the next element. If all elements are equal then return False.

a = RLPy.RVector4(0, 1, 5, 2)
b = RLPy.RVector4(0, 1, 5, 3)
c = RLPy.RVector4(1, 0, 1, 0)
d = RLPy.RVector4(0, 1, 5, 2)

p = RLPy.RQuaternion(a)
q = RLPy.RQuaternion(b)
r = RLPy.RQuaternion(c)
s = RLPy.RQuaternion(d)

if q >p:                       #True
    print('q >p')
if r >q:                       #True
    print('r >q')
if p >s:                       #False
    print('p >s')

<=

The "less than or equal" operator. Similar to string comparison: Returns True upon the first match that is less than and False if it is greater than. If the current comparison is equal, continue onto the next element. If all elements are equal then return True.

a = RLPy.RVector4(0, 1, 5, 2)
b = RLPy.RVector4(0, 1, 5, 3)
c = RLPy.RVector4(1, 0, 1, 0)
d = RLPy.RVector4(0, 1, 5, 2)

p = RLPy.RQuaternion(a)
q = RLPy.RQuaternion(b)
r = RLPy.RQuaternion(c)
s = RLPy.RQuaternion(d)

if p<= q:                       #True
    print('p<= q')
if q<= r:                       #True
    print('q<= r')
if p<= s:                       #True
    print('p<= s')

>=

The "greater than or equal" operator. Similar to string comparison: Returns True upon the first match that is greater than and False if it is less than. If the current comparison is equal, continue onto the next element. If all elements are equal then return True.

a = RLPy.RVector4(0, 1, 5, 2)
b = RLPy.RVector4(0, 1, 5, 3)
c = RLPy.RVector4(1, 0, 1, 0)
d = RLPy.RVector4(0, 1, 5, 2)

p = RLPy.RQuaternion(a)
q = RLPy.RQuaternion(b)
r = RLPy.RQuaternion(c)
s = RLPy.RQuaternion(d)

if q >= p:                       #True
    print('q >= p')
if r >= q:                       #True
    print('r >= q')
if p >= s:                       #True
    print('p >= s')

+

The "addition" operator. Perform quaternion addition.

a = RLPy.RVector4(0, 1, 2, 3)
b = RLPy.RVector4(1, 2, 3, 4)
p = RLPy.RQuaternion(a)
q = RLPy.RQuaternion(b)
r = p + q

print(str(r.x) + ', ' + str(r.y) + ', ' + str(r.z) + ', ' + str(r.w))  # 1.0, 3.0, 5.0, 7.0

-

The "subtraction" operator. Perform quaternion subtraction.

a = RLPy.RVector4(0, 1, 2, 3)
b = RLPy.RVector4(3, 2, 1, 0)
p = RLPy.RQuaternion(a)
q = RLPy.RQuaternion(b)
r = q - p

print(str(r.x) + ', ' + str(r.y) + ', ' + str(r.z) + ', ' + str(r.w)) # 3.0, 1.0, -1.0, -3.0

*

The "multiplication" operator. Perform a scalar multiplication when the second operand is an integer or float. If the second operand is another quaternion, then the respective elements are multiplied.

a = RLPy.RVector4(1, 2, 3, 4)
p = RLPy.RQuaternion(a)
q = p * 2
r = p * p

print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # 2.0, 4.0, 6.0, 8.0
print(str(r.x) + ', ' + str(r.y) + ', ' + str(r.z) + ', ' + str(r.w)) # 1.0, 4.0, 9.0, 16.0

/

The "division" operator. Perform a scalar division with a int or float value which the second operand is limited to.

a = RLPy.RVector4(1, 2, 3, 4)
p = RLPy.RQuaternion(a)
q = p / 2

print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # 0.5, 1.0, 1.5, 2.0

-

The "unary minus" operator. Inverse the sign of each element.

a = RLPy.RVector4(1, 2, 3, 4)
p = RLPy.RQuaternion(a)
q = -p

print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # -1.0, -2.0, -3.0, -4.0

+ =

The "addition assignment" operator.

a = RLPy.RVector4(0, 1, 2, 3)
b = RLPy.RVector4(1, 2, 3, 4)
p = RLPy.RQuaternion(a)
q = RLPy.RQuaternion(b)
p += q

print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 1.0, 3.0, 5.0, 7.0

- =

The "subtraction assignment" operator.

a = RLPy.RVector4(0, 1, 4, 5)
b = RLPy.RVector4(1, 2, 3, 1)
p = RLPy.RQuaternion(a)
q = RLPy.RQuaternion(b)
p -= q

print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # -1.0, -1.0, 1.0, 4.0

*=

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

a = RLPy.RVector4(1, 2, 3, 4)
p = RLPy.RQuaternion(a)
p *= 2

print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 2.0, 4.0, 6.0, 8.0

/=

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

a = RLPy.RVector4(1, 2, 3, 4)
p = RLPy.RQuaternion(a)
p /= 2

print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 0.5, 1.0, 1.5, 2.0

Member Functions

AlmostEqual( self, qQ )

a = RLPy.RVector4(1, 2, 3, 4)
p = RLPy.RQuaternion(a)
q = RLPy.RQuaternion(a)
r = RLPy.RQuaternion(a)

q.w = 4.000000001
r.w = 4.00001

if p.AlmostEqual(q):               #True
    print("p ≈ q")
if q.AlmostEqual(r):               #False
    print("p ≈ r")

Parameters

qQ [IN] The target quaternion to check for equivalence - RLPy.RQuaternion

Returns

True if the two quaternions are almost the same - bool

Conjugate( self )

Conjugate this quaternion.

a = RLPy.RVector4(1, 2, 3, 4)
p = RLPy.RQuaternion(a)
q = p.Conjugate()

print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # -1.0, -2.0, -3.0, 4.0

Returns

Returns the conjugated quaternion. The result is a quaternion whose x, y, and z values have been negated - RLPy.RQuaternion

Dot( self, qQ )

Calculate dot product of the two quaternions.

Parameters

qQ [IN] The quaternion to compute dot product - RLPy.RQuaternion

Returns

Returns the value of the dot product - float
a = RLPy.RVector4(1, 2, 3, 4)
b = RLPy.RVector4(1, 2, 3, 0)
p = RLPy.RQuaternion(a)
q = RLPy.RQuaternion(b)
f = p.Dot(q)

print(f)     # 14.0

FromAxisAngle( self, rkAxis, fAngle )

Quaternion from axis angle.

Parameters

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

Returns

Return a new quaternion from a axis angle - RLPy.RQuaternion
p = RLPy.RQuaternion()
v = RLPy.RVector3(0, 0, 1)
p.FromAxisAngle(v, math.pi/2)

print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 0.0, 0.0, 0.7071067094802856, 0.7071067690849304

FromRotationMatrix( self, rkRot )

Quaternion from a rotation matrix.

Parameters

rkRot [IN] Rotation matrix - RLPy.RMatrix3

Returns

Return a new quaternion from a rotation matrix - RLPy.RQuaternion
v = RLPy.RVector3(0, 0, 1)
m = RLPy.RMatrix3(v, math.pi/2)
p = RLPy.RQuaternion()
p.FromRotationMatrix(m)

print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 0.0, 0.0, 0.7071067690849304, 0.7071067690849304

Inverse( self, rkRot )

Obtain the inverse of this quaternion.

Returns

The inversed quaternion - RLPy.RQuaternion
a = RLPy.RVector4(1, 1, 1, 1)
p = RLPy.RQuaternion(a)
q = p.Inverse()

print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w)) # -0.25, -0.25, -0.25, 0.25

Multiply( self, qQ )

Multiply by another quaternion.

Parameters

qQ [IN] The quaternion to multiply - RLPy.RQuaternion

Returns

Returns the multiplied quaternion - RLPy.RQuaternion
a = RLPy.RVector4(1, 2, 3, 4)
b = RLPy.RVector4(1, 2, 2, 1)

p = RLPy.RQuaternion(a)
q = RLPy.RQuaternion(b)
r = p.Multiply(q)

print(str(r.x) + ', ' + str(r.y) + ', ' + str(r.z) + ', ' + str(r.w)) # 3.0, 11.0, 11.0, -7.0

MultiplyEqual( self, qQ )

Parameters

qQ [IN] The quaternion to multiply - RLPy.RQuaternion

Returns

Returns the multiplied quaternion - RLPy.RQuaternion
a = RLPy.RVector4(1, 2, 3, 4)
b = RLPy.RVector4(1, 2, 2, 1)

p = RLPy.RQuaternion(a)
q = RLPy.RQuaternion(b)
r = p.MultiplyEqual(q)

print(str(r.x) + ', ' + str(r.y) + ', ' + str(r.z) + ', ' + str(r.w)) # 3.0, 11.0, 11.0, -7.0

Normalize( self )

Normalizes this quaternion.

Returns

Returns the normalized quaternion - RLPy.RQuaternion
a = RLPy.RVector4(1, 1, 1, 1)
p = RLPy.RQuaternion(a)
q = p.Normalize()

print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w))
    # 0.4999999701976776, 0.4999999701976776, 0.4999999701976776, 0.4999999701976776

Rotate180( self )

Rotate 180 degree of this quaternion.

Returns

Returns the rotated quaternion - RLPy.RQuaternion
a = RLPy.RVector4(1, 1, 1, 1)
p = RLPy.RQuaternion(a)
q = p.Normalize()

print(str(q.x) + ', ' + str(q.y) + ', ' + str(q.z) + ', ' + str(q.w))
   #0.4999999701976776, 0.4999999701976776, 0.4999999701976776, 0.4999999701976776

SetX( self, tX )

Set the value of the x-axis.

Parameters

tX [IN] the value of the x-axis - float
a = RLPy.RVector4(1, 2, 3, 4)
p = RLPy.RQuaternion(a)
p.SetX(9)

print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w)) # 9.0, 2.0, 3.0, 4.0

SetY( self, tY )

Set the value of the y-axis.

Parameters

tY [IN] the value of the y-axis - float
a = RLPy.RVector4(1, 2, 3, 4)
p = RLPy.RQuaternion(a)
p.SetY(9)
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w))
    #1.0, 9.0, 3.0, 4.0

SetZ( self, tZ )

Set the value of the z-axis.

Parameters

tZ [IN] the value of the z-axis - float
a = RLPy.RVector4(1, 2, 3, 4)
p = RLPy.RQuaternion(a)
p.SetZ(9)
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w))
    #1.0, 2.0, 9.0, 4.0

SetW( self, tW )

Set the value of the w-axis.

Parameters

tW [IN] the value of the w-axis - float
a = RLPy.RVector4(1, 2, 3, 4)
p = RLPy.RQuaternion(a)
p.SetW(9)
print(str(p.x) + ', ' + str(p.y) + ', ' + str(p.z) + ', ' + str(p.w))
    #1.0, 2.0, 3.0, 9.0