Struct Quaternion
- Namespace
- Cobilas.GodotEngine.Utility.Numerics
- Assembly
- com.cobilas.godot.utility.dll
Quaternions are used to represent rotations.
[Serializable]
public struct Quaternion : IEquatable<Quaternion>, IFormattable
- Implements
- Inherited Members
Constructors
Quaternion(Quaternion)
Starts a new instance of the object.
public Quaternion(Quaternion vector)
Parameters
vector
Quaternion
Quaternion(Vector4D)
Starts a new instance of the object.
public Quaternion(Vector4D vector)
Parameters
vector
Vector4D
Quaternion(float, float)
Starts a new instance of the object.
public Quaternion(float x, float y)
Parameters
Quaternion(float, float, float)
Starts a new instance of the object.
public Quaternion(float x, float y, float z)
Parameters
Quaternion(float, float, float, float)
Starts a new instance of the object.
public Quaternion(float x, float y, float z, float w)
Parameters
Fields
Deg2Rad
Radians-to-degrees conversion constant (Read Only).
public const double Deg2Rad = 0.017453292519943295
Field Value
KEpsilon
A small value used to compare quaternions for equality.
public const float KEpsilon = 1E-06
Field Value
Remarks
The kEpsilon
constant is used to determine if two quaternions are nearly equal, accounting for floating-point precision errors.
Rad2Deg
Degrees-to-radians conversion constant (Read Only).
public const double Rad2Deg = 57.29577951308232
Field Value
w
W component of the Quaternion. Do not directly modify quaternions.
public float w
Field Value
x
X component of the Quaternion. Don't modify this directly unless you know quaternions inside out.
public float x
Field Value
y
Y component of the Quaternion. Don't modify this directly unless you know quaternions inside out.
public float y
Field Value
z
Z component of the Quaternion. Don't modify this directly unless you know quaternions inside out.
public float z
Field Value
Properties
Euler
Returns or sets the euler angle representation of the rotation.
public readonly Vector3D Euler { get; }
Property Value
Identity
The identity rotation (Read Only).
public static Quaternion Identity { get; }
Property Value
Normalized
Returns this quaternion with a magnitude of 1 (Read Only).
public readonly Quaternion Normalized { get; }
Property Value
Methods
Angle(Quaternion, Quaternion)
Returns the angle in degrees between two rotations a and b.
public static float Angle(Quaternion a, Quaternion b)
Parameters
a
QuaternionObject to be compared.
b
QuaternionObject of comparison.
Returns
- float
The floating point angle.
Dot(Quaternion, Quaternion)
The dot product between two rotations.
public static float Dot(Quaternion a, Quaternion b)
Parameters
a
QuaternionObject to be compared.
b
QuaternionObject of comparison.
Returns
- float
Returns the dot product of two quaternions.
Equals(Quaternion)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(Quaternion other)
Parameters
other
QuaternionAn object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Normalize(Quaternion)
Converts this quaternion to one with the same orientation but with a magnitude of 1.
public static Quaternion Normalize(Quaternion q)
Parameters
q
QuaternionThe Quaternion that will be normalized.
Returns
- Quaternion
Returns an already normalized Quaternion.
ToEuler(Quaternion)
Convert quaternion to euler-angle.
public static Vector3D ToEuler(Quaternion quaternion)
Parameters
quaternion
QuaternionThe quaternion that will be converted.
Returns
- Vector3D
The result of the conversion from quaternion to euler.
ToQuaternion(Vector3D)
Convert euler-angle to quaternion.
public static Quaternion ToQuaternion(Vector3D vector)
Parameters
vector
Vector3DEuler-angle that will be converted.
Returns
- Quaternion
Return result of euler to quaternion conversion.
ToString()
Returns the fully qualified type name of this instance.
public override readonly string ToString()
Returns
- string
The fully qualified type name.
ToString(string)
Formats the value of the current instance using the specified format.
public readonly string ToString(string format)
Parameters
format
stringThe format to use.-or- A null reference (
Nothing
in Visual Basic) to use the default format defined for the type of the IFormattable implementation.
Returns
- string
The value of the current instance in the specified format.
ToString(string, IFormatProvider)
Formats the value of the current instance using the specified format.
public readonly string ToString(string format, IFormatProvider formatProvider)
Parameters
format
stringThe format to use.-or- A null reference (
Nothing
in Visual Basic) to use the default format defined for the type of the IFormattable implementation.formatProvider
IFormatProviderThe provider to use to format the value.-or- A null reference (
Nothing
in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
Operators
operator ==(Quaternion, Quaternion)
Indicates whether this instance is equal to another instance of the same type.
public static bool operator ==(Quaternion lhs, Quaternion rhs)
Parameters
lhs
QuaternionObject to be compared.
rhs
QuaternionObject of comparison.
Returns
- bool
Returns the result of the comparison.
implicit operator Vector4D(Quaternion)
Implicit conversion operator.(Quaternion to Vector4D)
public static implicit operator Vector4D(Quaternion v)
Parameters
v
QuaternionObject to be converted.
Returns
operator !=(Quaternion, Quaternion)
Indicates whether this instance is different from another instance of the same type.
public static bool operator !=(Quaternion lhs, Quaternion rhs)
Parameters
lhs
QuaternionObject to be compared.
rhs
QuaternionObject of comparison.
Returns
- bool
Returns the result of the comparison.
operator *(Quaternion, Quaternion)
Multiplication operation between two values.(Quaternion * Quaternion)
public static Quaternion operator *(Quaternion lhs, Quaternion rhs)
Parameters
lhs
QuaternionFirst module.
rhs
QuaternionSecond module.
Returns
- Quaternion
The result of the multiplication.
operator *(Quaternion, Vector3D)
Multiplication operation between two values.(Quaternion * Vector3D)
public static Vector3D operator *(Quaternion rotation, Vector3D point)
Parameters
rotation
QuaternionFirst module.
point
Vector3DSecond module.
Returns
- Vector3D
The result of the multiplication.