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>, ISpanFormattable, IFormattable
- Implements
Constructors
Quaternion(Vector2, float, float)
Initializes a new instance of the Quaternion struct.
public Quaternion(Vector2 value, float z, float w)
Parameters
valueVector2A vector containing the values with which to initialize the X and Y components.
zfloatInitial value for the Z component of the quaternion.
wfloatInitial 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
valueVector3A vector containing the values with which to initialize the X, Y, and Z components.
wfloatInitial value for the W component of the quaternion.
Quaternion(Vector4)
Initializes a new instance of the Quaternion struct.
public Quaternion(Vector4 value)
Parameters
valueVector4A 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
valuefloatThe 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
xfloatInitial value for the X component of the quaternion.
yfloatInitial value for the Y component of the quaternion.
zfloatInitial value for the Z component of the quaternion.
wfloatInitial value for the W component of the quaternion.
Quaternion(float[])
Initializes a new instance of the Quaternion struct.
public Quaternion(float[] values)
Parameters
valuesfloat[]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
valuesisnull.- ArgumentOutOfRangeException
Thrown when
valuescontains 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
trueif 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
indexintThe 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
indexis 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
leftQuaternionThe first quaternion to add.
rightQuaternionThe second quaternion to add.
Returns
- Quaternion
The sum of the two quaternions.
Add(ref readonly Quaternion, ref readonly Quaternion, out Quaternion)
Adds two quaternions.
public static void Add(ref readonly Quaternion left, ref readonly Quaternion right, out Quaternion result)
Parameters
leftQuaternionThe first quaternion to add.
rightQuaternionThe second quaternion to add.
resultQuaternionWhen 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
aQuaternionbQuaternion
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
value1QuaternionA Quaternion containing the 4D Cartesian coordinates of vertex 1 of the triangle.
value2QuaternionA Quaternion containing the 4D Cartesian coordinates of vertex 2 of the triangle.
value3QuaternionA Quaternion containing the 4D Cartesian coordinates of vertex 3 of the triangle.
amount1floatBarycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in
value2).amount2floatBarycentric 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 readonly Quaternion, ref readonly Quaternion, ref readonly 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 readonly Quaternion value1, ref readonly Quaternion value2, ref readonly Quaternion value3, float amount1, float amount2, out Quaternion result)
Parameters
value1QuaternionA Quaternion containing the 4D Cartesian coordinates of vertex 1 of the triangle.
value2QuaternionA Quaternion containing the 4D Cartesian coordinates of vertex 2 of the triangle.
value3QuaternionA Quaternion containing the 4D Cartesian coordinates of vertex 3 of the triangle.
amount1floatBarycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in
value2).amount2floatBarycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in
value3).resultQuaternionWhen 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
sourceVector3The source vector of the transformation.
targetVector3The target vector of the transformation.
Returns
- Quaternion
The resulting quaternion corresponding to the transformation of the source vector to the target vector.
BetweenDirections(ref readonly Vector3, ref readonly Vector3, out Quaternion)
Computes a quaternion corresponding to the rotation transforming the vector source to the vector target.
public static void BetweenDirections(ref readonly Vector3 source, ref readonly Vector3 target, out Quaternion result)
Parameters
sourceVector3The source vector of the transformation.
targetVector3The target vector of the transformation.
resultQuaternionThe 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
valueQuaternionThe quaternion to conjugate.
Returns
- Quaternion
The conjugated quaternion.
Conjugate(ref readonly Quaternion, out Quaternion)
Conjugates a quaternion.
public static void Conjugate(ref readonly Quaternion value, out Quaternion result)
Parameters
valueQuaternionThe quaternion to conjugate.
resultQuaternionWhen 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
leftQuaternionFirst source quaternion.
rightQuaternionSecond source quaternion.
Returns
- float
The dot product of the two quaternions.
Dot(ref readonly Quaternion, ref readonly Quaternion, out float)
Calculates the dot product of two quaternions.
public static void Dot(ref readonly Quaternion left, ref readonly Quaternion right, out float result)
Parameters
leftQuaternionFirst source quaternion.
rightQuaternionSecond source quaternion.
resultfloatWhen the method completes, contains the dot product of the two quaternions.
Equals(Quaternion)
Determines whether the specified Quaternion is within ZeroTolerance for equality to this instance.
public readonly bool Equals(Quaternion other)
Parameters
otherQuaternionThe Quaternion to compare with this instance.
Returns
- bool
trueif the specified Quaternion is equal or almost equal to this instance; otherwise,false.
Equals(object?)
Determines whether the specified object is within ZeroTolerance for equality to this instance.
public override readonly bool Equals(object? value)
Parameters
valueobjectThe object to compare with this instance.
Returns
- bool
trueif the specified object is equal or almost equal to this instance; otherwise,false.
EqualsStrict(Quaternion)
Determines whether the specified Quaternion is exactly equal to this instance.
public bool EqualsStrict(Quaternion other)
Parameters
otherQuaternionThe Quaternion to compare with this instance.
Returns
- bool
trueif the specified Quaternion is exactly equal to this instance; otherwise,false.
Exponential(Quaternion)
Exponentiates a quaternion.
public static Quaternion Exponential(Quaternion value)
Parameters
valueQuaternionThe quaternion to exponentiate.
Returns
- Quaternion
The exponentiated quaternion.
Exponential(ref readonly Quaternion, out Quaternion)
Exponentiates a quaternion.
public static void Exponential(ref readonly Quaternion value, out Quaternion result)
Parameters
valueQuaternionThe quaternion to exponentiate.
resultQuaternionWhen 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
valueQuaternionThe quaternion to conjugate and renormalize.
Returns
- Quaternion
The conjugated and renormalized quaternion.
Invert(ref readonly Quaternion, out Quaternion)
Conjugates and renormalizes the quaternion.
public static void Invert(ref readonly Quaternion value, out Quaternion result)
Parameters
valueQuaternionThe quaternion to conjugate and renormalize.
resultQuaternionWhen 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
startQuaternionStart quaternion.
endQuaternionEnd quaternion.
amountfloatValue 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 readonly Quaternion, ref readonly Quaternion, float, out Quaternion)
Performs a linear interpolation between two quaternions.
public static void Lerp(ref readonly Quaternion start, ref readonly Quaternion end, float amount, out Quaternion result)
Parameters
startQuaternionStart quaternion.
endQuaternionEnd quaternion.
amountfloatValue between 0 and 1 indicating the weight of
end.resultQuaternionWhen 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
valueQuaternionThe quaternion whose logarithm will be calculated.
Returns
- Quaternion
The natural logarithm of the quaternion.
Logarithm(ref readonly Quaternion, out Quaternion)
Calculates the natural logarithm of the specified quaternion.
public static void Logarithm(ref readonly Quaternion value, out Quaternion result)
Parameters
valueQuaternionThe quaternion whose logarithm will be calculated.
resultQuaternionWhen 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
valueQuaternionThe quaternion to scale.
scalefloatThe 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
leftQuaternionThe first quaternion to modulate.
rightQuaternionThe second quaternion to modulate.
Returns
- Quaternion
The modulated quaternion.
Multiply(ref readonly Quaternion, ref readonly Quaternion, out Quaternion)
Modulates a quaternion by another.
public static void Multiply(ref readonly Quaternion left, ref readonly Quaternion right, out Quaternion result)
Parameters
leftQuaternionThe first quaternion to modulate.
rightQuaternionThe second quaternion to modulate.
resultQuaternionWhen the moethod completes, contains the modulated quaternion.
Multiply(ref readonly Quaternion, float, out Quaternion)
Scales a quaternion by the given value.
public static void Multiply(ref readonly Quaternion value, float scale, out Quaternion result)
Parameters
valueQuaternionThe quaternion to scale.
scalefloatThe amount by which to scale the quaternion.
resultQuaternionWhen the method completes, contains the scaled quaternion.
Negate(Quaternion)
Reverses the direction of a given quaternion.
public static Quaternion Negate(Quaternion value)
Parameters
valueQuaternionThe quaternion to negate.
Returns
- Quaternion
A quaternion facing in the opposite direction.
Negate(ref readonly Quaternion, out Quaternion)
Reverses the direction of a given quaternion.
public static void Negate(ref readonly Quaternion value, out Quaternion result)
Parameters
valueQuaternionThe quaternion to negate.
resultQuaternionWhen 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
valueQuaternionThe quaternion to normalize.
Returns
- Quaternion
The normalized quaternion.
Normalize(ref readonly Quaternion, out Quaternion)
Converts the quaternion into a unit quaternion.
public static void Normalize(ref readonly Quaternion value, out Quaternion result)
Parameters
valueQuaternionThe quaternion to normalize.
resultQuaternionWhen 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
vectorVector3The 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
currentQuaterniontargetQuaternionanglefloat
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 readonly Vector3, float, out Quaternion)
Creates a quaternion given a rotation and an axis.
public static void RotationAxis(ref readonly Vector3 axis, float angle, out Quaternion result)
Parameters
axisVector3The axis of rotation.
anglefloatThe angle of rotation.
resultQuaternionWhen the method completes, contains the newly created quaternion.
RotationMatrix(Matrix)
Creates a quaternion given a rotation matrix.
public static Quaternion RotationMatrix(Matrix matrix)
Parameters
matrixMatrixThe rotation matrix.
Returns
- Quaternion
The newly created quaternion.
RotationMatrix(ref readonly Matrix, out Quaternion)
Creates a quaternion given a rotation matrix.
public static void RotationMatrix(ref readonly Matrix matrix, out Quaternion result)
Parameters
matrixMatrixThe rotation matrix.
resultQuaternionWhen 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
anglefloatAngle 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
anglefloatAngle of rotation in radians.
resultQuaternionWhen 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
anglefloatAngle 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
anglefloatAngle of rotation in radians.
resultQuaternionWhen the method completes, contains the newly created quaternion.
RotationYawPitchRoll(ref readonly Quaternion, out float, out float, out float)
Calculate the yaw/pitch/roll rotation equivalent to the provided quaternion.
public static void RotationYawPitchRoll(ref readonly Quaternion rotation, out float yaw, out float pitch, out float roll)
Parameters
rotationQuaternionThe input quaternion
yawfloatThe yaw component in radians.
pitchfloatThe pitch component in radians.
rollfloatThe 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
yawfloatThe yaw of rotation in radians.
pitchfloatThe pitch of rotation in radians.
rollfloatThe 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
yawfloatThe yaw of rotation in radians.
pitchfloatThe pitch of rotation in radians.
rollfloatThe roll of rotation in radians.
resultQuaternionWhen 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
anglefloatAngle 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
anglefloatAngle of rotation in radians.
resultQuaternionWhen 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
startQuaternionStart quaternion.
endQuaternionEnd quaternion.
amountfloatValue between 0 and 1 indicating the weight of
end.
Returns
- Quaternion
The spherical linear interpolation of the two quaternions.
Slerp(ref readonly Quaternion, ref readonly Quaternion, float, out Quaternion)
Interpolates between two quaternions, using spherical linear interpolation.
public static void Slerp(ref readonly Quaternion start, ref readonly Quaternion end, float amount, out Quaternion result)
Parameters
startQuaternionStart quaternion.
endQuaternionEnd quaternion.
amountfloatValue between 0 and 1 indicating the weight of
end.resultQuaternionWhen 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
value1QuaternionFirst source quaternion.
value2QuaternionSecond source quaternion.
value3QuaternionThrid source quaternion.
value4QuaternionFourth source quaternion.
amountfloatValue between 0 and 1 indicating the weight of interpolation.
Returns
- Quaternion
The spherical quadrangle interpolation of the quaternions.
Squad(ref readonly Quaternion, ref readonly Quaternion, ref readonly Quaternion, ref readonly Quaternion, float, out Quaternion)
Interpolates between quaternions, using spherical quadrangle interpolation.
public static void Squad(ref readonly Quaternion value1, ref readonly Quaternion value2, ref readonly Quaternion value3, ref readonly Quaternion value4, float amount, out Quaternion result)
Parameters
value1QuaternionFirst source quaternion.
value2QuaternionSecond source quaternion.
value3QuaternionThrid source quaternion.
value4QuaternionFourth source quaternion.
amountfloatValue between 0 and 1 indicating the weight of interpolation.
resultQuaternionWhen 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
value1QuaternionFirst source quaternion.
value2QuaternionSecond source quaternion.
value3QuaternionThird source quaternion.
value4QuaternionFourth 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
leftQuaternionThe first quaternion to subtract.
rightQuaternionThe second quaternion to subtract.
Returns
- Quaternion
The difference of the two quaternions.
Subtract(ref readonly Quaternion, ref readonly Quaternion, out Quaternion)
Subtracts two quaternions.
public static void Subtract(ref readonly Quaternion left, ref readonly Quaternion right, out Quaternion result)
Parameters
leftQuaternionThe first quaternion to subtract.
rightQuaternionThe second quaternion to subtract.
resultQuaternionWhen 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(string?, IFormatProvider?)
Returns a string that represents this instance.
public readonly string ToString(string? format, IFormatProvider? formatProvider)
Parameters
formatstringThe format.
formatProviderIFormatProviderThe format provider.
Returns
Operators
operator +(in Quaternion, in Quaternion)
Adds two quaternions.
public static Quaternion operator +(in Quaternion left, in Quaternion right)
Parameters
leftQuaternionThe first quaternion to add.
rightQuaternionThe 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
leftQuaternionThe first value to compare.
rightQuaternionThe second value to compare.
Returns
- bool
trueiflefthas the same value asright; otherwise,false.
Remarks
Comparison is not strict, a difference of ZeroTolerance will return as equal.
implicit operator Quaternion(Quaternion)
Casts from Stride.Maths to System.Numerics vectors
public static implicit operator Quaternion(Quaternion v)
Parameters
vQuaternionValue to cast
Returns
implicit operator Quaternion(Quaternion)
Casts from System.Numerics to Stride.Maths vectors
public static implicit operator Quaternion(Quaternion v)
Parameters
vQuaternionValue to cast
Returns
operator !=(in Quaternion, in Quaternion)
Tests for inequality between two objects.
public static bool operator !=(in Quaternion left, in Quaternion right)
Parameters
leftQuaternionThe first value to compare.
rightQuaternionThe second value to compare.
Returns
- bool
trueiflefthas a different value thanright; otherwise,false.
Remarks
Comparison is not strict, a difference of ZeroTolerance will return as equal.
operator *(in Quaternion, in Quaternion)
Multiplies a quaternion by another.
public static Quaternion operator *(in Quaternion left, in Quaternion right)
Parameters
leftQuaternionThe first quaternion to multiply.
rightQuaternionThe 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
leftQuaternionrightVector3
Returns
Remarks
Shorthand for Rotate(ref Vector3)
operator *(in Quaternion, float)
Scales a quaternion by the given value.
public static Quaternion operator *(in Quaternion value, float scale)
Parameters
valueQuaternionThe quaternion to scale.
scalefloatThe amount by which to scale the quaternion.
Returns
- Quaternion
The scaled quaternion.
operator *(float, in Quaternion)
Scales a quaternion by the given value.
public static Quaternion operator *(float scale, in Quaternion value)
Parameters
scalefloatThe amount by which to scale the quaternion.
valueQuaternionThe quaternion to scale.
Returns
- Quaternion
The scaled quaternion.
operator -(in Quaternion, in Quaternion)
Subtracts two quaternions.
public static Quaternion operator -(in Quaternion left, in Quaternion right)
Parameters
leftQuaternionThe first quaternion to subtract.
rightQuaternionThe second quaternion to subtract.
Returns
- Quaternion
The difference of the two quaternions.
operator -(in Quaternion)
Reverses the direction of a given quaternion.
public static Quaternion operator -(in Quaternion value)
Parameters
valueQuaternionThe quaternion to negate.
Returns
- Quaternion
A quaternion facing in the opposite direction.