Difference between revisions of "Quaternion Class"

From Derivative
Jump to navigation Jump to search
Line 109: Line 109:
 
     |class=tdu.Quaternion
 
     |class=tdu.Quaternion
 
     |name=dot
 
     |name=dot
     |call=dot(q2)
+
     |call=dot(quat)
 
     |returns=float
 
     |returns=float
     |text=Returns the dot product (float) of the current quaternion and another quaternion.
+
     |text=Returns the dot product of the quaternion and the argument.
 +
The quaternion argument can be anything from which a quaternion can be derived (x,y,z,w), Matrix, etc).
 
<syntaxhighlight lang=python>
 
<syntaxhighlight lang=python>
 
l = q.dot(q2)
 
l = q.dot(q2)
Line 131: Line 132:
 
     |call=copy()
 
     |call=copy()
 
     |returns=quaternion
 
     |returns=quaternion
     |text=Quaternion copy
+
     |text=Creates a copy of the quaternion with separate values.
 
}}
 
}}
 
{{ClassMethod
 
{{ClassMethod

Revision as of 06:42, 29 May 2018

Quaternion


Members

wfloat (Read Only):

Quaternion_w

xfloat (Read Only):

Quaternion_x

yfloat (Read Only):

Quaternion_y

zfloat (Read Only):

Quaternion_z

Methods

lerp(q2, lerpF)quaternion:

Returns a quaternion as the linear interpolation of the current quaternion (q) and another quaternion (q2) using an interpolation factor (lerpF) in the range [0,1].

l = q.lerp(q2, lerpF)

length()float:

Returns the length of the current quaternion.

l = q.length()

cross(q2)vector:

Returns the cross product of the current quaternion and another quaternion.

l = q.cross(q2)

rotate(vec)vector:

Rotates a vector using the current quaternion and returns a new vector.

l= q.rotate(vec)

slerp(q2, slerpF)quaternion:

Returns a quaternion as the spherical interpolation of the current quaternion (q) and another quaternion (q2) using an interpolation factor (slerpF).

l = q.slerp(q2, slerpF)

eulerAngles(order='xyz')tuple:

Returns euler angles in degrees as a tuple (i.e. pitch as x, yaw as y, roll as z) from current quaternion. The 'order' argument can be set to any valid rotation order which by default is set to 'xyz'.

l = q.eulerAngles(order='xyz')

axis()vector:

Returns the rotation axis vector of the current.

l = q.axis()

dot(quat)float:

Returns the dot product of the quaternion and the argument.

The quaternion argument can be anything from which a quaternion can be derived (x,y,z,w), Matrix, etc).

l = q.dot(q2)

exp()quaternion:

Returns the exponential of the current as a new quaternion.

l = q.exp()

copy()quaternion:

Creates a copy of the quaternion with separate values.

log()quaternion:

Returns the natural logarithm of the current as a new quaternion.

l = q.log()

inverse()None:

Invert the current quaternion.

q.inverse()

angle()float:

Returns the rotation angle (in degrees) of the current.

l = q.angle()

TouchDesigner Build: