Struct Quaternion
- Namespace
- Lime
- Assembly
- Lime.dll
public struct Quaternion : IEquatable<Quaternion>
- Implements
- Inherited Members
Constructors
Quaternion(Vector3, float)
Constructs a quaternion with X, Y, Z from Vector3 and rotation component from a scalar.
public Quaternion(Vector3 value, float w)
Parameters
Quaternion(float, float, float, float)
Constructs a quaternion with X, Y, Z and W from four values.
public Quaternion(float x, float y, float z, float w)
Parameters
x
floatThe x coordinate in 3d-space.
y
floatThe y coordinate in 3d-space.
z
floatThe z coordinate in 3d-space.
w
floatThe rotation component.
Fields
W
The rotation component of this Quaternion.
[YuzuMember("3")]
public float W
Field Value
X
The x coordinate of this Quaternion.
[YuzuMember("0")]
public float X
Field Value
Y
The y coordinate of this Quaternion.
[YuzuMember("1")]
public float Y
Field Value
Z
The z coordinate of this Quaternion.
[YuzuMember("2")]
public float Z
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.
Identity
Returns a quaternion representing no rotation.
public static Quaternion Identity { get; }
Property Value
Normalized
public Quaternion Normalized { get; }
Property Value
Methods
Add(Quaternion, Quaternion)
Creates a new Quaternion that contains the sum of two quaternions.
public static Quaternion Add(Quaternion quaternion1, Quaternion quaternion2)
Parameters
quaternion1
QuaternionSource Quaternion.
quaternion2
QuaternionSource Quaternion.
Returns
- Quaternion
The result of the quaternion addition.
Add(ref Quaternion, ref Quaternion, out Quaternion)
Creates a new Quaternion that contains the sum of two quaternions.
public static void Add(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
Parameters
quaternion1
QuaternionSource Quaternion.
quaternion2
QuaternionSource Quaternion.
result
QuaternionThe result of the quaternion addition as an output parameter.
Concatenate(Quaternion, Quaternion)
Creates a new Quaternion that contains concatenation between two quaternion.
public static Quaternion Concatenate(Quaternion value1, Quaternion value2)
Parameters
value1
QuaternionThe first Quaternion to concatenate.
value2
QuaternionThe second Quaternion to concatenate.
Returns
- Quaternion
The result of rotation of
value1
followed byvalue2
rotation.
Concatenate(ref Quaternion, ref Quaternion, out Quaternion)
Creates a new Quaternion that contains concatenation between two quaternion.
public static void Concatenate(ref Quaternion value1, ref Quaternion value2, out Quaternion result)
Parameters
value1
QuaternionThe first Quaternion to concatenate.
value2
QuaternionThe second Quaternion to concatenate.
result
QuaternionThe result of rotation of
value1
followed byvalue2
rotation as an output parameter.
Conjugate()
Transforms this quaternion into its conjugated version.
public void Conjugate()
Conjugate(Quaternion)
Creates a new Quaternion that contains conjugated version of the specified quaternion.
public static Quaternion Conjugate(Quaternion value)
Parameters
value
QuaternionThe quaternion which values will be used to create the conjugated version.
Returns
- Quaternion
The conjugate version of the specified quaternion.
Conjugate(ref Quaternion, out Quaternion)
Creates a new Quaternion that contains conjugated version of the specified quaternion.
public static void Conjugate(ref Quaternion value, out Quaternion result)
Parameters
value
QuaternionThe quaternion which values will be used to create the conjugated version.
result
QuaternionThe conjugated version of the specified quaternion as an output parameter.
CreateFromAxisAngle(Vector3, float)
Creates a new Quaternion from the specified axis and angle.
public static Quaternion CreateFromAxisAngle(Vector3 axis, float angle)
Parameters
Returns
- Quaternion
The new quaternion builded from axis and angle.
CreateFromAxisAngle(ref Vector3, float, out Quaternion)
Creates a new Quaternion from the specified axis and angle.
public static void CreateFromAxisAngle(ref Vector3 axis, float angle, out Quaternion result)
Parameters
axis
Vector3The axis of rotation.
angle
floatThe angle in radians.
result
QuaternionThe new quaternion builded from axis and angle as an output parameter.
CreateFromEulerAngles(Vector3)
Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).
public static Quaternion CreateFromEulerAngles(Vector3 angles)
Parameters
angles
Vector3
Returns
CreateFromRotationMatrix(Matrix44)
Creates a new Quaternion from the specified Matrix44.
public static Quaternion CreateFromRotationMatrix(Matrix44 matrix)
Parameters
matrix
Matrix44The rotation matrix.
Returns
- Quaternion
A quaternion composed from the rotation part of the matrix.
CreateFromRotationMatrix(ref Matrix44, out Quaternion)
Fills existing Quaternion from the specified Matrix44.
public static void CreateFromRotationMatrix(ref Matrix44 matrix, out Quaternion result)
Parameters
matrix
Matrix44The rotation matrix.
result
QuaternionA quaternion composed from the rotation part of the matrix as an output parameter.
CreateFromYawPitchRoll(float, float, float)
Creates a new Quaternion from the specified yaw, pitch and roll angles.
public static Quaternion CreateFromYawPitchRoll(float yaw, float pitch, float roll)
Parameters
yaw
floatYaw around the y axis in radians.
pitch
floatPitch around the x axis in radians.
roll
floatRoll around the z axis in radians.
Returns
- Quaternion
A new quaternion from the concatenated yaw, pitch, and roll angles.
Divide(Quaternion, Quaternion)
Divides a Quaternion by the other Quaternion.
public static Quaternion Divide(Quaternion quaternion1, Quaternion quaternion2)
Parameters
quaternion1
QuaternionSource Quaternion.
quaternion2
QuaternionDivisor Quaternion.
Returns
- Quaternion
The result of dividing the quaternions.
Divide(ref Quaternion, ref Quaternion, out Quaternion)
Divides a Quaternion by the other Quaternion.
public static void Divide(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
Parameters
quaternion1
QuaternionSource Quaternion.
quaternion2
QuaternionDivisor Quaternion.
result
QuaternionThe result of dividing the quaternions as an output parameter.
Dot(Quaternion, Quaternion)
Returns a dot product of two quaternions.
public static float Dot(Quaternion quaternion1, Quaternion quaternion2)
Parameters
quaternion1
QuaternionThe first quaternion.
quaternion2
QuaternionThe second quaternion.
Returns
- float
The dot product of two quaternions.
Dot(ref Quaternion, ref Quaternion, out float)
Returns a dot product of two quaternions.
public static void Dot(ref Quaternion quaternion1, ref Quaternion quaternion2, out float result)
Parameters
quaternion1
QuaternionThe first quaternion.
quaternion2
QuaternionThe second quaternion.
result
floatThe dot product of two quaternions as an output parameter.
Equals(Quaternion)
Compares whether current instance is equal to specified Quaternion.
public bool Equals(Quaternion other)
Parameters
other
QuaternionThe Quaternion to compare.
Returns
- bool
true
if the instances are equal;false
otherwise.
Equals(object)
Compares whether current instance is equal to specified object.
public override bool Equals(object obj)
Parameters
Returns
- bool
true
if the instances are equal;false
otherwise.
GetHashCode()
Gets the hash code of this Quaternion.
public override int GetHashCode()
Returns
- int
Hash code of this Quaternion.
Inverse(Quaternion)
Returns the inverse quaternion which represents the opposite rotation.
public static Quaternion Inverse(Quaternion quaternion)
Parameters
quaternion
QuaternionSource Quaternion.
Returns
- Quaternion
The inverse quaternion.
Inverse(ref Quaternion, out Quaternion)
Returns the inverse quaternion which represents the opposite rotation.
public static void Inverse(ref Quaternion quaternion, out Quaternion result)
Parameters
quaternion
QuaternionSource Quaternion.
result
QuaternionThe inverse quaternion as an output parameter.
Length()
Returns the magnitude of the quaternion components.
public float Length()
Returns
- float
The magnitude of the quaternion components.
LengthSquared()
Returns the squared magnitude of the quaternion components.
public float LengthSquared()
Returns
- float
The squared magnitude of the quaternion components.
Lerp(Quaternion, Quaternion, float)
Performs a linear blend between two quaternions.
public static Quaternion Lerp(Quaternion value1, Quaternion value2, float amount)
Parameters
value1
QuaternionSource Quaternion.
value2
QuaternionSource Quaternion.
amount
floatThe blend amount where 0 returns
value1
and 1value2
.
Returns
- Quaternion
The result of linear blending between two quaternions.
Lerp(ref Quaternion, ref Quaternion, float, out Quaternion)
Performs a linear blend between two quaternions.
public static void Lerp(ref Quaternion value1, ref Quaternion value2, float amount, out Quaternion result)
Parameters
value1
QuaternionSource Quaternion.
value2
QuaternionSource Quaternion.
amount
floatThe blend amount where 0 returns
value1
and 1value2
.result
QuaternionThe result of linear blending between two quaternions as an output parameter.
Multiply(Quaternion, Quaternion)
Creates a new Quaternion that contains a multiplication of two quaternions.
public static Quaternion Multiply(Quaternion quaternion1, Quaternion quaternion2)
Parameters
quaternion1
QuaternionSource Quaternion.
quaternion2
QuaternionSource Quaternion.
Returns
- Quaternion
The result of the quaternion multiplication.
Multiply(Quaternion, float)
Creates a new Quaternion that contains a multiplication of Quaternion and a scalar.
public static Quaternion Multiply(Quaternion quaternion1, float scaleFactor)
Parameters
quaternion1
QuaternionSource Quaternion.
scaleFactor
floatScalar value.
Returns
- Quaternion
The result of the quaternion multiplication with a scalar.
Multiply(ref Quaternion, ref Quaternion, out Quaternion)
Creates a new Quaternion that contains a multiplication of two quaternions.
public static void Multiply(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
Parameters
quaternion1
QuaternionSource Quaternion.
quaternion2
QuaternionSource Quaternion.
result
QuaternionThe result of the quaternion multiplication as an output parameter.
Multiply(ref Quaternion, float, out Quaternion)
Creates a new Quaternion that contains a multiplication of Quaternion and a scalar.
public static void Multiply(ref Quaternion quaternion1, float scaleFactor, out Quaternion result)
Parameters
quaternion1
QuaternionSource Quaternion.
scaleFactor
floatScalar value.
result
QuaternionThe result of the quaternion multiplication with a scalar as an output parameter.
Negate(Quaternion)
Flips the sign of the all the quaternion components.
public static Quaternion Negate(Quaternion quaternion)
Parameters
quaternion
QuaternionSource Quaternion.
Returns
- Quaternion
The result of the quaternion negation.
Negate(ref Quaternion, out Quaternion)
Flips the sign of the all the quaternion components.
public static void Negate(ref Quaternion quaternion, out Quaternion result)
Parameters
quaternion
QuaternionSource Quaternion.
result
QuaternionThe result of the quaternion negation as an output parameter.
Normalize()
Scales the quaternion magnitude to unit length.
public void Normalize()
Normalize(Quaternion)
Scales the quaternion magnitude to unit length.
public static Quaternion Normalize(Quaternion quaternion)
Parameters
quaternion
QuaternionSource Quaternion.
Returns
- Quaternion
The unit length quaternion.
Normalize(ref Quaternion, out Quaternion)
Scales the quaternion magnitude to unit length.
public static void Normalize(ref Quaternion quaternion, out Quaternion result)
Parameters
quaternion
QuaternionSource Quaternion.
result
QuaternionThe unit length quaternion an output parameter.
Slerp(Quaternion, Quaternion, float)
Performs a spherical linear blend between two quaternions.
public static Quaternion Slerp(Quaternion quaternion1, Quaternion quaternion2, float amount)
Parameters
quaternion1
QuaternionSource Quaternion.
quaternion2
QuaternionSource Quaternion.
amount
floatThe blend amount where 0 returns
quaternion1
and 1quaternion2
.
Returns
- Quaternion
The result of spherical linear blending between two quaternions.
Slerp(ref Quaternion, ref Quaternion, float, out Quaternion)
Performs a spherical linear blend between two quaternions.
public static void Slerp(ref Quaternion quaternion1, ref Quaternion quaternion2, float amount, out Quaternion result)
Parameters
quaternion1
QuaternionSource Quaternion.
quaternion2
QuaternionSource Quaternion.
amount
floatThe blend amount where 0 returns
quaternion1
and 1quaternion2
.result
QuaternionThe result of spherical linear blending between two quaternions as an output parameter.
Subtract(Quaternion, Quaternion)
Creates a new Quaternion that contains subtraction of one Quaternion from another.
public static Quaternion Subtract(Quaternion quaternion1, Quaternion quaternion2)
Parameters
quaternion1
QuaternionSource Quaternion.
quaternion2
QuaternionSource Quaternion.
Returns
- Quaternion
The result of the quaternion subtraction.
Subtract(ref Quaternion, ref Quaternion, out Quaternion)
Creates a new Quaternion that contains subtraction of one Quaternion from another.
public static void Subtract(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
Parameters
quaternion1
QuaternionSource Quaternion.
quaternion2
QuaternionSource Quaternion.
result
QuaternionThe result of the quaternion subtraction as an output parameter.
ToEulerAngles()
Returns the x, y, and z angles represent a rotation z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order). Original code taken from: https://raw.githubusercontent.com/dfelinto/blender/0a446d7276e74e3c8472453948204ca6463d158e/source/blender/blenlib/intern/math_rotation.c
public Vector3 ToEulerAngles()
Returns
ToString()
public override string ToString()
Returns
- string
A string representation of this Quaternion.
TransformVector(Vector3)
public Vector3 TransformVector(Vector3 value)
Parameters
value
Vector3
Returns
Operators
operator +(Quaternion, Quaternion)
Adds two quaternions.
public static Quaternion operator +(Quaternion quaternion1, Quaternion quaternion2)
Parameters
quaternion1
QuaternionSource Quaternion on the left of the add sign.
quaternion2
QuaternionSource Quaternion on the right of the add sign.
Returns
- Quaternion
Sum of the vectors.
operator /(Quaternion, Quaternion)
Divides a Quaternion by the other Quaternion.
public static Quaternion operator /(Quaternion quaternion1, Quaternion quaternion2)
Parameters
quaternion1
QuaternionSource Quaternion on the left of the div sign.
quaternion2
QuaternionDivisor Quaternion on the right of the div sign.
Returns
- Quaternion
The result of dividing the quaternions.
operator ==(Quaternion, Quaternion)
Compares whether two Quaternion instances are equal.
public static bool operator ==(Quaternion quaternion1, Quaternion quaternion2)
Parameters
quaternion1
QuaternionQuaternion instance on the left of the equal sign.
quaternion2
QuaternionQuaternion instance on the right of the equal sign.
Returns
- bool
true
if the instances are equal;false
otherwise.
operator !=(Quaternion, Quaternion)
Compares whether two Quaternion instances are not equal.
public static bool operator !=(Quaternion quaternion1, Quaternion quaternion2)
Parameters
quaternion1
QuaternionQuaternion instance on the left of the not equal sign.
quaternion2
QuaternionQuaternion instance on the right of the not equal sign.
Returns
- bool
true
if the instances are not equal;false
otherwise.
operator *(Quaternion, Quaternion)
Multiplies two quaternions.
public static Quaternion operator *(Quaternion quaternion1, Quaternion quaternion2)
Parameters
quaternion1
QuaternionSource Quaternion on the left of the mul sign.
quaternion2
QuaternionSource Quaternion on the right of the mul sign.
Returns
- Quaternion
Result of the quaternions multiplication.
operator *(Quaternion, float)
Multiplies the components of quaternion by a scalar.
public static Quaternion operator *(Quaternion quaternion1, float scaleFactor)
Parameters
quaternion1
QuaternionSource Vector3 on the left of the mul sign.
scaleFactor
floatScalar value on the right of the mul sign.
Returns
- Quaternion
Result of the quaternion multiplication with a scalar.
operator *(Vector3, Quaternion)
public static Vector3 operator *(Vector3 a, Quaternion b)
Parameters
a
Vector3b
Quaternion
Returns
operator -(Quaternion, Quaternion)
Subtracts a Quaternion from a Quaternion.
public static Quaternion operator -(Quaternion quaternion1, Quaternion quaternion2)
Parameters
quaternion1
QuaternionSource Vector3 on the left of the sub sign.
quaternion2
QuaternionSource Vector3 on the right of the sub sign.
Returns
- Quaternion
Result of the quaternion subtraction.
operator -(Quaternion)
Flips the sign of the all the quaternion components.
public static Quaternion operator -(Quaternion quaternion)
Parameters
quaternion
QuaternionSource Quaternion on the right of the sub sign.
Returns
- Quaternion
The result of the quaternion negation.