Class Quaternion
Represents a four dimensional mathematical quaternion. Euler angles are stored in: pitch, yaw, roll order (x, y, z).
Inheritance
Implements
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public sealed class Quaternion : ValueType, IEquatable<Quaternion>, IFormattable
Constructors
Quaternion(Float3, Single)
Initializes a new instance of the Quaternion struct.
Declaration
public Quaternion(Float3 value, float w)
Parameters
|
Float3
value
A vector containing the values with which to initialize the X, Y, and Z components. |
|
System.Single
w
Initial value for the W component of the quaternion. |
Quaternion(Float4)
Initializes a new instance of the Quaternion struct.
Declaration
public Quaternion(Float4 value)
Parameters
|
Float4
value
A vector containing the values with which to initialize the components. |
Quaternion(Vector4)
Initializes a new instance of the Quaternion struct.
Declaration
public Quaternion(Vector4 value)
Parameters
|
Vector4
value
A vector containing the values with which to initialize the components. |
Quaternion(Single, Single, Single, Single)
Initializes a new instance of the Quaternion struct.
Declaration
public Quaternion(float x, float y, float z, float w)
Parameters
|
System.Single
x
Initial value for the X component of the quaternion. |
|
System.Single
y
Initial value for the Y component of the quaternion. |
|
System.Single
z
Initial value for the Z component of the quaternion. |
|
System.Single
w
Initial value for the W component of the quaternion. |
Quaternion(Single[])
Initializes a new instance of the Quaternion struct.
Declaration
public Quaternion(float[] values)
Parameters
|
System.Single[]
values
The values to assign to the X, Y, Z, and W components of the quaternion. This must be an array with four elements. |
Exceptions
|
System.ArgumentNullException
Thrown when |
|
System.ArgumentOutOfRangeException
Thrown when |
Fields
Identity
The identity Quaternion (0, 0, 0, 1).
Declaration
public static readonly Quaternion Identity
Field Value
|
Quaternion
|
One
A Quaternion with all of its components set to one.
Declaration
public static readonly Quaternion One
Field Value
|
Quaternion
|
SizeInBytes
The size of the Quaternion type, in bytes.
Declaration
public static readonly int SizeInBytes
Field Value
|
System.Int32
|
Tolerance
Equality tolerance factor used when comparing quaternions via dot operation.
Declaration
[Unmanaged]
public const float Tolerance = 0.999999F
Field Value
|
System.Single
|
W
The W component of the quaternion.
Declaration
public float W
Field Value
|
System.Single
|
X
The X component of the quaternion.
Declaration
public float X
Field Value
|
System.Single
|
Y
The Y component of the quaternion.
Declaration
public float Y
Field Value
|
System.Single
|
Z
The Z component of the quaternion.
Declaration
public float Z
Field Value
|
System.Single
|
Zero
A Quaternion with all of its components set to zero.
Declaration
public static readonly Quaternion Zero
Field Value
|
Quaternion
|
Properties
Angle
Gets the angle of the quaternion.
Declaration
public float Angle { get; }
Property Value
|
System.Single
|
Axis
Gets the axis components of the quaternion.
Declaration
public Float3 Axis { get; }
Property Value
|
Float3
|
Default
The default Quaternion.
Declaration
public static Quaternion Default { get; }
Property Value
|
Quaternion
|
EulerAngles
Gets the euler angle (pitch, yaw, roll) in degrees.
Declaration
public Float3 EulerAngles { get; }
Property Value
|
Float3
|
IsIdentity
Gets a value indicating whether this instance is equivalent to the identity quaternion.
Declaration
public bool IsIdentity { get; }
Property Value
|
System.Boolean
|
IsNormalized
Gets a value indicting whether this instance is normalized.
Declaration
public bool IsNormalized { get; }
Property Value
|
System.Boolean
|
Item[Int32]
Gets or sets the component at the specified index.
Declaration
public float this[int index] { get; set; }
Parameters
|
System.Int32
index
The index of the component to access. Use 0 for the X component, 1 for the Y component, 2 for the Z component, and 3 for the W component. |
Property Value
|
System.Single
The value of the X, Y, Z, or W component, depending on the index. |
Exceptions
|
System.ArgumentOutOfRangeException
Thrown when the |
Length
Calculates the length of the quaternion.
Declaration
public float Length { get; }
Property Value
|
System.Single
The length of the quaternion. |
Remarks
LengthSquared may be preferred when only the relative length is needed and speed is of the essence.
LengthSquared
Calculates the squared length of the quaternion.
Declaration
public float LengthSquared { get; }
Property Value
|
System.Single
The squared length of the quaternion. |
Remarks
This method may be preferred to Length when only a relative length is needed and speed is of the essence.
Methods
Add(Quaternion, Quaternion)
Adds two quaternions.
Declaration
public static Quaternion Add(Quaternion left, Quaternion right)
Parameters
|
Quaternion
left
The first quaternion to add. |
|
Quaternion
right
The second quaternion to add. |
Returns
|
Quaternion
The sum of the two quaternions. |
Add(ref Quaternion, ref Quaternion, out Quaternion)
Adds two quaternions.
Declaration
public static void Add(ref Quaternion left, ref Quaternion right, out Quaternion result)
Parameters
|
Quaternion
left
The first quaternion to add. |
|
Quaternion
right
The second quaternion to add. |
|
Quaternion
result
When the method completes, contains the sum of the two quaternions. |
AngleBetween(Quaternion, Quaternion)
Calculates the angle between two quaternions.
Declaration
public static float AngleBetween(Quaternion a, Quaternion b)
Parameters
|
Quaternion
a
First source quaternion. |
|
Quaternion
b
Second source quaternion. |
Returns
|
System.Single
Returns the angle in degrees between two rotations a and b. |
Barycentric(Quaternion, Quaternion, Quaternion, Single, Single)
Returns a Quaternion containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 2D triangle.
Declaration
public static Quaternion Barycentric(Quaternion value1, Quaternion value2, Quaternion value3, float amount1, float amount2)
Parameters
|
Quaternion
value1
A Quaternion containing the 4D Cartesian coordinates of vertex 1 of the triangle. |
|
Quaternion
value2
A Quaternion containing the 4D Cartesian coordinates of vertex 2 of the triangle. |
|
Quaternion
value3
A Quaternion containing the 4D Cartesian coordinates of vertex 3 of the triangle. |
|
System.Single
amount1
Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in |
|
System.Single
amount2
Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in |
Returns
|
Quaternion
A new Quaternion containing the 4D Cartesian coordinates of the specified point. |
Barycentric(ref Quaternion, ref Quaternion, ref Quaternion, Single, Single, out Quaternion)
Returns a Quaternion containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 2D triangle.
Declaration
public static void Barycentric(ref Quaternion value1, ref Quaternion value2, ref Quaternion value3, float amount1, float amount2, out Quaternion result)
Parameters
|
Quaternion
value1
A Quaternion containing the 4D Cartesian coordinates of vertex 1 of the triangle. |
|
Quaternion
value2
A Quaternion containing the 4D Cartesian coordinates of vertex 2 of the triangle. |
|
Quaternion
value3
A Quaternion containing the 4D Cartesian coordinates of vertex 3 of the triangle. |
|
System.Single
amount1
Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in |
|
System.Single
amount2
Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in |
|
Quaternion
result
When the method completes, contains a new Quaternion containing the 4D Cartesian coordinates of the specified point. |
Billboard(Float3, Float3, Float3, Float3)
Creates a left-handed spherical billboard that rotates around a specified object position.
Declaration
public static Quaternion Billboard(Float3 objectPosition, Float3 cameraPosition, Float3 cameraUpVector, Float3 cameraForwardVector)
Parameters
|
Float3
objectPosition
The position of the object around which the billboard will rotate. |
|
Float3
cameraPosition
The position of the camera. |
|
Float3
cameraUpVector
The up vector of the camera. |
|
Float3
cameraForwardVector
The forward vector of the camera. |
Returns
|
Quaternion
The created billboard quaternion. |
Billboard(ref Float3, ref Float3, ref Float3, ref Float3, out Quaternion)
Creates a left-handed spherical billboard that rotates around a specified object position.
Declaration
public static void Billboard(ref Float3 objectPosition, ref Float3 cameraPosition, ref Float3 cameraUpVector, ref Float3 cameraForwardVector, out Quaternion result)
Parameters
|
Float3
objectPosition
The position of the object around which the billboard will rotate. |
|
Float3
cameraPosition
The position of the camera. |
|
Float3
cameraUpVector
The up vector of the camera. |
|
Float3
cameraForwardVector
The forward vector of the camera. |
|
Quaternion
result
When the method completes, contains the created billboard quaternion. |
Conjugate()
Conjugates the quaternion.
Declaration
public void Conjugate()
Conjugate(Quaternion)
Conjugates a quaternion.
Declaration
public static Quaternion Conjugate(Quaternion value)
Parameters
|
Quaternion
value
The quaternion to conjugate. |
Returns
|
Quaternion
The conjugated quaternion. |
Conjugate(ref Quaternion, out Quaternion)
Conjugates a quaternion.
Declaration
public static void Conjugate(ref Quaternion value, out Quaternion result)
Parameters
|
Quaternion
value
The quaternion to conjugate. |
|
Quaternion
result
When the method completes, contains the conjugated quaternion. |
Conjugated()
Dot(Quaternion, Quaternion)
Calculates the dot product of two quaternions.
Declaration
public static float Dot(Quaternion left, Quaternion right)
Parameters
|
Quaternion
left
First source quaternion. |
|
Quaternion
right
Second source quaternion. |
Returns
|
System.Single
The dot product of the two quaternions. |
Dot(ref Quaternion, ref Quaternion)
Calculates the dot product of two quaternions.
Declaration
public static float Dot(ref Quaternion left, ref Quaternion right)
Parameters
|
Quaternion
left
First source quaternion. |
|
Quaternion
right
Second source quaternion. |
Returns
|
System.Single
The dot product of the two quaternions. |
Equals(Quaternion)
Determines whether the specified Quaternion is equal to this instance.
Declaration
public bool Equals(Quaternion other)
Parameters
|
Quaternion
other
The Quaternion to compare with this instance. |
Returns
|
System.Boolean
|
Equals(ref Quaternion)
Determines whether the specified Quaternion is equal to this instance.
Declaration
public bool Equals(ref Quaternion other)
Parameters
|
Quaternion
other
The Quaternion to compare with this instance. |
Returns
|
System.Boolean
|
Equals(Object)
Determines whether the specified System.Object is equal to this instance.
Declaration
public override bool Equals(object value)
Parameters
|
System.Object
value
The System.Object to compare with this instance. |
Returns
|
System.Boolean
|
Euler(Float3)
Creates a quaternion given a pitch, yaw and roll values. Angles are in degrees.
Declaration
public static Quaternion Euler(Float3 eulerAngles)
Parameters
|
Float3
eulerAngles
The pitch, yaw and roll angles of rotation. |
Returns
|
Quaternion
When the method completes, contains the newly created quaternion. |
Euler(ref Float3, out Quaternion)
Creates a quaternion given a pitch, yaw and roll values. Angles are in degrees.
Declaration
public static void Euler(ref Float3 eulerAngles, out Quaternion result)
Parameters
|
Float3
eulerAngles
The pitch, yaw and roll angles of rotation. |
|
Quaternion
result
When the method completes, contains the newly created quaternion. |
Euler(Single, Single, Single)
Creates a quaternion given a pitch, yaw and roll values. Angles are in degrees.
Declaration
public static Quaternion Euler(float x, float y, float z)
Parameters
|
System.Single
x
The pitch of rotation (in degrees). |
|
System.Single
y
The yaw of rotation (in degrees). |
|
System.Single
z
The roll of rotation (in degrees). |
Returns
|
Quaternion
When the method completes, contains the newly created quaternion. |
Euler(Single, Single, Single, out Quaternion)
Creates a quaternion given a pitch, yaw and roll values. Angles are in degrees.
Declaration
public static void Euler(float x, float y, float z, out Quaternion result)
Parameters
|
System.Single
x
The pitch of rotation (in degrees). |
|
System.Single
y
The yaw of rotation (in degrees). |
|
System.Single
z
The roll of rotation (in degrees). |
|
Quaternion
result
When the method completes, contains the newly created quaternion. |
Exponential(Quaternion)
Exponentiates a quaternion.
Declaration
public static Quaternion Exponential(Quaternion value)
Parameters
|
Quaternion
value
The quaternion to exponentiate. |
Returns
|
Quaternion
The exponentiated quaternion. |
Exponential(ref Quaternion, out Quaternion)
Exponentiates a quaternion.
Declaration
public static void Exponential(ref Quaternion value, out Quaternion result)
Parameters
|
Quaternion
value
The quaternion to exponentiate. |
|
Quaternion
result
When the method completes, contains the exponentiated quaternion. |
FindBetween(Float3, Float3)
Gets the quaternion that will rotate vector from into vector to, around their plan perpendicular axis.The input vectors don't need to be normalized.
Declaration
public static Quaternion FindBetween(Float3 from, Float3 to)
Parameters
|
Float3
from
The source vector. |
|
Float3
to
The destination vector. |
Returns
|
Quaternion
The rotation. |
FindBetween(ref Float3, ref Float3, out Quaternion)
Gets the quaternion that will rotate vector from into vector to, around their plan perpendicular axis.The input vectors don't need to be normalized.
Declaration
public static void FindBetween(ref Float3 from, ref Float3 to, out Quaternion result)
Parameters
|
Float3
from
The source vector. |
|
Float3
to
The destination vector. |
|
Quaternion
result
The result. |
FromDirection(Float3)
Calculates the orientation from the direction vector.
Declaration
public static Quaternion FromDirection(Float3 direction)
Parameters
|
Float3
direction
The direction vector (normalized). |
Returns
|
Quaternion
The orientation. |
GetHashCode()
Returns a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
|
System.Int32
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
GetRotationFromNormal(Vector3, Transform)
Gets rotation from a normal in relation to a transform.
This function is especially useful for axis aligned faces,
and with RayCast(Vector3, Vector3, out RayCastHit, Single, UInt32, Boolean).
Example code:
langword_csharp_public langword_csharp_class GetRotationFromNormalExample : Script
langword_csharp_public Actor RayOrigin;
langword_csharp_public Actor SomeObject;
langword_csharp_public langword_csharp_override langword_csharp_void OnFixedUpdate()
{
langword_csharp_if (Physics.RayCast(RayOrigin.Position, RayOrigin.Transform.Forward, out RayCastHit hit)
{
Vector3 position = hit.Collider.Position;
Transform transform = hit.Collider.Transform;
Vector3 point = hit.Point;
Vector3 normal = hit.Normal;
Quaternion rot = Quaternion.GetRotationFromNormal(normal,transform);
SomeObject.Position = point;
SomeObject.Orientation = rot;
}
}
}
Declaration
public static Quaternion GetRotationFromNormal(Vector3 normal, Transform reference)
Parameters
|
Vector3
normal
The normal vector. |
|
Transform
reference
The reference transform. |
Returns
|
Quaternion
The rotation from the normal vector. |
GetRotationFromTo(Float3, Float3, Float3)
Gets the shortest arc quaternion to rotate this vector to the destination vector.
Declaration
public static Quaternion GetRotationFromTo(Float3 from, Float3 to, Float3 fallbackAxis)
Parameters
|
Float3
from
The source vector. |
|
Float3
to
The destination vector. |
|
Float3
fallbackAxis
The fallback axis. |
Returns
|
Quaternion
The rotation. |
GetRotationFromTo(ref Float3, ref Float3, out Quaternion, ref Float3)
Gets the shortest arc quaternion to rotate this vector to the destination vector.
Declaration
public static void GetRotationFromTo(ref Float3 from, ref Float3 to, out Quaternion result, ref Float3 fallbackAxis)
Parameters
|
Float3
from
The source vector. |
|
Float3
to
The destination vector. |
|
Quaternion
result
The result. |
|
Float3
fallbackAxis
The fallback axis. |
Invert()
Conjugates and renormalizes the quaternion.
Declaration
public void Invert()
Invert(Quaternion)
Conjugates and renormalizes the quaternion.
Declaration
public static Quaternion Invert(Quaternion value)
Parameters
|
Quaternion
value
The quaternion to conjugate and renormalize. |
Returns
|
Quaternion
The conjugated and renormalized quaternion. |
Invert(ref Quaternion, out Quaternion)
Conjugates and renormalizes the quaternion.
Declaration
public static void Invert(ref Quaternion value, out Quaternion result)
Parameters
|
Quaternion
value
The quaternion to conjugate and renormalize. |
|
Quaternion
result
When the method completes, contains the conjugated and renormalized quaternion. |
Lerp(Quaternion, Quaternion, Single)
Performs a linear interpolation between two quaternion.
Declaration
public static Quaternion Lerp(Quaternion start, Quaternion end, float amount)
Parameters
|
Quaternion
start
Start quaternion. |
|
Quaternion
end
End quaternion. |
|
System.Single
amount
Value between 0 and 1 indicating the weight of |
Returns
|
Quaternion
The linear interpolation of the two quaternions. |
Remarks
This method performs the linear interpolation based on the following formula.
start + (end - start) * amount
Passing amount a value of 0 will cause start to be returned; a value of 1
will cause end to be returned.
Lerp(ref Quaternion, ref Quaternion, Single, out Quaternion)
Performs a linear interpolation between two quaternions.
Declaration
public static void Lerp(ref Quaternion start, ref Quaternion end, float amount, out Quaternion result)
Parameters
|
Quaternion
start
Start quaternion. |
|
Quaternion
end
End quaternion. |
|
System.Single
amount
Value between 0 and 1 indicating the weight of |
|
Quaternion
result
When the method completes, contains the linear interpolation of the two quaternions. |
Remarks
This method performs the linear interpolation based on the following formula.
start + (end - start) * amount
Passing amount a value of 0 will cause start to be returned; a value of 1
will cause end to be returned.
Logarithm(Quaternion)
Calculates the natural logarithm of the specified quaternion.
Declaration
public static Quaternion Logarithm(Quaternion value)
Parameters
|
Quaternion
value
The quaternion whose logarithm will be calculated. |
Returns
|
Quaternion
The natural logarithm of the quaternion. |
Logarithm(ref Quaternion, out Quaternion)
Calculates the natural logarithm of the specified quaternion.
Declaration
public static void Logarithm(ref Quaternion value, out Quaternion result)
Parameters
|
Quaternion
value
The quaternion whose logarithm will be calculated. |
|
Quaternion
result
When the method completes, contains the natural logarithm of the quaternion. |
LookAt(Float3, Float3)
Creates a left-handed, look-at quaternion.
Declaration
public static Quaternion LookAt(Float3 eye, Float3 target)
Parameters
|
Float3
eye
The position of the viewer's eye. |
|
Float3
target
The camera look-at target. |
Returns
|
Quaternion
The created look-at quaternion. |
LookAt(Float3, Float3, Float3)
Creates a left-handed, look-at quaternion.
Declaration
public static Quaternion LookAt(Float3 eye, Float3 target, Float3 up)
Parameters
|
Float3
eye
The position of the viewer's eye. |
|
Float3
target
The camera look-at target. |
|
Float3
up
The camera's up vector. |
Returns
|
Quaternion
The created look-at quaternion. |
LookAt(ref Float3, ref Float3, ref Float3, out Quaternion)
Creates a left-handed, look-at quaternion.
Declaration
public static void LookAt(ref Float3 eye, ref Float3 target, ref Float3 up, out Quaternion result)
Parameters
|
Float3
eye
The position of the viewer's eye. |
|
Float3
target
The camera look-at target. |
|
Float3
up
The camera's up vector. |
|
Quaternion
result
When the method completes, contains the created look-at quaternion. |
LookRotation(Float3)
Creates a rotation with the specified forward and upwards directions.
Declaration
public static Quaternion LookRotation(Float3 forward)
Parameters
|
Float3
forward
The forward direction. Direction to orient towards. |
Returns
|
Quaternion
The calculated quaternion. |
LookRotation(Float3, Float3)
Creates a rotation with the specified forward and upwards directions.
Declaration
public static Quaternion LookRotation(Float3 forward, Float3 up)
Parameters
|
Float3
forward
The forward direction. Direction to orient towards. |
|
Float3
up
Up direction. Constrains y axis orientation to a plane this vector lies on. This rule might be broken if forward and up direction are nearly parallel. |
Returns
|
Quaternion
The calculated quaternion. |
LookRotation(ref Float3, ref Float3, out Quaternion)
Creates a rotation with the specified forward and upwards directions.
Declaration
public static void LookRotation(ref Float3 forward, ref Float3 up, out Quaternion result)
Parameters
|
Float3
forward
The forward direction. Direction to orient towards. |
|
Float3
up
The up direction. Constrains y axis orientation to a plane this vector lies on. This rule might be broken if forward and up direction are nearly parallel. |
|
Quaternion
result
The calculated quaternion. |
Multiply(Quaternion, Quaternion)
Multiplies a quaternion by another.
Declaration
public static Quaternion Multiply(Quaternion left, Quaternion right)
Parameters
|
Quaternion
left
The first quaternion to multiply. |
|
Quaternion
right
The second quaternion to multiply. |
Returns
|
Quaternion
The multiplied quaternion. |
Multiply(Quaternion, Single)
Scales a quaternion by the given value.
Declaration
public static Quaternion Multiply(Quaternion value, float scale)
Parameters
|
Quaternion
value
The quaternion to scale. |
|
System.Single
scale
The amount by which to scale the quaternion. |
Returns
|
Quaternion
The scaled quaternion. |
Multiply(ref Quaternion, ref Quaternion, out Quaternion)
Multiplies a quaternion by another.
Declaration
public static void Multiply(ref Quaternion left, ref Quaternion right, out Quaternion result)
Parameters
|
Quaternion
left
The first quaternion to multiply. |
|
Quaternion
right
The second quaternion to multiply. |
|
Quaternion
result
When the method completes, contains the multiplied quaternion. |
Multiply(ref Quaternion, Single, out Quaternion)
Scales a quaternion by the given value.
Declaration
public static void Multiply(ref Quaternion value, float scale, out Quaternion result)
Parameters
|
Quaternion
value
The quaternion to scale. |
|
System.Single
scale
The amount by which to scale the quaternion. |
|
Quaternion
result
When the method completes, contains the scaled quaternion. |
NearEqual(Quaternion, Quaternion, Single)
Tests whether one quaternion is near another quaternion.
Declaration
public static bool NearEqual(Quaternion left, Quaternion right, float epsilon = 1E-06F)
Parameters
|
Quaternion
left
The left quaternion. |
|
Quaternion
right
The right quaternion. |
|
System.Single
epsilon
The epsilon. |
Returns
|
System.Boolean
|
NearEqual(ref Quaternion, ref Quaternion, Single)
Tests whether one quaternion is near another quaternion.
Declaration
public static bool NearEqual(ref Quaternion left, ref Quaternion right, float epsilon = 1E-06F)
Parameters
|
Quaternion
left
The left quaternion. |
|
Quaternion
right
The right quaternion. |
|
System.Single
epsilon
The epsilon. |
Returns
|
System.Boolean
|
Negate(Quaternion)
Reverses the direction of a given quaternion.
Declaration
public static Quaternion Negate(Quaternion value)
Parameters
|
Quaternion
value
The quaternion to negate. |
Returns
|
Quaternion
A quaternion facing in the opposite direction. |
Negate(ref Quaternion, out Quaternion)
Reverses the direction of a given quaternion.
Declaration
public static void Negate(ref Quaternion value, out Quaternion result)
Parameters
|
Quaternion
value
The quaternion to negate. |
|
Quaternion
result
When the method completes, contains a quaternion facing in the opposite direction. |
Normalize()
Converts the quaternion into a unit quaternion.
Declaration
public void Normalize()
Normalize(Quaternion)
Converts the quaternion into a unit quaternion.
Declaration
public static Quaternion Normalize(Quaternion value)
Parameters
|
Quaternion
value
The quaternion to normalize. |
Returns
|
Quaternion
The normalized quaternion. |
Normalize(ref Quaternion, out Quaternion)
Converts the quaternion into a unit quaternion.
Declaration
public static void Normalize(ref Quaternion value, out Quaternion result)
Parameters
|
Quaternion
value
The quaternion to normalize. |
|
Quaternion
result
When the method completes, contains the normalized quaternion. |
RotationAxis(Float3, Single)
Creates a quaternion given a rotation and an axis.
Declaration
public static Quaternion RotationAxis(Float3 axis, float angle)
Parameters
|
Float3
axis
The axis of rotation. |
|
System.Single
angle
The angle of rotation (in radians). |
Returns
|
Quaternion
The newly created quaternion. |
RotationAxis(ref Float3, Single, out Quaternion)
Creates a quaternion given a rotation and an axis.
Declaration
public static void RotationAxis(ref Float3 axis, float angle, out Quaternion result)
Parameters
|
Float3
axis
The axis of rotation. |
|
System.Single
angle
The angle of rotation (in radians). |
|
Quaternion
result
When the method completes, contains the newly created quaternion. |
RotationLookAt(Float3)
Creates a left-handed, look-at quaternion.
Declaration
public static Quaternion RotationLookAt(Float3 forward)
Parameters
|
Float3
forward
The camera's forward direction. |
Returns
|
Quaternion
The created look-at quaternion. |
RotationLookAt(Float3, Float3)
Creates a left-handed, look-at quaternion.
Declaration
public static Quaternion RotationLookAt(Float3 forward, Float3 up)
Parameters
|
Float3
forward
The camera's forward direction. |
|
Float3
up
The camera's up vector. |
Returns
|
Quaternion
The created look-at quaternion. |
RotationLookAt(ref Float3, ref Float3, out Quaternion)
Creates a left-handed, look-at quaternion.
Declaration
public static void RotationLookAt(ref Float3 forward, ref Float3 up, out Quaternion result)
Parameters
|
Float3
forward
The camera's forward direction. |
|
Float3
up
The camera's up vector. |
|
Quaternion
result
When the method completes, contains the created look-at quaternion. |
RotationMatrix(Matrix)
Creates a quaternion given a rotation matrix.
Declaration
public static Quaternion RotationMatrix(Matrix matrix)
Parameters
|
Matrix
matrix
The rotation matrix. |
Returns
|
Quaternion
The newly created quaternion. |
RotationMatrix(ref Matrix, out Quaternion)
Creates a quaternion given a rotation matrix.
Declaration
public static void RotationMatrix(ref Matrix matrix, out Quaternion result)
Parameters
|
Matrix
matrix
The rotation matrix. |
|
Quaternion
result
When the method completes, contains the newly created quaternion. |
RotationMatrix(ref Matrix3x3, out Quaternion)
Creates a quaternion given a rotation matrix.
Declaration
public static void RotationMatrix(ref Matrix3x3 matrix, out Quaternion result)
Parameters
|
Matrix3x3
matrix
The rotation matrix. |
|
Quaternion
result
When the method completes, contains the newly created quaternion. |
RotationX(Single)
Creates a quaternion that rotates around the x-axis.
Declaration
public static Quaternion RotationX(float angle)
Parameters
|
System.Single
angle
Angle of rotation in radians. |
Returns
|
Quaternion
The created rotation quaternion. |
RotationX(Single, out Quaternion)
Creates a quaternion that rotates around the x-axis.
Declaration
public static void RotationX(float angle, out Quaternion result)
Parameters
|
System.Single
angle
Angle of rotation in radians. |
|
Quaternion
result
When the method completes, contains the newly created quaternion. |
RotationY(Single)
Creates a quaternion that rotates around the y-axis.
Declaration
public static Quaternion RotationY(float angle)
Parameters
|
System.Single
angle
Angle of rotation in radians. |
Returns
|
Quaternion
The created rotation quaternion. |
RotationY(Single, out Quaternion)
Creates a quaternion that rotates around the y-axis.
Declaration
public static void RotationY(float angle, out Quaternion result)
Parameters
|
System.Single
angle
Angle of rotation in radians. |
|
Quaternion
result
When the method completes, contains the newly created quaternion. |
RotationYawPitchRoll(Single, Single, Single)
Creates a quaternion given a yaw, pitch, and roll value. Angles are in radians.
Declaration
public static Quaternion RotationYawPitchRoll(float yaw, float pitch, float roll)
Parameters
|
System.Single
yaw
The yaw of rotation (in radians). |
|
System.Single
pitch
The pitch of rotation (in radians). |
|
System.Single
roll
The roll of rotation (in radians). |
Returns
|
Quaternion
The newly created quaternion (in radians). |
RotationYawPitchRoll(Single, Single, Single, out Quaternion)
Creates a quaternion given a yaw, pitch, and roll value. Angles are in radians. Use FlaxEngine.Mathf.RadiansToDegrees to convert degrees to radians.
Declaration
public static void RotationYawPitchRoll(float yaw, float pitch, float roll, out Quaternion result)
Parameters
|
System.Single
yaw
The yaw of rotation (in radians). |
|
System.Single
pitch
The pitch of rotation (in radians). |
|
System.Single
roll
The roll of rotation (in radians). |
|
Quaternion
result
When the method completes, contains the newly created quaternion. |
RotationZ(Single)
Creates a quaternion that rotates around the z-axis.
Declaration
public static Quaternion RotationZ(float angle)
Parameters
|
System.Single
angle
Angle of rotation in radians. |
Returns
|
Quaternion
The created rotation quaternion. |
RotationZ(Single, out Quaternion)
Creates a quaternion that rotates around the z-axis.
Declaration
public static void RotationZ(float angle, out Quaternion result)
Parameters
|
System.Single
angle
Angle of rotation in radians. |
|
Quaternion
result
When the method completes, contains the newly created quaternion. |
Slerp(Quaternion, Quaternion, Single)
Interpolates between two quaternions, using spherical linear interpolation.
Declaration
public static Quaternion Slerp(Quaternion start, Quaternion end, float amount)
Parameters
|
Quaternion
start
Start quaternion. |
|
Quaternion
end
End quaternion. |
|
System.Single
amount
Value between 0 and 1 indicating the weight of |
Returns
|
Quaternion
The spherical linear interpolation of the two quaternions. |
Slerp(ref Quaternion, ref Quaternion, Single, out Quaternion)
Interpolates between two quaternions, using spherical linear interpolation.
Declaration
public static void Slerp(ref Quaternion start, ref Quaternion end, float amount, out Quaternion result)
Parameters
|
Quaternion
start
Start quaternion. |
|
Quaternion
end
End quaternion. |
|
System.Single
amount
Value between 0 and 1 indicating the weight of |
|
Quaternion
result
When the method completes, contains the spherical linear interpolation of the two quaternions. |
Squad(Quaternion, Quaternion, Quaternion, Quaternion, Single)
Interpolates between quaternions, using spherical quadrangle interpolation.
Declaration
public static Quaternion Squad(Quaternion value1, Quaternion value2, Quaternion value3, Quaternion value4, float amount)
Parameters
|
Quaternion
value1
First source quaternion. |
|
Quaternion
value2
Second source quaternion. |
|
Quaternion
value3
Third source quaternion. |
|
Quaternion
value4
Fourth source quaternion. |
|
System.Single
amount
Value between 0 and 1 indicating the weight of interpolation. |
Returns
|
Quaternion
The spherical quadrangle interpolation of the quaternions. |
Squad(ref Quaternion, ref Quaternion, ref Quaternion, ref Quaternion, Single, out Quaternion)
Interpolates between quaternions, using spherical quadrangle interpolation.
Declaration
public static void Squad(ref Quaternion value1, ref Quaternion value2, ref Quaternion value3, ref Quaternion value4, float amount, out Quaternion result)
Parameters
|
Quaternion
value1
First source quaternion. |
|
Quaternion
value2
Second source quaternion. |
|
Quaternion
value3
Third source quaternion. |
|
Quaternion
value4
Fourth source quaternion. |
|
System.Single
amount
Value between 0 and 1 indicating the weight of interpolation. |
|
Quaternion
result
When the method completes, contains the spherical quadrangle interpolation of the quaternions. |
SquadSetup(Quaternion, Quaternion, Quaternion, Quaternion)
Sets up control points for spherical quadrangle interpolation.
Declaration
public static Quaternion[] SquadSetup(Quaternion value1, Quaternion value2, Quaternion value3, Quaternion value4)
Parameters
|
Quaternion
value1
First source quaternion. |
|
Quaternion
value2
Second source quaternion. |
|
Quaternion
value3
Third source quaternion. |
|
Quaternion
value4
Fourth source quaternion. |
Returns
|
Quaternion[]
An array of three quaternions that represent control points for spherical quadrangle interpolation. |
Subtract(Quaternion, Quaternion)
Subtracts two quaternions.
Declaration
public static Quaternion Subtract(Quaternion left, Quaternion right)
Parameters
|
Quaternion
left
The first quaternion to subtract. |
|
Quaternion
right
The second quaternion to subtract. |
Returns
|
Quaternion
The difference of the two quaternions. |
Subtract(ref Quaternion, ref Quaternion, out Quaternion)
Subtracts two quaternions.
Declaration
public static void Subtract(ref Quaternion left, ref Quaternion right, out Quaternion result)
Parameters
|
Quaternion
left
The first quaternion to subtract. |
|
Quaternion
right
The second quaternion to subtract. |
|
Quaternion
result
When the method completes, contains the difference of the two quaternions. |
ToArray()
Creates an array containing the elements of the quaternion.
Declaration
public float[] ToArray()
Returns
|
System.Single[]
A four-element array containing the components of the quaternion. |
ToString()
Returns a System.String that represents this instance.
Declaration
public override string ToString()
Returns
|
System.String
A System.String that represents this instance. |
ToString(IFormatProvider)
Returns a System.String that represents this instance.
Declaration
public string ToString(IFormatProvider formatProvider)
Parameters
|
System.IFormatProvider
formatProvider
The format provider. |
Returns
|
System.String
A System.String that represents this instance. |
ToString(String)
Returns a System.String that represents this instance.
Declaration
public string ToString(string format)
Parameters
|
System.String
format
The format. |
Returns
|
System.String
A System.String that represents this instance. |
ToString(String, IFormatProvider)
Returns a System.String that represents this instance.
Declaration
public string ToString(string format, IFormatProvider formatProvider)
Parameters
|
System.String
format
The format. |
|
System.IFormatProvider
formatProvider
The format provider. |
Returns
|
System.String
A System.String that represents this instance. |
Operators
Addition(Quaternion, Quaternion)
Adds two quaternions.
Declaration
public static Quaternion operator +(Quaternion left, Quaternion right)
Parameters
|
Quaternion
left
The first quaternion to add. |
|
Quaternion
right
The second quaternion to add. |
Returns
|
Quaternion
The sum of the two quaternions. |
Equality(Quaternion, Quaternion)
Tests for equality between two objects.
Declaration
public static bool operator ==(Quaternion left, Quaternion right)
Parameters
|
Quaternion
left
The first value to compare. |
|
Quaternion
right
The second value to compare. |
Returns
|
System.Boolean
|
Inequality(Quaternion, Quaternion)
Tests for inequality between two objects.
Declaration
public static bool operator !=(Quaternion left, Quaternion right)
Parameters
|
Quaternion
left
The first value to compare. |
|
Quaternion
right
The second value to compare. |
Returns
|
System.Boolean
|
Multiply(Quaternion, Quaternion)
Multiplies a quaternion by another.
Declaration
public static Quaternion operator *(Quaternion left, Quaternion right)
Parameters
|
Quaternion
left
The first quaternion to multiply. |
|
Quaternion
right
The second quaternion to multiply. |
Returns
|
Quaternion
The multiplied quaternion. |
Multiply(Quaternion, Single)
Scales a quaternion by the given value.
Declaration
public static Quaternion operator *(Quaternion value, float scale)
Parameters
|
Quaternion
value
The quaternion to scale. |
|
System.Single
scale
The amount by which to scale the quaternion. |
Returns
|
Quaternion
The scaled quaternion. |
Multiply(Single, Quaternion)
Scales a quaternion by the given value.
Declaration
public static Quaternion operator *(float scale, Quaternion value)
Parameters
|
System.Single
scale
The amount by which to scale the quaternion. |
|
Quaternion
value
The quaternion to scale. |
Returns
|
Quaternion
The scaled quaternion. |
Subtraction(Quaternion, Quaternion)
Subtracts two quaternions.
Declaration
public static Quaternion operator -(Quaternion left, Quaternion right)
Parameters
|
Quaternion
left
The first quaternion to subtract. |
|
Quaternion
right
The second quaternion to subtract. |
Returns
|
Quaternion
The difference of the two quaternions. |
UnaryNegation(Quaternion)
Reverses the direction of a given quaternion.
Declaration
public static Quaternion operator -(Quaternion value)
Parameters
|
Quaternion
value
The quaternion to negate. |
Returns
|
Quaternion
A quaternion facing in the opposite direction. |