Struct Quaternion
Represents a quaternion.
Implements
Inherited Members
Namespace: Evergine.Mathematics
Assembly: Evergine.Mathematics.dll
Syntax
public struct Quaternion : IEquatable<Quaternion>
Constructors
Quaternion(Vector3, float)
Initializes a new instance of the Quaternion struct.
Declaration
public Quaternion(Vector3 vectorPart, float scalarPart)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vectorPart | The vector part. |
float | scalarPart | The scalar part. |
Quaternion(float, float, float, float)
Initializes a new instance of the Quaternion struct.
Declaration
public Quaternion(float x, float y, float z, float w)
Parameters
Type | Name | Description |
---|---|---|
float | x | The x. |
float | y | The y. |
float | z | The z. |
float | w | The w. |
Fields
W
W component.
Declaration
public float W
Field Value
Type | Description |
---|---|
float |
X
X component.
Declaration
public float X
Field Value
Type | Description |
---|---|
float |
Y
Y component.
Declaration
public float Y
Field Value
Type | Description |
---|---|
float |
Z
Z component.
Declaration
public float Z
Field Value
Type | Description |
---|---|
float |
Properties
Identity
Gets the identity.
Declaration
public static Quaternion Identity { get; }
Property Value
Type | Description |
---|---|
Quaternion |
IsIdentity
Gets a value indicating whether the Quaternion is the identity Quaternion.
Declaration
public bool IsIdentity { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
Add(Quaternion, Quaternion)
Adds the specified quaternion1.
Declaration
public static Quaternion Add(Quaternion quaternion1, Quaternion quaternion2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
Quaternion | quaternion2 | The quaternion2. |
Returns
Type | Description |
---|---|
Quaternion | The result. |
Add(ref Quaternion, ref Quaternion, out Quaternion)
Adds the specified quaternion1.
Declaration
public static void Add(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
Quaternion | quaternion2 | The quaternion2. |
Quaternion | result | The result. |
Concatenate(Quaternion, Quaternion)
Concatenates two Quaternions; the result represents the value1 rotation followed by the value2 rotation.
Declaration
public static Quaternion Concatenate(Quaternion value1, Quaternion value2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value1 | The first Quaternion rotation in the series. |
Quaternion | value2 | The second Quaternion rotation in the series. |
Returns
Type | Description |
---|---|
Quaternion | A new Quaternion representing the concatenation of the value1 rotation followed by the value2 rotation. |
Concatenate(ref Quaternion, ref Quaternion, out Quaternion)
Concatenates two Quaternions; the result represents the value1 rotation followed by the value2 rotation.
Declaration
public static void Concatenate(ref Quaternion value1, ref Quaternion value2, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value1 | The first Quaternion rotation in the series. |
Quaternion | value2 | The second Quaternion rotation in the series. |
Quaternion | result | The Quaternion representing the concatenation of the value1 rotation followed by the value2 rotation. |
Conjugate()
Conjugates this instance.
Declaration
public void Conjugate()
Conjugate(Quaternion)
Conjugates the specified value.
Declaration
public static Quaternion Conjugate(Quaternion value)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The value. |
Returns
Type | Description |
---|---|
Quaternion | The result. |
Conjugate(ref Quaternion, out Quaternion)
Conjugates the specified value.
Declaration
public static void Conjugate(ref Quaternion value, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The value. |
Quaternion | result | The result. |
CreateFromAxisAngle(Vector3, float)
Creates from axis angle.
Declaration
public static Quaternion CreateFromAxisAngle(Vector3 axis, float angle)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | axis | The axis. |
float | angle | The angle. |
Returns
Type | Description |
---|---|
Quaternion | The result. |
CreateFromAxisAngle(ref Vector3, float, out Quaternion)
Creates from axis angle.
Declaration
public static void CreateFromAxisAngle(ref Vector3 axis, float angle, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | axis | The axis. |
float | angle | The angle. |
Quaternion | result | The result. |
CreateFromEuler(Vector3)
Creates a quaternion from euler angles.
Declaration
public static Quaternion CreateFromEuler(Vector3 euler)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | euler | The euler angles. |
Returns
Type | Description |
---|---|
Quaternion | The quaternion created. |
CreateFromEuler(ref Vector3, out Quaternion)
Creates a quaternion from euler angles.
Declaration
public static void CreateFromEuler(ref Vector3 euler, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | euler | The euler angles. |
Quaternion | result | The quaternion created. |
CreateFromLookAt(ref Vector3, ref Vector3, out Quaternion)
Creates from the lookAt and up vector.
Declaration
public static void CreateFromLookAt(ref Vector3 lookAt, ref Vector3 up, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | lookAt | The look at vector. |
Vector3 | up | The Up vector. |
Quaternion | result | The result. |
CreateFromRotationMatrix(Matrix4x4)
Creates from rotation matrix.
Declaration
public static Quaternion CreateFromRotationMatrix(Matrix4x4 matrix)
Parameters
Type | Name | Description |
---|---|---|
Matrix4x4 | matrix | The matrix. |
Returns
Type | Description |
---|---|
Quaternion | The result. |
CreateFromRotationMatrix(ref Matrix4x4, out Quaternion)
Creates from rotation matrix.
Declaration
public static void CreateFromRotationMatrix(ref Matrix4x4 matrix, out Quaternion quaternion)
Parameters
Type | Name | Description |
---|---|---|
Matrix4x4 | matrix | The matrix. |
Quaternion | quaternion | The quaternion result. |
CreateFromTwoVectors(Vector3, Vector3)
Creates from the angle between two vectors.
Declaration
public static Quaternion CreateFromTwoVectors(Vector3 u, Vector3 v)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | u | First vector. |
Vector3 | v | Second vector. |
Returns
Type | Description |
---|---|
Quaternion | The result. |
CreateFromTwoVectors(ref Vector3, out Quaternion)
Creates from the angle between two vectors.
Declaration
public static void CreateFromTwoVectors(ref Vector3 lookAt, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | lookAt | The look at vector. |
Quaternion | result | The result. |
CreateFromYawPitchRoll(float, float, float)
Creates from yaw pitch roll.
Declaration
public static Quaternion CreateFromYawPitchRoll(float yaw, float pitch, float roll)
Parameters
Type | Name | Description |
---|---|---|
float | yaw | The yaw. |
float | pitch | The pitch. |
float | roll | The roll. |
Returns
Type | Description |
---|---|
Quaternion | The result. |
CreateFromYawPitchRoll(float, float, float, out Quaternion)
Creates from yaw pitch roll.
Declaration
public static void CreateFromYawPitchRoll(float yaw, float pitch, float roll, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
float | yaw | The yaw. |
float | pitch | The pitch. |
float | roll | The roll. |
Quaternion | result | The result. |
Divide(Quaternion, Quaternion)
Divides a Quaternion by another Quaternion.
Declaration
public static Quaternion Divide(Quaternion quaternion1, Quaternion quaternion2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The source Quaternion. |
Quaternion | quaternion2 | The divisor. |
Returns
Type | Description |
---|---|
Quaternion | The result of the division. |
Divide(ref Quaternion, ref Quaternion, out Quaternion)
Divides a Quaternion by another Quaternion.
Declaration
public static void Divide(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The source Quaternion. |
Quaternion | quaternion2 | The divisor. |
Quaternion | result | The result of the division. |
Dot(Quaternion, Quaternion)
Dots the specified quaternion1.
Declaration
public static float Dot(Quaternion quaternion1, Quaternion quaternion2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
Quaternion | quaternion2 | The quaternion2. |
Returns
Type | Description |
---|---|
float | The result. |
Dot(ref Quaternion, ref Quaternion)
Dots the specified quaternion1.
Declaration
public static float Dot(ref Quaternion quaternion1, ref Quaternion quaternion2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
Quaternion | quaternion2 | The quaternion2. |
Returns
Type | Description |
---|---|
float | The result. |
Equals(Quaternion)
Equalses the specified other.
Declaration
public bool Equals(Quaternion other)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | other | The other. |
Returns
Type | Description |
---|---|
bool | The result. |
Equals(ref Quaternion)
Equalses the specified other.
Declaration
public bool Equals(ref Quaternion other)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | other | The other. |
Returns
Type | Description |
---|---|
bool | The result. |
Equals(object)
Determines whether the specified object is equal to this instance.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with this instance. |
Returns
Type | Description |
---|---|
bool |
|
Overrides
GetHashCode()
Returns a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
Inverse(Quaternion)
Inverses the specified quaternion.
Declaration
public static Quaternion Inverse(Quaternion quaternion)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion. |
Returns
Type | Description |
---|---|
Quaternion | The result. |
Inverse(ref Quaternion, out Quaternion)
Inverses the specified quaternion.
Declaration
public static void Inverse(ref Quaternion quaternion, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion. |
Quaternion | result | The result. |
Length()
Lengthes this instance.
Declaration
public float Length()
Returns
Type | Description |
---|---|
float | The result. |
LengthSquared()
Lengthes the squared.
Declaration
public float LengthSquared()
Returns
Type | Description |
---|---|
float | The result. |
Lerp(Quaternion, Quaternion, float)
Linearly interpolates between two quaternions.
Declaration
public static Quaternion Lerp(Quaternion quaternion1, Quaternion quaternion2, float amount)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The first source Quaternion. |
Quaternion | quaternion2 | The second source Quaternion. |
float | amount | The relative weight of the second source Quaternion in the interpolation. |
Returns
Type | Description |
---|---|
Quaternion | The interpolated Quaternion. |
Lerp(ref Quaternion, ref Quaternion, float, out Quaternion)
Linearly interpolates between two quaternions.
Declaration
public static void Lerp(ref Quaternion quaternion1, ref Quaternion quaternion2, float amount, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The first source Quaternion. |
Quaternion | quaternion2 | The second source Quaternion. |
float | amount | The relative weight of the second source Quaternion in the interpolation. |
Quaternion | result | The interpolated Quaternion. |
Multiply(Quaternion, Quaternion)
Multiplies two Quaternions together.
Declaration
public static Quaternion Multiply(Quaternion quaternion1, Quaternion quaternion2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The Quaternion on the left side of the multiplication. |
Quaternion | quaternion2 | The Quaternion on the right side of the multiplication. |
Returns
Type | Description |
---|---|
Quaternion | The result of the multiplication. |
Multiply(Quaternion, float)
Multiplies the specified quaternion1.
Declaration
public static Quaternion Multiply(Quaternion quaternion1, float scaleFactor)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
float | scaleFactor | The scale factor. |
Returns
Type | Description |
---|---|
Quaternion | The result. |
Multiply(ref Quaternion, ref Quaternion, out Quaternion)
Multiplies two Quaternions together.
Declaration
public static void Multiply(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The Quaternion on the left side of the multiplication. |
Quaternion | quaternion2 | The Quaternion on the right side of the multiplication. |
Quaternion | result | The result of the multiplication. |
Multiply(ref Quaternion, float, out Quaternion)
Multiplies the specified quaternion1.
Declaration
public static void Multiply(ref Quaternion quaternion1, float scaleFactor, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
float | scaleFactor | The scale factor. |
Quaternion | result | The result. |
Negate(Quaternion)
Negates the specified quaternion.
Declaration
public static Quaternion Negate(Quaternion quaternion)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion. |
Returns
Type | Description |
---|---|
Quaternion | The result. |
Negate(ref Quaternion, out Quaternion)
Negates the specified quaternion.
Declaration
public static void Negate(ref Quaternion quaternion, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion. |
Quaternion | result | The result. |
Normalize()
Normalizes this instance.
Declaration
public void Normalize()
Normalize(Quaternion)
Normalizes the specified quaternion.
Declaration
public static Quaternion Normalize(Quaternion quaternion)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion. |
Returns
Type | Description |
---|---|
Quaternion | The result. |
Normalize(ref Quaternion, out Quaternion)
Normalizes the specified quaternion.
Declaration
public static void Normalize(ref Quaternion quaternion, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion. |
Quaternion | result | The result. |
Slerp(Quaternion, Quaternion, float)
Slerps the specified quaternion1.
Declaration
public static Quaternion Slerp(Quaternion quaternion1, Quaternion quaternion2, float amount)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
Quaternion | quaternion2 | The quaternion2. |
float | amount | The amount. |
Returns
Type | Description |
---|---|
Quaternion | The result. |
Slerp(ref Quaternion, ref Quaternion, float, out Quaternion)
Slerps the specified quaternion1.
Declaration
public static void Slerp(ref Quaternion quaternion1, ref Quaternion quaternion2, float amount, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
Quaternion | quaternion2 | The quaternion2. |
float | amount | The amount. |
Quaternion | result | The result. |
SmoothDamp(Quaternion, Quaternion, ref Quaternion, float, float)
Changes a quaternion towards a desired goal over time.
Declaration
public static Quaternion SmoothDamp(Quaternion current, Quaternion target, ref Quaternion deriv, float smoothTime, float gameTime)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | current | Current quaternion. |
Quaternion | target | Target quaternion. |
Quaternion | deriv | Derivative quaternion. |
float | smoothTime | The smooth time. |
float | gameTime | The elapsed time. |
Returns
Type | Description |
---|---|
Quaternion | The smooth quaternion. |
Subtract(Quaternion, Quaternion)
Subtracts the specified quaternion1.
Declaration
public static Quaternion Subtract(Quaternion quaternion1, Quaternion quaternion2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
Quaternion | quaternion2 | The quaternion2. |
Returns
Type | Description |
---|---|
Quaternion | The result. |
Subtract(ref Quaternion, ref Quaternion, out Quaternion)
Subtracts the specified quaternion1.
Declaration
public static void Subtract(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
Quaternion | quaternion2 | The quaternion2. |
Quaternion | result | The result. |
ToAngleAxis(ref Quaternion, out Vector3, out float)
Obtains the Angle and Axis of a Quaternion.
Declaration
public static void ToAngleAxis(ref Quaternion orientation, out Vector3 axis, out float angle)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | orientation | The quaternion. |
Vector3 | axis | The axis of the quaternion. |
float | angle | The angle of the quaternion. |
ToEuler(Quaternion)
Converts a Quaternion to Euler angles (X = pitch, Y = yaw, Z = roll).
Declaration
public static Vector3 ToEuler(Quaternion orientation)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | orientation | The rotation. |
Returns
Type | Description |
---|---|
Vector3 | The rotationaxes. |
ToEuler(ref Quaternion, out Vector3)
Converts a Quaternion to Euler angles (X = pitch, Y = yaw, Z = roll).
Declaration
public static void ToEuler(ref Quaternion orientation, out Vector3 rotationaxes)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | orientation | The rotation. |
Vector3 | rotationaxes | The rotationaxes. |
ToString()
Returns a string that represents this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents this instance. |
Overrides
Operators
operator +(Quaternion, Quaternion)
Implements the operator +.
Declaration
public static Quaternion operator +(Quaternion quaternion1, Quaternion quaternion2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
Quaternion | quaternion2 | The quaternion2. |
Returns
Type | Description |
---|---|
Quaternion | The result of the operator. |
operator /(Quaternion, Quaternion)
Divides a Quaternion by another Quaternion.
Declaration
public static Quaternion operator /(Quaternion quaternion1, Quaternion quaternion2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The source Quaternion. |
Quaternion | quaternion2 | The divisor. |
Returns
Type | Description |
---|---|
Quaternion | The result of the division. |
operator ==(Quaternion, Quaternion)
Implements the operator ==.
Declaration
public static bool operator ==(Quaternion quaternion1, Quaternion quaternion2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
Quaternion | quaternion2 | The quaternion2. |
Returns
Type | Description |
---|---|
bool | The result of the operator. |
operator !=(Quaternion, Quaternion)
Implements the operator !=.
Declaration
public static bool operator !=(Quaternion quaternion1, Quaternion quaternion2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
Quaternion | quaternion2 | The quaternion2. |
Returns
Type | Description |
---|---|
bool | The result of the operator. |
operator *(Quaternion, Quaternion)
Multiplies two Quaternions together.
Declaration
public static Quaternion operator *(Quaternion value1, Quaternion value2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value1 | The Quaternion on the left side of the multiplication. |
Quaternion | value2 | The Quaternion on the right side of the multiplication. |
Returns
Type | Description |
---|---|
Quaternion | The result of the multiplication. |
operator *(Quaternion, Vector3)
Implements the operator *.
Declaration
public static Vector3 operator *(Quaternion rotation, Vector3 point)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | rotation | The rotation quaternion. |
Vector3 | point | The point as vector3. |
Returns
Type | Description |
---|---|
Vector3 | The multiplied vector. |
operator *(Quaternion, float)
Implements the operator *.
Declaration
public static Quaternion operator *(Quaternion quaternion1, float scaleFactor)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
float | scaleFactor | The scale factor. |
Returns
Type | Description |
---|---|
Quaternion | The result of the operator. |
operator -(Quaternion, Quaternion)
Implements the operator -.
Declaration
public static Quaternion operator -(Quaternion quaternion1, Quaternion quaternion2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion1 | The quaternion1. |
Quaternion | quaternion2 | The quaternion2. |
Returns
Type | Description |
---|---|
Quaternion | The result of the operator. |
operator -(Quaternion)
Implements the operator -.
Declaration
public static Quaternion operator -(Quaternion quaternion)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | The quaternion. |
Returns
Type | Description |
---|---|
Quaternion | The result of the operator. |