Table of Contents

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

x float
y float

Quaternion(float, float, float)

Starts a new instance of the object.

public Quaternion(float x, float y, float z)

Parameters

x float
y float
z float

Quaternion(float, float, float, float)

Starts a new instance of the object.

public Quaternion(float x, float y, float z, float w)

Parameters

x float
y float
z float
w float

Fields

Deg2Rad

Radians-to-degrees conversion constant (Read Only).

public const double Deg2Rad = 0.017453292519943295

Field Value

double

KEpsilon

A small value used to compare quaternions for equality.

public const float KEpsilon = 1E-06

Field Value

float

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

double

w

W component of the Quaternion. Do not directly modify quaternions.

public float w

Field Value

float

x

X component of the Quaternion. Don't modify this directly unless you know quaternions inside out.

public float x

Field Value

float

y

Y component of the Quaternion. Don't modify this directly unless you know quaternions inside out.

public float y

Field Value

float

z

Z component of the Quaternion. Don't modify this directly unless you know quaternions inside out.

public float z

Field Value

float

Properties

Euler

Returns or sets the euler angle representation of the rotation.

public readonly Vector3D Euler { get; }

Property Value

Vector3D

Identity

The identity rotation (Read Only).

public static Quaternion Identity { get; }

Property Value

Quaternion

Normalized

Returns this quaternion with a magnitude of 1 (Read Only).

public readonly Quaternion Normalized { get; }

Property Value

Quaternion

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 Quaternion

Object to be compared.

b Quaternion

Object 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 Quaternion

Object to be compared.

b Quaternion

Object 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 Quaternion

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object obj)

Parameters

obj object

The 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 Quaternion

The 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 Quaternion

The 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 Vector3D

Euler-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 string

The 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 string

The 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 IFormatProvider

The 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 Quaternion

Object to be compared.

rhs Quaternion

Object 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 Quaternion

Object to be converted.

Returns

Vector4D

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 Quaternion

Object to be compared.

rhs Quaternion

Object 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 Quaternion

First module.

rhs Quaternion

Second 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 Quaternion

First module.

point Vector3D

Second module.

Returns

Vector3D

The result of the multiplication.