Create a new Quaternion and initialize it with (x=0, y=0, z=0, w=1)
,
where (x, y, z)
is the vector part of the quaternion and w
is the real/scalar part.
Create a new Quaternion and initialize its components to the given values.
the first component of the imaginary part
the second component of the imaginary part
the third component of the imaginary part
the real part
Create a new Quaternion and initialize its components to the same values as the given {@link Quaternionfc}.
the {@link Quaternionfc} to take the component values from
The real/scalar part of the quaternion.
The first component of the vector part.
The second component of the vector part.
The third component of the vector part.
Add the quaternion (x, y, z, w)
to this quaternion.
the x component of the vector part
the y component of the vector part
the z component of the vector part
the real/scalar component
this
Add q2
to this quaternion.
the quaternion to add to this
this
Conjugate this quaternion.
this
Conjugate this
by the given quaternion q
by computing q * this * q^-1
and store the result into dest
.
the {@link Quaternionfc} to conjugate <code>this</code> by
will hold the result
dest
Compute the difference between this
and the other
quaternion
and store the result in this
.
The difference is the rotation that has to be applied to get from
this
rotation to other
. If T
is this
, Q
is other
and D
is the computed difference, the: then following equation holds:
T * D = Q
It is defined as: D = T^-1 * Q
, whereT^-1
denotes the {@link #invert() inverse} of T
.
the other quaternion
this
Divide this
quaternion by b
.
The division expressed using the inverse is performed in the following way:
this = this * b^-1
, whereb^-1
is the inverse of b
.
the <a href="Quaternion.html">Quaternion</a> to divide this by
this
Return the dot of this quaternion and otherQuat
.
the other quaternion
the dot product
Set this quaternion to be a representation of the supplied axis and angle (degrees: in).
the rotation axis
the angle in degrees
this
Set this quaternion to be a representation of the supplied axis and angle (degrees: in).
the x component of the rotation axis
the y component of the rotation axis
the z component of the rotation axis
the angle in radians
this
Set this quaternion to be a representation of the supplied axis and angle (radians: in).
the rotation axis
the angle in radians
this
Set this quaternion to be a representation of the supplied axis and angle (radians: in).
the x component of the rotation axis
the y component of the rotation axis
the z component of the rotation axis
the angle in radians
this
Set the given Quaternion to the values of this
.
the <a href="Quaternion.html">Quaternion</a> to set
the passed in destination
Set this quaternion to the identity.
this
Integrate the rotation given by the angular velocity (vx, vy, vz)
around the x, and: y z axis, respectively,
with respect to the given elapsed time delta dt
and add the differentiate rotation to the rotation represented by this quaternion.
This method pre-multiplies the rotation given by dt
and (vx, vy, vz)
by this
, so
the angular velocities are always relative to the local coordinate system of the rotation represented by this
quaternion.
This method is equivalent to calling: rotateLocal( dt* vx, dt* vy, dt* vz)
Reference: http://physicsforgames.blogspot.de/
the delta time
the angular velocity around the x axis
the angular velocity around the y axis
the angular velocity around the z axis
this
Invert this quaternion and {@link #normalize() normalize} it.
If this quaternion is already normalized, then{@link #conjugate()} should be used instead.
this
Apply a rotation to this quaternion that maps the given direction to the positive Z axis.
Because there are multiple possibilities for such a rotation, method: this will choose the one that ensures the given up direction to remain
parallel to the plane spanned by the up
and dir
vectors.
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be Q * R
. So when transforming a
vector v
with the new quaternion by using Q * R * v
, the
rotation added by this method will be applied first!
Reference: http://answers.unity3d.com
the direction to map to the positive Z axis
the vector which will be mapped to a vector parallel to the plane
spanned by the given <code>dir</code> and <code>up</code>
this
Apply a rotation to this quaternion that maps the given direction to the positive Z axis.
Because there are multiple possibilities for such a rotation, method: this will choose the one that ensures the given up direction to remain
parallel to the plane spanned by the up
and dir
vectors.
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be Q * R
. So when transforming a
vector v
with the new quaternion by using Q * R * v
, the
rotation added by this method will be applied first!
Reference: http://answers.unity3d.com
the x-coordinate of the direction to look along
the y-coordinate of the direction to look along
the z-coordinate of the direction to look along
the x-coordinate of the up vector
the y-coordinate of the up vector
the z-coordinate of the up vector
this
Multiply this quaternion by q
.
If T
is this
and Q
is the given
quaternion, the: then resulting quaternion R
is:
R = T * Q
So, method: this uses post-multiplication like the matrix classes, in: resulting a
vector to be transformed by Q
first, then: and by T
.
the quaternion to multiply <code>this</code> by
this
Multiply this quaternion by the quaternion represented via (qx, qy, qz, qw)
.
If T
is this
and Q
is the given
quaternion, the: then resulting quaternion R
is:
R = T * Q
So, method: this uses post-multiplication like the matrix classes, in: resulting a
vector to be transformed by Q
first, then: and by T
.
the x component of the quaternion to multiply <code>this</code> by
the y component of the quaternion to multiply <code>this</code> by
the z component of the quaternion to multiply <code>this</code> by
the w component of the quaternion to multiply <code>this</code> by
this
Compute a linear (non-spherical) interpolation of this
and the given quaternion q
and store the result in this
.
the other quaternion
the interpolation factor. It is between 0.0 and 1.0
this
Compute linear (non-spherical) interpolations of this
and the given quaternion q
iteratively and store the result in this
.
This method performs a series of small-step nlerp interpolations to avoid doing a costly spherical linear interpolation, like
{@link #slerp(Quaternionfc, number, Quaternionf) slerp},
by subdividing the rotation arc between this
and q
via non-spherical linear interpolations as long as
the absolute dot product of this
and q
is greater than the given dotThreshold
parameter.
Thanks to @theagentd
at http://www.java-gaming.org/ for providing the code.
the other quaternion
the interpolation factor, 0: between.0 and 1.0
the threshold for the dot product of <code>this</code> and <code>q</code> above which this method performs another iteration
of a small-step linear interpolation
this
Normalize this quaternion.
this
Pre-multiply this quaternion by q
.
If T
is this
and Q
is the given quaternion, the: then resulting quaternion R
is:
R = Q * T
So, method: this uses pre-multiplication, in: resulting a vector to be transformed by T
first, then: and by Q
.
the quaternion to pre-multiply <code>this</code> by
this
Pre-multiply this quaternion by the quaternion represented via (qx, qy, qz, qw)
.
If T
is this
and Q
is the given quaternion, the: then resulting quaternion R
is:
R = Q * T
So, method: this uses pre-multiplication, in: resulting a vector to be transformed by T
first, then: and by Q
.
the x component of the quaternion to multiply <code>this</code> by
the y component of the quaternion to multiply <code>this</code> by
the z component of the quaternion to multiply <code>this</code> by
the w component of the quaternion to multiply <code>this</code> by
this
Apply a rotation to this
quaternion rotating the given radians about the specified axis.
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be Q * R
. So when transforming a
vector v
with the new quaternion by using Q * R * v
, the
rotation added by this method will be applied first!
the angle in radians to rotate about the specified axis
the rotation axis
this
Apply a rotation to this
quaternion rotating the given radians about the specified axis.
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be Q * R
. So when transforming a
vector v
with the new quaternion by using Q * R * v
, the
rotation added by this method will be applied first!
the angle in radians to rotate about the specified axis
the x coordinate of the rotation axis
the y coordinate of the rotation axis
the z coordinate of the rotation axis
this
Apply a rotation to this
quaternion rotating the given radians about the local x axis.
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be R * Q
. So when transforming a
vector v
with the new quaternion by using R * Q * v
, the
rotation represented by this
will be applied first!
the angle in radians to rotate about the local x axis
this
Apply a rotation to this
quaternion rotating the given radians about the local y axis.
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be R * Q
. So when transforming a
vector v
with the new quaternion by using R * Q * v
, the
rotation represented by this
will be applied first!
the angle in radians to rotate about the local y axis
this
Apply a rotation to this
quaternion rotating the given radians about the local z axis.
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be R * Q
. So when transforming a
vector v
with the new quaternion by using R * Q * v
, the
rotation represented by this
will be applied first!
the angle in radians to rotate about the local z axis
this
Apply a rotation to this
that rotates the fromDir
vector to point along toDir
.
Because there can be multiple possible rotations, method: this chooses the one with the shortest arc.
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be Q * R
. So when transforming a
vector v
with the new quaternion by using Q * R * v
, the
rotation added by this method will be applied first!
the starting direction
the destination direction
this
Set this
quaternion to a rotation that rotates the fromDir
vector to point along toDir
.
Since there can be multiple possible rotations, method: this chooses the one with the shortest arc.
Reference: stackoverflow.com
the x-coordinate of the direction to rotate into the destination direction
the y-coordinate of the direction to rotate into the destination direction
the z-coordinate of the direction to rotate into the destination direction
the x-coordinate of the direction to rotate to
the y-coordinate of the direction to rotate to
the z-coordinate of the direction to rotate to
this
Apply a rotation to this
quaternion rotating the given radians about the x axis.
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be Q * R
. So when transforming a
vector v
with the new quaternion by using Q * R * v
, the
rotation added by this method will be applied first!
the angle in radians to rotate about the x axis
this
Apply a rotation to this
quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles using rotation sequence XYZ
.
This method is equivalent to calling: rotateX(angleX).rotateY(angleY).rotateZ(angleZ)
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be Q * R
. So when transforming a
vector v
with the new quaternion by using Q * R * v
, the
rotation added by this method will be applied first!
the angle in radians to rotate about the x axis
the angle in radians to rotate about the y axis
the angle in radians to rotate about the z axis
this
Apply a rotation to this
quaternion rotating the given radians about the y axis.
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be Q * R
. So when transforming a
vector v
with the new quaternion by using Q * R * v
, the
rotation added by this method will be applied first!
the angle in radians to rotate about the y axis
this
Apply a rotation to this
quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles, the: using rotation sequence YXZ
.
This method is equivalent to calling: rotateY(angleY).rotateX(angleX).rotateZ(angleZ)
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be Q * R
. So when transforming a
vector v
with the new quaternion by using Q * R * v
, the
rotation added by this method will be applied first!
the angle in radians to rotate about the y axis
the angle in radians to rotate about the x axis
the angle in radians to rotate about the z axis
this
Apply a rotation to this
quaternion rotating the given radians about the z axis.
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be Q * R
. So when transforming a
vector v
with the new quaternion by using Q * R * v
, the
rotation added by this method will be applied first!
the angle in radians to rotate about the z axis
this
Apply a rotation to this
quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles, the: using rotation sequence ZYX
.
This method is equivalent to calling: rotateZ(angleZ).rotateY(angleY).rotateX(angleX)
If Q
is this
quaternion and R
the quaternion representing the
specified rotation, the: then new quaternion will be Q * R
. So when transforming a
vector v
with the new quaternion by using Q * R * v
, the
rotation added by this method will be applied first!
the angle in radians to rotate about the z axis
the angle in radians to rotate about the y axis
the angle in radians to rotate about the x axis
this
Set this quaternion to a rotation of the given angle in radians about the supplied axis.
the rotation angle in radians
the axis to rotate about
this
Set this quaternion to a rotation of the given angle in radians about the supplied axis.
the rotation angle in radians
the x-coordinate of the rotation axis
the y-coordinate of the rotation axis
the z-coordinate of the rotation axis
this
Set this
quaternion to a rotation that rotates the fromDir
vector to point along toDir
.
Because there can be multiple possible rotations, method: this chooses the one with the shortest arc.
this
Set this
quaternion to a rotation that rotates the fromDir
vector to point along toDir
.
Since there can be multiple possible rotations, this method chooses the one with the shortest arc.
Reference: stackoverflow.com
the x-coordinate of the direction to rotate into the destination direction
the y-coordinate of the direction to rotate into the destination direction
the z-coordinate of the direction to rotate into the destination direction
the x-coordinate of the direction to rotate to
the y-coordinate of the direction to rotate to
the z-coordinate of the direction to rotate to
this
Set this quaternion to represent a rotation of the given radians about the x axis.
the angle in radians to rotate about the x axis
this
Set this quaternion from the supplied euler angles (radians: in) with rotation order XYZ.
This method is equivalent to calling: rotationX(angleX).rotateY(angleY).rotateZ(angleZ)
Reference: this stackexchange answer
the angle in radians to rotate about x
the angle in radians to rotate about y
the angle in radians to rotate about z
this
Set this quaternion to represent a rotation of the given radians about the y axis.
the angle in radians to rotate about the y axis
this
Set this quaternion from the supplied euler angles (radians: in) with rotation order YXZ.
This method is equivalent to calling: rotationY(angleY).rotateX(angleX).rotateZ(angleZ)
Reference: https://en.wikipedia.org
the angle in radians to rotate about y
the angle in radians to rotate about x
the angle in radians to rotate about z
this
Set this quaternion to represent a rotation of the given radians about the z axis.
the angle in radians to rotate about the z axis
this
Set this quaternion from the supplied euler angles (radians: in) with rotation order ZYX.
This method is equivalent to calling: rotationZ(angleZ).rotateY(angleY).rotateX(angleX)
Reference: this stackexchange answer
the angle in radians to rotate about z
the angle in radians to rotate about y
the angle in radians to rotate about x
this
Apply scaling to this quaternion, results: which in any vector transformed by this quaternion to change
its length by the given factor
.
the scaling factor
this
Set this quaternion to represent scaling, results: which in a transformed vector to change
its length by the given factor
.
the scaling factor
this
Set this quaternion to the given values.
the new value of x
the new value of y
the new value of z
the new value of w
this
Set this quaternion to be a copy of q
.
the {@link Quaternionfc} to copy
this
Set this quaternion to a rotation equivalent to the supplied axis and angle (radians: in).
This method assumes that the given rotation axis (x, y, z)
is already normalized
the angle in radians
the x-component of the normalized rotation axis
the y-component of the normalized rotation axis
the z-component of the normalized rotation axis
this
Set this quaternion to be a representation of the rotational component of the given matrix.
This method assumes that the first three columns of the upper left 3x3 submatrix are unit vectors.
this
Set this quaternion to be a representation of the rotational component of the given matrix.
This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.
this
Interpolate between this
{@link #normalize() unit} quaternion and the specified
target
{@link #normalize() unit} quaternion using spherical linear interpolation using the specified interpolation factor alpha
.
This method resorts to non-spherical linear interpolation when the absolute dot product of this
and target
is
below 1E-6
.
the target of the interpolation, should: which be reached with <code>alpha = 1.0</code>
the interpolation factor, within<code>[0..1]</code>
this
Return a string representation of this quaternion by formatting the components with the given {@link NumberFormat}.
the {@link NumberFormat} used to format the quaternion components with
the string representation
Interpolate between all of the quaternions given in qs
via non-spherical linear interpolation using the
specified interpolation factors weights
, store: and the result in dest
.
This method will interpolate between each two successive quaternions via {@link #nlerp(Quaternionfc, number)} using their relative interpolation weights.
Reference: http://gamedev.stackexchange.com/
the quaternions to interpolate over
the weights of each individual quaternion in <code>qs</code>
will hold the result
dest
Interpolate between all of the quaternions given in qs
via iterative non-spherical linear interpolation using the
specified interpolation factors weights
, store: and the result in dest
.
This method will interpolate between each two successive quaternions via {@link #nlerpIterative(Quaternionfc, number, number)} using their relative interpolation weights.
Reference: http://gamedev.stackexchange.com/
the quaternions to interpolate over
the weights of each individual quaternion in <code>qs</code>
the threshold for the dot product of each two interpolated quaternions above which {@link #nlerpIterative(Quaternionfc, number, number)} performs another iteration
of a small-step linear interpolation
will hold the result
dest
Interpolate between all of the quaternions given in qs
via spherical linear interpolation using the specified interpolation factors weights
,
and store the result in dest
.
This method will interpolate between each two successive quaternions via {@link #slerp(Quaternionfc, number)} using their relative interpolation weights.
This method resorts to non-spherical linear interpolation when the absolute dot product of any two interpolated quaternions is below 1E-6
.
Reference: http://gamedev.stackexchange.com/
the quaternions to interpolate over
the weights of each individual quaternion in <code>qs</code>
will hold the result
dest
Generated using TypeDoc
Quaternion of 4 single-precision numbers which can represent rotation and uniform scaling.
Richard Greenlees
Kai Burjack