Struct Quaternion
A structure encapsulating a four-dimensional vector (x,y,z,w), which is used to efficiently rotate an object about the (x,y,z) vector by the angle theta, where w = cos(theta/2).
Implements
Inherited Members
Namespace: Vim.Math3d
Assembly: Vim.Math3D.dll
[DataContract]
public readonly struct Quaternion : IEquatable<Quaternion>
Constructors
View SourceQuaternion(Single, Single, Single, Single)
public Quaternion(float x, float y, float z, float w)
Quaternion((Single x, Single y, Single z, Single w))
public Quaternion((float x, float y, float z, float w) tuple)
Quaternion(Vector3, Single)
Constructs a Quaternion from the given vector and rotation parts.
public Quaternion(Vector3 vectorPart, float scalarPart)
Fields
View SourceMaxValue
public static Quaternion MaxValue
MinValue
public static Quaternion MinValue
W
[DataMember]
public readonly float W
X
[DataMember]
public readonly float X
Y
[DataMember]
public readonly float Y
Z
[DataMember]
public readonly float Z
Zero
public static Quaternion Zero
Properties
View SourceIdentity
Returns a Quaternion representing no rotation.
public static readonly Quaternion Identity { get; }
IsIdentity
Returns whether the Quaternion is the identity Quaternion.
public readonly bool IsIdentity { get; }
Vector4
public readonly Vector4 Vector4 { get; }
Methods
View SourceAlmostEquals(Quaternion, Single)
public readonly bool AlmostEquals(Quaternion x, float tolerance = 1E-07F)
Concatenate(Quaternion, Quaternion)
Concatenates two Quaternions; the result represents the value1 rotation followed by the value2 rotation.
public static Quaternion Concatenate(Quaternion value1, Quaternion value2)
Conjugate()
Returns the conjugate of the quaternion
public readonly Quaternion Conjugate()
Create(Single, Single, Single, Single)
public static Quaternion Create(float x, float y, float z, float w)
Create((Single x, Single y, Single z, Single w))
public static Quaternion Create((float x, float y, float z, float w) tuple)
CreateFromAxisAngle(Vector3, Single)
Creates a Quaternion from a normalized vector axis and an angle to rotate about the vector.
public static Quaternion CreateFromAxisAngle(Vector3 axis, float angle)
CreateFromEulerAngles(Vector3)
Creates a new Quaternion from the given rotation around X, Y, and Z
public static Quaternion CreateFromEulerAngles(Vector3 v)
CreateFromRotationMatrix(Matrix4x4)
Creates a Quaternion from the given rotation matrix.
public static Quaternion CreateFromRotationMatrix(Matrix4x4 matrix)
CreateFromYawPitchRoll(Single, Single, Single)
Creates a new Quaternion from the given yaw, pitch, and roll, in radians. Roll first, about axis the object is facing, then pitch upward, then yaw to face into the new heading
- Z(roll), 2. X (pitch), 3. Y (yaw)
public static Quaternion CreateFromYawPitchRoll(float yaw, float pitch, float roll)
CreateRotationFromAToB(Vector3, Vector3)
Creates a new Quaternion rotating vector 'fromA' to 'toB'
public static Quaternion CreateRotationFromAToB(Vector3 fromA, Vector3 toB)
CreateXRotation(Single)
Creates a new Quaternion from the given rotation around the X axis
public static Quaternion CreateXRotation(float theta)
CreateYRotation(Single)
Creates a new Quaternion from the given rotation around the Y axis
public static Quaternion CreateYRotation(float theta)
CreateZRotation(Single)
Creates a new Quaternion from the given rotation around the Z axis
public static Quaternion CreateZRotation(float theta)
Deconstruct(out Single, out Single, out Single, out Single)
public readonly void Deconstruct(out float x, out float y, out float z, out float w)
Dot(Quaternion, Quaternion)
Calculates the dot product of two Quaternions.
public static float Dot(Quaternion quaternion1, Quaternion quaternion2)
Equals(Object)
public override readonly bool Equals(object obj)
Overrides
Equals(Quaternion)
public readonly bool Equals(Quaternion x)
GetHashCode()
public override readonly int GetHashCode()
Overrides
Inverse()
Returns the inverse of a Quaternion.
public readonly Quaternion Inverse()
Length()
Calculates the length of the Quaternion.
public readonly float Length()
LengthSquared()
Calculates the length squared of the Quaternion. This operation is cheaper than Length().
public readonly float LengthSquared()
Lerp(Quaternion, Quaternion, Single)
Linearly interpolates between two quaternions.
public static Quaternion Lerp(Quaternion q1, Quaternion q2, float t)
LookAt(Vector3, Vector3, Vector3, Vector3)
Creates a new look-at Quaternion
public static Quaternion LookAt(Vector3 position, Vector3 targetPosition, Vector3 up, Vector3 forward)
Normalize()
Divides each component of the Quaternion by the length of the Quaternion.
public readonly Quaternion Normalize()
SetW(Single)
public readonly Quaternion SetW(float x)
SetX(Single)
public readonly Quaternion SetX(float x)
SetY(Single)
public readonly Quaternion SetY(float x)
SetZ(Single)
public readonly Quaternion SetZ(float x)
Slerp(Quaternion, Quaternion, Single)
Interpolates between two quaternions, using spherical linear interpolation.
public static Quaternion Slerp(Quaternion q1, Quaternion q2, float t)
ToEulerAngles()
Returns Euler123 angles (rotate around, X, then Y, then Z).
public readonly Vector3 ToEulerAngles()
ToString()
public override readonly string ToString()
Overrides
Operators
View SourceAddition(Quaternion, Quaternion)
Adds two Quaternions element-by-element.
public static Quaternion operator +(Quaternion value1, Quaternion value2)
Division(Quaternion, Quaternion)
Divides a Quaternion by another Quaternion.
public static Quaternion operator /(Quaternion value1, Quaternion value2)
Equality(Quaternion, Quaternion)
public static bool operator ==(Quaternion x0, Quaternion x1)
Implicit((Single x, Single y, Single z, Single w) to Quaternion)
public static implicit operator Quaternion((float x, float y, float z, float w) tuple)
Implicit(Quaternion to (Single x, Single y, Single z, Single w))
public static implicit operator (float x, float y, float z, float w)(Quaternion self)
Inequality(Quaternion, Quaternion)
public static bool operator !=(Quaternion x0, Quaternion x1)
Multiply(Quaternion, Single)
Multiplies a Quaternion by a scalar value.
public static Quaternion operator *(Quaternion value1, float value2)
Multiply(Quaternion, Quaternion)
Multiplies two Quaternions together.
public static Quaternion operator *(Quaternion value1, Quaternion value2)
Subtraction(Quaternion, Quaternion)
Subtracts one Quaternion from another.
public static Quaternion operator -(Quaternion value1, Quaternion value2)
UnaryNegation(Quaternion)
Flips the sign of each component of the quaternion.
public static Quaternion operator -(Quaternion value)