Struct Quaternion
- Namespace
- Stride.Core.Mathematics
- Assembly
- Stride.Core.Mathematics.dll
Represents a four dimensional mathematical quaternion.
[DataContract("quaternion")]
[DataStyle(DataStyle.Compact)]
public struct Quaternion : IEquatable<Quaternion>, IFormattable
- Implements
Constructors
Quaternion(Vector2, float, float)
Initializes a new instance of the Quaternion struct.
public Quaternion(Vector2 value, float z, float w)
Parameters
value
Vector2A vector containing the values with which to initialize the X and Y components.
z
floatInitial value for the Z component of the quaternion.
w
floatInitial value for the W component of the quaternion.
Quaternion(Vector3, float)
Initializes a new instance of the Quaternion struct.
public Quaternion(Vector3 value, float w)
Parameters
value
Vector3A vector containing the values with which to initialize the X, Y, and Z components.
w
floatInitial value for the W component of the quaternion.
Quaternion(Vector4)
Initializes a new instance of the Quaternion struct.
public Quaternion(Vector4 value)
Parameters
value
Vector4A vector containing the values with which to initialize the components.
Quaternion(float)
Initializes a new instance of the Quaternion struct.
public Quaternion(float value)
Parameters
value
floatThe value that will be assigned to all components.
Quaternion(float, float, float, float)
Initializes a new instance of the Quaternion struct.
public Quaternion(float x, float y, float z, float w)
Parameters
x
floatInitial value for the X component of the quaternion.
y
floatInitial value for the Y component of the quaternion.
z
floatInitial value for the Z component of the quaternion.
w
floatInitial value for the W component of the quaternion.
Quaternion(float[])
Initializes a new instance of the Quaternion struct.
public Quaternion(float[] values)
Parameters
values
float[]The values to assign to the X, Y, Z, and W components of the quaternion. This must be an array with four elements.
Exceptions
- ArgumentNullException
Thrown when
values
isnull
.- ArgumentOutOfRangeException
Thrown when
values
contains more or less than four elements.
Fields
Identity
The identity Quaternion (0, 0, 0, 1).
public static readonly Quaternion Identity
Field Value
One
A Quaternion with all of its components set to one.
public static readonly Quaternion One
Field Value
SizeInBytes
The size of the Quaternion type, in bytes.
public static readonly int SizeInBytes
Field Value
W
The W component of the quaternion.
public float W
Field Value
X
The X component of the quaternion.
public float X
Field Value
Y
The Y component of the quaternion.
public float Y
Field Value
Z
The Z component of the quaternion.
public float Z
Field Value
Zero
A Quaternion with all of its components set to zero.
public static readonly Quaternion Zero
Field Value
Properties
Angle
Gets the angle of the quaternion.
public float Angle { get; }
Property Value
- float
The quaternion's angle.
Axis
Gets the axis components of the quaternion.
public Vector3 Axis { get; }
Property Value
- Vector3
The axis components of the quaternion.
IsIdentity
Gets a value indicating whether this instance is equivalent to the identity quaternion.
public bool IsIdentity { get; }
Property Value
- bool
true
if this instance is an identity quaternion; otherwise,false
.
IsNormalized
Gets a value indicting whether this instance is normalized.
public bool IsNormalized { get; }
Property Value
this[int]
Gets or sets the component at the specified index.
public float this[int index] { get; set; }
Parameters
index
intThe 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
- float
The value of the X, Y, Z, or W component, depending on the index.
Exceptions
- ArgumentOutOfRangeException
Thrown when the
index
is out of the range [0, 3].
YawPitchRoll
Gets yaw/pitch/roll equivalent of the quaternion
public Vector3 YawPitchRoll { get; }
Property Value
Methods
Add(Quaternion, Quaternion)
Adds two quaternions.
public static Quaternion Add(Quaternion left, Quaternion right)
Parameters
left
QuaternionThe first quaternion to add.
right
QuaternionThe second quaternion to add.
Returns
- Quaternion
The sum of the two quaternions.
Add(ref Quaternion, ref Quaternion, out Quaternion)
Adds two quaternions.
public static void Add(ref Quaternion left, ref Quaternion right, out Quaternion result)
Parameters
left
QuaternionThe first quaternion to add.
right
QuaternionThe second quaternion to add.
result
QuaternionWhen the method completes, contains the sum of the two quaternions.
AngleBetween(in Quaternion, in Quaternion)
Returns the absolute angle in radians between a
and b
public static float AngleBetween(in Quaternion a, in Quaternion b)
Parameters
a
Quaternionb
Quaternion
Returns
Barycentric(Quaternion, Quaternion, Quaternion, float, float)
Returns a Quaternion containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 2D triangle.
public static Quaternion Barycentric(Quaternion value1, Quaternion value2, Quaternion value3, float amount1, float amount2)
Parameters
value1
QuaternionA Quaternion containing the 4D Cartesian coordinates of vertex 1 of the triangle.
value2
QuaternionA Quaternion containing the 4D Cartesian coordinates of vertex 2 of the triangle.
value3
QuaternionA Quaternion containing the 4D Cartesian coordinates of vertex 3 of the triangle.
amount1
floatBarycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in
value2
).amount2
floatBarycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in
value3
).
Returns
- Quaternion
A new Quaternion containing the 4D Cartesian coordinates of the specified point.
Barycentric(ref Quaternion, ref Quaternion, ref Quaternion, float, float, out Quaternion)
Returns a Quaternion containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 2D triangle.
public static void Barycentric(ref Quaternion value1, ref Quaternion value2, ref Quaternion value3, float amount1, float amount2, out Quaternion result)
Parameters
value1
QuaternionA Quaternion containing the 4D Cartesian coordinates of vertex 1 of the triangle.
value2
QuaternionA Quaternion containing the 4D Cartesian coordinates of vertex 2 of the triangle.
value3
QuaternionA Quaternion containing the 4D Cartesian coordinates of vertex 3 of the triangle.
amount1
floatBarycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in
value2
).amount2
floatBarycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in
value3
).result
QuaternionWhen the method completes, contains a new Quaternion containing the 4D Cartesian coordinates of the specified point.
BetweenDirections(Vector3, Vector3)
Computes a quaternion corresponding to the rotation transforming the vector source
to the vector target
.
public static Quaternion BetweenDirections(Vector3 source, Vector3 target)
Parameters
source
Vector3The source vector of the transformation.
target
Vector3The target vector of the transformation.
Returns
- Quaternion
The resulting quaternion corresponding to the transformation of the source vector to the target vector.
BetweenDirections(ref Vector3, ref Vector3, out Quaternion)
Computes a quaternion corresponding to the rotation transforming the vector source
to the vector target
.
public static void BetweenDirections(ref Vector3 source, ref Vector3 target, out Quaternion result)
Parameters
source
Vector3The source vector of the transformation.
target
Vector3The target vector of the transformation.
result
QuaternionThe resulting quaternion corresponding to the transformation of the source vector to the target vector.
Conjugate()
Conjugates the quaternion.
public void Conjugate()
Conjugate(in Quaternion)
Conjugates a quaternion.
public static Quaternion Conjugate(in Quaternion value)
Parameters
value
QuaternionThe quaternion to conjugate.
Returns
- Quaternion
The conjugated quaternion.
Conjugate(ref Quaternion, out Quaternion)
Conjugates a quaternion.
public static void Conjugate(ref Quaternion value, out Quaternion result)
Parameters
value
QuaternionThe quaternion to conjugate.
result
QuaternionWhen the method completes, contains the conjugated quaternion.
Dot(in Quaternion, in Quaternion)
Calculates the dot product of two quaternions.
public static float Dot(in Quaternion left, in Quaternion right)
Parameters
left
QuaternionFirst source quaternion.
right
QuaternionSecond source quaternion.
Returns
- float
The dot product of the two quaternions.
Dot(ref Quaternion, ref Quaternion, out float)
Calculates the dot product of two quaternions.
public static void Dot(ref Quaternion left, ref Quaternion right, out float result)
Parameters
left
QuaternionFirst source quaternion.
right
QuaternionSecond source quaternion.
result
floatWhen the method completes, contains the dot product of the two quaternions.
Equals(Quaternion)
Determines whether the specified Quaternion is equal to this instance.
public readonly bool Equals(Quaternion other)
Parameters
other
QuaternionThe Quaternion to compare with this instance.
Returns
- bool
true
if the specified Quaternion is equal to this instance; otherwise,false
.
Equals(object)
Determines whether the specified object is equal to this instance.
public override readonly bool Equals(object value)
Parameters
Returns
Exponential(Quaternion)
Exponentiates a quaternion.
public static Quaternion Exponential(Quaternion value)
Parameters
value
QuaternionThe quaternion to exponentiate.
Returns
- Quaternion
The exponentiated quaternion.
Exponential(ref Quaternion, out Quaternion)
Exponentiates a quaternion.
public static void Exponential(ref Quaternion value, out Quaternion result)
Parameters
value
QuaternionThe quaternion to exponentiate.
result
QuaternionWhen the method completes, contains the exponentiated quaternion.
GetHashCode()
Returns a hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
Invert()
Conjugates and renormalizes the quaternion.
public void Invert()
Invert(Quaternion)
Conjugates and renormalizes the quaternion.
public static Quaternion Invert(Quaternion value)
Parameters
value
QuaternionThe quaternion to conjugate and renormalize.
Returns
- Quaternion
The conjugated and renormalized quaternion.
Invert(ref Quaternion, out Quaternion)
Conjugates and renormalizes the quaternion.
public static void Invert(ref Quaternion value, out Quaternion result)
Parameters
value
QuaternionThe quaternion to conjugate and renormalize.
result
QuaternionWhen the method completes, contains the conjugated and renormalized quaternion.
Length()
Calculates the length of the quaternion.
public readonly float Length()
Returns
- float
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.
public readonly float LengthSquared()
Returns
- float
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.
Lerp(Quaternion, Quaternion, float)
Performs a linear interpolation between two quaternion.
public static Quaternion Lerp(Quaternion start, Quaternion end, float amount)
Parameters
start
QuaternionStart quaternion.
end
QuaternionEnd quaternion.
amount
floatValue between 0 and 1 indicating the weight of
end
.
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, float, out Quaternion)
Performs a linear interpolation between two quaternions.
public static void Lerp(ref Quaternion start, ref Quaternion end, float amount, out Quaternion result)
Parameters
start
QuaternionStart quaternion.
end
QuaternionEnd quaternion.
amount
floatValue between 0 and 1 indicating the weight of
end
.result
QuaternionWhen 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.
public static Quaternion Logarithm(Quaternion value)
Parameters
value
QuaternionThe 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.
public static void Logarithm(ref Quaternion value, out Quaternion result)
Parameters
value
QuaternionThe quaternion whose logarithm will be calculated.
result
QuaternionWhen the method completes, contains the natural logarithm of the quaternion.
LookRotation(in Vector3, in Vector3)
Returns a rotation whose facing direction points towards forward
and whose up direction points as close as possible to up
.
public static Quaternion LookRotation(in Vector3 forward, in Vector3 up)
Parameters
Returns
Multiply(Quaternion, float)
Scales a quaternion by the given value.
public static Quaternion Multiply(Quaternion value, float scale)
Parameters
value
QuaternionThe quaternion to scale.
scale
floatThe amount by which to scale the quaternion.
Returns
- Quaternion
The scaled quaternion.
Multiply(in Quaternion, in Quaternion)
Modulates a quaternion by another.
public static Quaternion Multiply(in Quaternion left, in Quaternion right)
Parameters
left
QuaternionThe first quaternion to modulate.
right
QuaternionThe second quaternion to modulate.
Returns
- Quaternion
The modulated quaternion.
Multiply(ref Quaternion, ref Quaternion, out Quaternion)
Modulates a quaternion by another.
public static void Multiply(ref Quaternion left, ref Quaternion right, out Quaternion result)
Parameters
left
QuaternionThe first quaternion to modulate.
right
QuaternionThe second quaternion to modulate.
result
QuaternionWhen the moethod completes, contains the modulated quaternion.
Multiply(ref Quaternion, float, out Quaternion)
Scales a quaternion by the given value.
public static void Multiply(ref Quaternion value, float scale, out Quaternion result)
Parameters
value
QuaternionThe quaternion to scale.
scale
floatThe amount by which to scale the quaternion.
result
QuaternionWhen the method completes, contains the scaled quaternion.
Negate(Quaternion)
Reverses the direction of a given quaternion.
public static Quaternion Negate(Quaternion value)
Parameters
value
QuaternionThe quaternion to negate.
Returns
- Quaternion
A quaternion facing in the opposite direction.
Negate(ref Quaternion, out Quaternion)
Reverses the direction of a given quaternion.
public static void Negate(ref Quaternion value, out Quaternion result)
Parameters
value
QuaternionThe quaternion to negate.
result
QuaternionWhen the method completes, contains a quaternion facing in the opposite direction.
Normalize()
Converts the quaternion into a unit quaternion.
public void Normalize()
Normalize(Quaternion)
Converts the quaternion into a unit quaternion.
public static Quaternion Normalize(Quaternion value)
Parameters
value
QuaternionThe quaternion to normalize.
Returns
- Quaternion
The normalized quaternion.
Normalize(ref Quaternion, out Quaternion)
Converts the quaternion into a unit quaternion.
public static void Normalize(ref Quaternion value, out Quaternion result)
Parameters
value
QuaternionThe quaternion to normalize.
result
QuaternionWhen the method completes, contains the normalized quaternion.
Rotate(ref Vector3)
Rotates a Vector3 by the specified quaternion rotation.
public readonly void Rotate(ref Vector3 vector)
Parameters
vector
Vector3The vector to rotate.
RotateTowards(in Quaternion, in Quaternion, float)
Rotate current
towards target
by angle
.
public static Quaternion RotateTowards(in Quaternion current, in Quaternion target, float angle)
Parameters
current
Quaterniontarget
Quaternionangle
float
Returns
Remarks
When the angle difference between current
and target
is less than
the given angle
, returns target
instead of overshooting past it.
RotationAxis(Vector3, float)
Creates a quaternion given a rotation and an axis.
public static Quaternion RotationAxis(Vector3 axis, float angle)
Parameters
Returns
- Quaternion
The newly created quaternion.
RotationAxis(ref Vector3, float, out Quaternion)
Creates a quaternion given a rotation and an axis.
public static void RotationAxis(ref Vector3 axis, float angle, out Quaternion result)
Parameters
axis
Vector3The axis of rotation.
angle
floatThe angle of rotation.
result
QuaternionWhen the method completes, contains the newly created quaternion.
RotationMatrix(Matrix)
Creates a quaternion given a rotation matrix.
public static Quaternion RotationMatrix(Matrix matrix)
Parameters
matrix
MatrixThe rotation matrix.
Returns
- Quaternion
The newly created quaternion.
RotationMatrix(ref Matrix, out Quaternion)
Creates a quaternion given a rotation matrix.
public static void RotationMatrix(ref Matrix matrix, out Quaternion result)
Parameters
matrix
MatrixThe rotation matrix.
result
QuaternionWhen the method completes, contains the newly created quaternion.
RotationX(float)
Creates a quaternion that rotates around the x-axis.
public static Quaternion RotationX(float angle)
Parameters
angle
floatAngle of rotation in radians.
Returns
- Quaternion
The created rotation quaternion.
RotationX(float, out Quaternion)
Creates a quaternion that rotates around the x-axis.
public static void RotationX(float angle, out Quaternion result)
Parameters
angle
floatAngle of rotation in radians.
result
QuaternionWhen the method completes, contains the newly created quaternion.
RotationY(float)
Creates a quaternion that rotates around the y-axis.
public static Quaternion RotationY(float angle)
Parameters
angle
floatAngle of rotation in radians.
Returns
- Quaternion
The created rotation quaternion.
RotationY(float, out Quaternion)
Creates a quaternion that rotates around the y-axis.
public static void RotationY(float angle, out Quaternion result)
Parameters
angle
floatAngle of rotation in radians.
result
QuaternionWhen the method completes, contains the newly created quaternion.
RotationYawPitchRoll(ref Quaternion, out float, out float, out float)
Calculate the yaw/pitch/roll rotation equivalent to the provided quaternion.
public static void RotationYawPitchRoll(ref Quaternion rotation, out float yaw, out float pitch, out float roll)
Parameters
rotation
QuaternionThe input quaternion
yaw
floatThe yaw component in radians.
pitch
floatThe pitch component in radians.
roll
floatThe roll component in radians.
RotationYawPitchRoll(float, float, float)
Creates a quaternion given a yaw, pitch, and roll value (angles in radians).
public static Quaternion RotationYawPitchRoll(float yaw, float pitch, float roll)
Parameters
yaw
floatThe yaw of rotation in radians.
pitch
floatThe pitch of rotation in radians.
roll
floatThe roll of rotation in radians.
Returns
- Quaternion
The newly created quaternion.
RotationYawPitchRoll(float, float, float, out Quaternion)
Creates a quaternion given a yaw, pitch, and roll value (angles in radians).
public static void RotationYawPitchRoll(float yaw, float pitch, float roll, out Quaternion result)
Parameters
yaw
floatThe yaw of rotation in radians.
pitch
floatThe pitch of rotation in radians.
roll
floatThe roll of rotation in radians.
result
QuaternionWhen the method completes, contains the newly created quaternion.
RotationZ(float)
Creates a quaternion that rotates around the z-axis.
public static Quaternion RotationZ(float angle)
Parameters
angle
floatAngle of rotation in radians.
Returns
- Quaternion
The created rotation quaternion.
RotationZ(float, out Quaternion)
Creates a quaternion that rotates around the z-axis.
public static void RotationZ(float angle, out Quaternion result)
Parameters
angle
floatAngle of rotation in radians.
result
QuaternionWhen the method completes, contains the newly created quaternion.
Slerp(in Quaternion, in Quaternion, float)
Interpolates between two quaternions, using spherical linear interpolation.
public static Quaternion Slerp(in Quaternion start, in Quaternion end, float amount)
Parameters
start
QuaternionStart quaternion.
end
QuaternionEnd quaternion.
amount
floatValue between 0 and 1 indicating the weight of
end
.
Returns
- Quaternion
The spherical linear interpolation of the two quaternions.
Slerp(ref Quaternion, ref Quaternion, float, out Quaternion)
Interpolates between two quaternions, using spherical linear interpolation.
public static void Slerp(ref Quaternion start, ref Quaternion end, float amount, out Quaternion result)
Parameters
start
QuaternionStart quaternion.
end
QuaternionEnd quaternion.
amount
floatValue between 0 and 1 indicating the weight of
end
.result
QuaternionWhen the method completes, contains the spherical linear interpolation of the two quaternions.
Squad(Quaternion, Quaternion, Quaternion, Quaternion, float)
Interpolates between quaternions, using spherical quadrangle interpolation.
public static Quaternion Squad(Quaternion value1, Quaternion value2, Quaternion value3, Quaternion value4, float amount)
Parameters
value1
QuaternionFirst source quaternion.
value2
QuaternionSecond source quaternion.
value3
QuaternionThrid source quaternion.
value4
QuaternionFourth source quaternion.
amount
floatValue 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, float, out Quaternion)
Interpolates between quaternions, using spherical quadrangle interpolation.
public static void Squad(ref Quaternion value1, ref Quaternion value2, ref Quaternion value3, ref Quaternion value4, float amount, out Quaternion result)
Parameters
value1
QuaternionFirst source quaternion.
value2
QuaternionSecond source quaternion.
value3
QuaternionThrid source quaternion.
value4
QuaternionFourth source quaternion.
amount
floatValue between 0 and 1 indicating the weight of interpolation.
result
QuaternionWhen the method completes, contains the spherical quadrangle interpolation of the quaternions.
SquadSetup(Quaternion, Quaternion, Quaternion, Quaternion)
Sets up control points for spherical quadrangle interpolation.
public static Quaternion[] SquadSetup(Quaternion value1, Quaternion value2, Quaternion value3, Quaternion value4)
Parameters
value1
QuaternionFirst source quaternion.
value2
QuaternionSecond source quaternion.
value3
QuaternionThird source quaternion.
value4
QuaternionFourth source quaternion.
Returns
- Quaternion[]
An array of three quaternions that represent control points for spherical quadrangle interpolation.
Subtract(Quaternion, Quaternion)
Subtracts two quaternions.
public static Quaternion Subtract(Quaternion left, Quaternion right)
Parameters
left
QuaternionThe first quaternion to subtract.
right
QuaternionThe second quaternion to subtract.
Returns
- Quaternion
The difference of the two quaternions.
Subtract(ref Quaternion, ref Quaternion, out Quaternion)
Subtracts two quaternions.
public static void Subtract(ref Quaternion left, ref Quaternion right, out Quaternion result)
Parameters
left
QuaternionThe first quaternion to subtract.
right
QuaternionThe second quaternion to subtract.
result
QuaternionWhen the method completes, contains the difference of the two quaternions.
ToArray()
Creates an array containing the elements of the quaternion.
public float[] ToArray()
Returns
- float[]
A four-element array containing the components of the quaternion.
ToString()
Returns a string that represents this instance.
public override readonly string ToString()
Returns
ToString(IFormatProvider)
Returns a string that represents this instance.
public readonly string ToString(IFormatProvider formatProvider)
Parameters
formatProvider
IFormatProviderThe format provider.
Returns
ToString(string)
Returns a string that represents this instance.
public readonly string ToString(string format)
Parameters
format
stringThe format.
Returns
ToString(string, IFormatProvider)
Returns a string that represents this instance.
public readonly string ToString(string format, IFormatProvider formatProvider)
Parameters
format
stringThe format.
formatProvider
IFormatProviderThe format provider.
Returns
Operators
operator +(Quaternion, Quaternion)
Adds two quaternions.
public static Quaternion operator +(Quaternion left, Quaternion right)
Parameters
left
QuaternionThe first quaternion to add.
right
QuaternionThe second quaternion to add.
Returns
- Quaternion
The sum of the two quaternions.
operator ==(in Quaternion, in Quaternion)
Tests for equality between two objects.
public static bool operator ==(in Quaternion left, in Quaternion right)
Parameters
left
QuaternionThe first value to compare.
right
QuaternionThe second value to compare.
Returns
- bool
true
ifleft
has the same value asright
; otherwise,false
.
operator !=(in Quaternion, in Quaternion)
Tests for inequality between two objects.
public static bool operator !=(in Quaternion left, in Quaternion right)
Parameters
left
QuaternionThe first value to compare.
right
QuaternionThe second value to compare.
Returns
- bool
true
ifleft
has a different value thanright
; otherwise,false
.
operator *(Quaternion, float)
Scales a quaternion by the given value.
public static Quaternion operator *(Quaternion value, float scale)
Parameters
value
QuaternionThe quaternion to scale.
scale
floatThe amount by which to scale the quaternion.
Returns
- Quaternion
The scaled quaternion.
operator *(in Quaternion, in Quaternion)
Multiplies a quaternion by another.
public static Quaternion operator *(in Quaternion left, in Quaternion right)
Parameters
left
QuaternionThe first quaternion to multiply.
right
QuaternionThe second quaternion to multiply.
Returns
- Quaternion
The multiplied quaternion.
operator *(in Quaternion, in Vector3)
Return the vector rotated by the quaternion.
public static Vector3 operator *(in Quaternion left, in Vector3 right)
Parameters
left
Quaternionright
Vector3
Returns
Remarks
Shorthand for Rotate(ref Vector3)
operator *(float, Quaternion)
Scales a quaternion by the given value.
public static Quaternion operator *(float scale, Quaternion value)
Parameters
scale
floatThe amount by which to scale the quaternion.
value
QuaternionThe quaternion to scale.
Returns
- Quaternion
The scaled quaternion.
operator -(Quaternion, Quaternion)
Subtracts two quaternions.
public static Quaternion operator -(Quaternion left, Quaternion right)
Parameters
left
QuaternionThe first quaternion to subtract.
right
QuaternionThe second quaternion to subtract.
Returns
- Quaternion
The difference of the two quaternions.
operator -(Quaternion)
Reverses the direction of a given quaternion.
public static Quaternion operator -(Quaternion value)
Parameters
value
QuaternionThe quaternion to negate.
Returns
- Quaternion
A quaternion facing in the opposite direction.