pebxcvi's picture
big update
d7bb13e
raw
history blame
15.3 kB
1.66 Quaternion .557
1.66.1 Quaternion.Add .557
1.66.2 Quaternion.Conjugate .558
1.66.3 Quaternion.Copy .558
1.66.4 Quaternion.Create .559
1.66.5 Quaternion.Divide .560
1.66.6 Quaternion.Dot .560
1.66.7 Quaternion.Length .561
1.66.8 Quaternion.Multiply .562
1.66.9 Quaternion.Negate .562
1.66.10 Quaternion.Nlerp .563
1.66.11 Quaternion.Normalize .563
1.66.12 Quaternion.SetAxisAngle .564
1.66.13 Quaternion.Setldentity .564
1.66.14 Quaternion.SetRotationMatrix .565
1.66.15 Quaternion.SetW .566
1.66.16 Quaternion.SetX .566
1.66.17 Quaternion.SetXyzw .567
1.66.18 Quaternion.SetY .567
1.66.19 Quaternion.SetZ .568
1.66.20 Quaternion.Slerp .569
1.66.21 Quaternion.Subtract .569
1.66.22 Quaternion.ToAxisAngle .570
1.66.23 Quaternion.W .570
1.66.24 Quaternion.X .571
1.66.25 Quaternion.Y .572
1.66.26 Quaternion.Z .572
Quaternion
Quaternion.Add
Brief
Adds one quaternion to another, element by element.
Definition
! Quaternion.Add( Quaternion destination. Quaternion sourcel. Quaternion source2 )
Arguments
destination - Quaternion to store the result of the addition.sourcel - Quaternion to be added to source2.source2 - Quaternion to be added to
sourcel.
Return Values
None
Description
Adds sourcel and source2 element-wise, storing the result in destination.
Examples
result = Quaternion.Create()
ql = Quaternion.Create( )
q2 = Quaternion.Create( )
Quaternion.Add( result, ql, q2 ) � result = ql + q2
See Also
� Quaternion.Create
Quaternion.Conjugate
Brief
Conjugate a quaternion.
Definition
! Quaternion.Conjugate( Quaternion q )
Arguments
q - Quaternion to be conjugated.
Return Values
None
Description
Conjugate a quaternion.
Examples
! q = Quaternion.Create ()
i Quaternion.Conjugate( q )
See Also
� Quaternion.Create
Quaternion.Copy
Brief
Copies the values of one quaternion into another.
Definition
! Quaternion.Copy( Quaternion destination. Quaternion source )
Arguments
destination - The quaternion to copy to.source - The quaternion to be copied.
Return Values
None
Description
Copies the values of the source quaternion and stores them in the destination. Lua has reference semantics for user types, so using ql = q2 will
not copy values but rather make ql reference q2.
Examples
ql = Quaternion.Create()
q2 = Quaternion.Create()
Quaternion.Copy( q2, ql )
See Also
� Quaternion.Create
Quaternion.Create
Brief
Creates a new Quaternion object using the specified values.
Definition
Quaternion Quaternion.Create( )
Quaternion Quaternion.Create( Quaternion source )
Quaternion Quaternion.Create( number x, number y, number z, number w )
Quaternion Quaternion.Create( Matrix44 rotationMatrix )
Quaternion Quaternion.Create( Vector4 axis, number angle )
Arguments
source - Quaternion whose values are used to initialize newly created quaternion.x - Number to be written into the first element of the quaternion.y
- Number to be written into the second element of the quaternion.z - Number to be written into the third element of the quaternion.w - Number to
be written into the fourth element of the quaternion.rotationMatrix - A rotation matrix to be converted to a quaternion.axis - Rotation axis.angle -
Rotation angle about the rotation axis in degrees.
Return Values
A new Quaternion instance.
Description
Creates a new Quaternion object using the specified values.
Examples
� Create a default identity (0, 0, 0, 1) quaternion
ql = Quaternion.Create ()
� Create a quaternion with supplied values
q2 = Quaternion.Create( 0, 0, 0, 1 )
� Create a quaternion using the values of another
q3 = Quaternion.Create( q2 )
� Create a quaternion from a rotation matrix
Matrix44 rotation = Matrix44.Create ()
q4 = Quaternion.Create ( rotation )
� Create a quaternion from a rotation axis and rotation angle
Vector4 axis = Vector4.Create( 0, 1, 0 )
angle = 45
q5 = Quaternion.Create( axis, angle )
See Also
None
Quaternion.Divide
Brief
Performs scalar division on a quaternion.
Definition
Quaternion.Divide( Quaternion destination. Quaternion source, number scalar )
Arguments
destination - Quaternion to store the result of the division.source 1 - Quaternion to divide.scalar - The scalar to divide by.
Return Values
None
Description
Multiplies source by 1/scalar, storing the result in destination.
Examples
result = Quaternion.Create()
ql = Quaternion.Create()
Quaternion.Divide( result, ql, 2 )
See Also
� Quaternion.Create
Quaternion.Dot
Brief
Performs a dot product between two quaternions.
Definition
number Quaternion.Dot( Quaternion srcl, Quaternion src2 )
Arguments
srcl - First quaternion to take part in the dot product.src2 - Second quaternion to take part in the dot product.
Return Values
The dot product of the two supplied quaternions.
Description
Performs a dot product between two quaternions.
Examples
ql = Quaternion.Create()
i q2 = Quaternion.Create()
j result = Quaternion.Dot2( ql, q2 )
See Also
None
Quaternion.Length
Brief
Calculates the magnitude of the specified quaternion.
Definition
number Quaternion.Length( Quaternion quaternion )
Arguments
quaternion - Source quaternion for the calculation.
Return Values
A number holding the magnitude of the specified quaternion.
Description
Calculates the magnitude of the specified quaternion.
Examples
1 ql = Quaternion.Create ()
| print( "Quaternion magnitude is: " .. Quaternion.Length( ql ) )
See Also
None
Quaternion.Multiply
Brief
Multiplies two quaternion by one another or a quaternion by a scalar.
Definition
Quaternion.Multiply( Quaternion destination, Quaternion sourcel, Quaternion source2 )
Quaternion.Multiply( Quaternion destination, Quaternion source, number scalar )
Quaternion.Multiply( Quaternion destination, number scalar, Quaternion source )
Arguments
destination - Quaternion to store the result of the multiplication.sourcel - The first quaternion argument for the multiplication.source2 - The second
quaternion argument for the multiplication.scalar - Number to multiply quaternion components by.
Return Values
None
Description
Multiplies sourcel and source2 or source and scalar, storing the result in destination.
Examples
result = Quaternion.Create()
vl = Quaternion.Create()
v2 = Quaternion.Create()
Quaternion.Multiply( result, vl, v2 )
Quaternion.Multiply( result, result, 0.5 )
See Also
� Quaternion.Create
Quaternion.Negate
Brief
Negate the components of a quaternion.
Definition
Quaternion.Negate( Quaternion q )
Arguments
q - Quaternion to be negated.
Return Values
None
Description
Negate the components of a quaternion.
Examples
q = Quaternion.Create()
Quaternion.Negate( q )
See Also
� Quaternion.Create
Quaternion.Nlerp
Brief
Performs a normalized linear interpolation between two quaternions.
Definition
Quaternion.Nlerp( Quaternion destination. Quaternion sourcel, Quaternion source2, number t )
Arguments
destination - Quaternion to store the result of the nlerp.sourcel - The first quaternion argument for the nlerp.source2 - The second quaternion
argument for the nlerp.t - The interpolation parameter, in range [ 0, 1 ].
Return Values
None
Description
Performs a normalized linear interpolation between two quaternions. The shortest path rotation is taken.
Examples
result = Quaternion.Create()
ql = Quaternion.Create( axis, 0 )
q2 = Quaternion.Create( axis, 90 )
Quaternion.Nlerp( result, ql, q2 )
See Also
� Quaternion.Create
Quaternion.Normalize
Brief
Normalizes the specified quaternion.
Definition
Quaternion.Normalize( Quaternion quaternion )
Arguments
quaternion - The quaternion to normalize.
Return Values
None
Description
Normalizes the specified quaternion.
Examples
q = Quaternion.Create()
Quaternion.Normalize( q ) � note that this has no effect to the identity quaternion from Create
See Also
� Quaternion.Create
Quaternion.SetAxisAngle
Brief
Sets a quaternion to represent a given axis/angle rotation.
Definition
Quaternion.SetAxisAngle( Quaternion destination, Vector4 axis, number angle )
Arguments
destination - Quaternion to store the result of the slerp.axis - Rotation axis.angle - Angle of rotation about the rotation axis, in degrees.
Return Values
None
Description
Sets a quaternion to represent a given axis/angle rotation.
Examples
! q = Quaternion.Create ()
i axis = Vector4.Create ( 0, 1, 0 )
| angle = 45
! Quaternion.SetAxisAngle( q, axis, angle )
See Also
� Quaternion.Create
� Vector4.Create
Quaternion.Setldentity
Brief
Sets the quaternion to the identity quaternion (0, 0, 0, 1).
Definition
! Quaternion.Setldentity( Quaternion quat )
Arguments
quat - Quaternion to be set to identity.
Return Values
None
Description
Sets the quaternion to the identity quaternion (0, 0, 0, 1).
Examples
! q = Quaternion.Create ()
j Quaternion.Setldentity( q ) � this is redundant after using the default constructor however
See Also
� Quaternion.Create
Quaternion.SetRotationMatrix
Brief
Sets a quaternion to represent a given rotation matrix.
Definition
! Quaternion.SetRotationMatrix( Quaternion destination, Matrix44 rotationMatrix )
Arguments
destination - Quaternion to store the result of the slerp.rotationMatrix - Rotation matrix.
Return Values
None
Description
Sets a quaternion to represent a given rotation matrix.
Examples
! q = Quaternion.Create ()
m = Matrix44.Create()
j Matrix44.SetAxisRotation( m, 0.5, 0.5, 0, 90, MATRIX_REPLACE )
! Quaternion.SetRotationMatrix( q, m )
See Also
� Matrix44.Create
� Matrix44.SetAxisRotation
� Quaternion.Create
Quaternion.SetW
Brief
Sets the w value of the quaternion.
Definition
! Quaternion.SetW( Quaternion quaternion, number value )
Arguments
quaternion - Quaternion to be set.value - A numerical value that is copied into the w component of the quaternion.
Return Values
None
Description
Sets the w value of the quaternion.
Examples
! q = Quaternion.Create ()
\ Quaternion.SetW( q, 0 )
See Also
� Quaternion.Create
� Quaternion.SetX
� Quaternion.SetY
� Quaternion.SetZ
Quaternion.SetX
Brief
Sets the x value of the quaternion.
Definition
! Quaternion.SetX( Quaternion quaternion, number value )
Arguments
quaternion - Quaternion to be set.value - A numerical value that is copied into the x component of the quaternion.
Return Values
None
Description
Sets the x value of the quaternion.
Examples
! q = Quaternion.Create ()
! Quaternion.SetX( q, 0 )
See Also
� Quaternion.Create
� Quaternion.SetY
� Quaternion.SetZ
� Quaternion.SetW
Quaternion.SetXyzw
Brief
Sets a Quaternion object with the specified values.
Definition
! Quaternion.SetXyzw( Quaternion q, number x, number y, number z, number w )
Arguments
q - Quaternion to be set.x - Number to be written into the first element of the quaternion.y - Number to be written into the second element of the
quaternion.z - Number to be written into the third element of the quaternion.w - Number to be written into the fourth element of the quaternion.
Return Values
None
Description
Sets a Quaternion object with the specified values.
Examples
! q = Quaternion.Create ()
i Quaternion.SetXyzw( q, 0, 0, 0, 1 )
See Also
� Quaternion.SetX
� Quaternion.SetY
� Quaternion.SetZ
� Quaternion.SetW
Quaternion.SetY
Brief
Sets the y value of the quaternion.
Definition
! Quaternion.SetY( Quaternion quaternion, number value )
Arguments
quaternion - Quaternion to be set.value - A numerical value that is copied into the y component of the quaternion.
Return Values
None
Description
Sets the y value of the quaternion.
Examples
! q = Quaternion.Create ()
i Quaternion.SetY ( q, 0 )
See Also
� Quaternion.Create
� Quaternion.SetX
� Quaternion.SetZ
� Quaternion.SetW
Quaternion.SetZ
Brief
Sets the z value of the quaternion.
Definition
! Quaternion.SetZ( Quaternion quaternion, number value )
Arguments
quaternion - Quaternion to be set.value - A numerical value that is copied into the z component of the quaternion.
Return Values
None
Description
Sets the z value of the quaternion.
Examples
j q = Quaternion.Create ()
I Quaternion.SetZ( q, 0 )
See Also
� Quaternion.Create
� Quaternion.SetX
� Quaternion.SetY
� Quaternion.SetW
Quaternion.Slerp
Brief
Performs spherical linear interpolation between two quaternions.
Definition
! Quaternion.Slerp( Quaternion destination. Quaternion sourcel, Quaternion source2, number t )
Arguments
destination - Quaternion to store the result of the slerp.sourcel - The first quaternion argument for the slerp.source2 - The second quaternion
argument for the slerp.t - The interpolation parameter, in range [0,1].
Return Values
None
Description
Performs spherical linear interpolation between two quaternions.
Examples
result = Quaternion.Create()
ql = Quaternion.Create( axis, 0 )
q2 = Quaternion.Create( axis, 90 )
Quaternion.Slerp( result, ql, q2, 0.5 )
See Also
� Quaternion.Create
Quaternion.Subtract
Brief
Subtracts one quaternion from another, element by element.
Definition
Quaternion.Subtract( Quaternion destination, Quaternion sourcel. Quaternion source2 )
Arguments
destination - Quaternion to store the result of the subtraction.source 1 - The minuend for the subtraction.source2 - The subtrahend for the
subtraction.
Return Values
None
Description
Subtracts source2 from sourcel element-wise, storing the result in destination.
Examples
result = Quaternion.Create()
ql = Quaternion.Create()
q2 = Quaternion.Create()
Quaternion.Subtract( result, ql, q2 ) � result = ql - q2
See Also
� Quaternion.Create
Quaternion.ToAxisAngle
Brief
Get the equivalent rotation in axis/angle representation.
Definition
Vector4, number Quaternion.ToAxisAngle( Quaternion q )
Arguments
q - Quaternion to be converted to axis angle representation.
Return Values
Vector4 - x,y,z rotation axis, w rotation angle in degrees
Description
Get the equivalent rotation in axis/angle representation.
Examples
! q = Quaternion.Create ()
; axisAngle = Quaternion.ToAxisAngle( q )
See Also
� Quaternion.Create
Quaternion.W
Brief
Returns the w value of the quaternion.
Definition
! number Quaternion.W( Quaternion q )
Arguments
q - Quaternion to be queried.
Return Values
The fourth element of the quaternion, the w component.
Description
Returns the w value of the quaternion.
Examples
q = Quaternion.Create()
; print( "Value of W is: " .. Quaternion.W( q ) )
See Also
� Quaternion.Create
� Quaternion.X
� Quaternion.Y
� Quaternion.Z
Quaternion.X
Brief
Returns the x value of the quaternion.
Definition
! number Quaternion.X( Quaternion q )
Arguments
q - Quaternion to be queried.
Return Values
The first element of the quaternion, the x component.
Description
Returns the x value of the quaternion.
Examples
q = Quaternion.Create()
print( "Value of X is:
.. Quaternion.X( q ) )
See Also
� Quaternion.Create
� Quaternion.Y
� Quaternion.Z
� Quaternion.W
Quaternion.Y
Brief
Returns the y value of the quaternion.
Definition
! number Quaternion.Y( Quaternion q )
Arguments
q - Quaternion to be queried.
Return Values
The second element of the quaternion, the y component.
Description
Returns the y value of the quaternion.
Examples
! q = Quaternion.Create ()
i print( "Value of Y is: " .. Quaternion.Y( q ) )
See Also
� Quaternion.Create
� Quaternion.X
� Quaternion.Z
� Quaternion.W
Quaternion.Z
Brief
Returns the z value of the quaternion.
Definition
! number Quaternion.Z( Quaternion q )
Arguments
q - Quaternion to be queried.
Return Values
The third element of the quaternion, the z component.
Description
Returns the z value of the quaternion.
Examples
! q = Quaternion.Create ()
print( "Value of Z is: " .. Quaternion.Z( q ) )
See Also
� Quaternion.Create
� Quaternion.X
� Quaternion.Y
� Quaternion.W