Quaternion

Base template for all quaternion-types.

struct Quaternion (
type
) {}

Constructors

this
this(qt w_, qt x_, qt y_, qt z_)
this(qt w_, Vector!(qt, 3) vec)
this(Vector!(qt, 4) vec)

Constructs the quaternion. Takes a 4-dimensional vector, where vector.x = the quaternions w coordinate, or a w coordinate of type qt and a 3-dimensional vector representing the imaginary part, or 4 values of type qt.

Members

Aliases

conjugate
alias conjugate = invert
Undocumented in source.
conjugated
alias conjugated = inverse
Undocumented in source.
ok
deprecated alias ok = isFinite
Undocumented in source.
qt
alias qt = type
Undocumented in source.
w
alias w = get_!'w'
Undocumented in source.
w
alias w = set_!'w'
Undocumented in source.
x
alias x = get_!'x'
Undocumented in source.
x
alias x = set_!'x'
Undocumented in source.
y
alias y = get_!'y'
Undocumented in source.
y
alias y = set_!'y'
Undocumented in source.
z
alias z = get_!'z'
Undocumented in source.
z
alias z = set_!'z'
Undocumented in source.

Functions

get_
qt get_()
Undocumented in source. Be warned that the author may not have intended to support it.
inverse
Quaternion inverse()

Returns an inverted copy of the current quaternion.

invert
void invert()

Inverts the quaternion.

isFinite
bool isFinite()

Returns true if all values are not nan and finite, otherwise false.

magnitude
real magnitude()

Returns the magnitude of the quaternion.

magnitudeSquared
real magnitudeSquared()

Returns the squared magnitude of the quaternion.

makeIdentity
void makeIdentity()

Makes the current quaternion an identity quaternion.

normalize
void normalize()

Normalizes the current quaternion.

normalized
Quaternion normalized()

Returns a normalized copy of the current quaternion.

opBinary
Quaternion opBinary(Quaternion inp)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
Quaternion opBinary(Quaternion inp)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
Vector!(qt, 3) opBinary(Vector!(qt, 3) inp)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
Quaternion opBinary(qt inp)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinaryRight
auto opBinaryRight(T inp)
Undocumented in source. Be warned that the author may not have intended to support it.
opCmp
int opCmp(Quaternion qua)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Quaternion qu)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
void opOpAssign(Quaternion inp)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
void opOpAssign(Quaternion inp)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
void opOpAssign(qt inp)
Undocumented in source. Be warned that the author may not have intended to support it.
pitch
real pitch()

Returns the pitch.

ptr
auto ptr()

Returns a pointer to the quaternion in memory, it starts with the w coordinate.

roll
real roll()

Returns the roll.

rotateAxis
Quaternion rotateAxis(real alpha, Vector!(qt, 3) axis)

Rotates the current quaternion around an axis and returns this.

rotateEuler
Quaternion rotateEuler(real heading, real attitude, real bank)

Applies an euler rotation to the current quaternion and returns this.

rotateX
Quaternion rotateX(real alpha)

Rotates the current quaternion around the x-axis and returns this.

rotateY
Quaternion rotateY(real alpha)

Rotates the current quaternion around the y-axis and returns this.

rotateZ
Quaternion rotateZ(real alpha)

Rotates the current quaternion around the z-axis and returns this.

set_
void set_(qt value)
Undocumented in source. Be warned that the author may not have intended to support it.
toAxisAngle
vec3 toAxisAngle()

Returns the quaternion as a vec3 (axis / angle representation).

toHash
size_t toHash()

Gets a hash of this item

toMatrix
Matrix!(qt, rows, cols) toMatrix()

Returns the quaternion as matrix.

toString
string toString()

Returns the current vector formatted as string, useful for printing the quaternion.

yaw
real yaw()

Returns the yaw.

Static functions

axisRotation
Quaternion axisRotation(real alpha, Vector!(qt, 3) axis)

Returns a quaternion with applied rotation around an axis.

eulerRotation
Quaternion eulerRotation(real roll, real pitch, real yaw)

Creates a quaternion from an euler rotation.

fromMatrix
Quaternion fromMatrix(Matrix!(qt, 3, 3) matrix)

Creates a quaternion from a 3x3 matrix.

identity
Quaternion identity()

Returns an identity quaternion (w=1, x=0, y=0, z=0).

lookRotation
Quaternion lookRotation(vec3 forward, vec3 up)

Makes a quaternion with the specified forward and upwards directions in a Unity compatible manner. Implementation from http://answers.unity3d.com/questions/467614/what-is-the-source-code-of-quaternionlookrotation.html

xRotation
Quaternion xRotation(real alpha)

Returns a quaternion with applied rotation around the x-axis.

yRotation
Quaternion yRotation(real alpha)

Returns a quaternion with applied rotation around the y-axis.

zRotation
Quaternion zRotation(real alpha)

Returns a quaternion with applied rotation around the z-axis.

Templates

coordToIndex
template coordToIndex(char c)
Undocumented in source.

Variables

quaternion
qt[4] quaternion;

Holds the w, x, y and z coordinates.

Parameters

type

all values get stored as this type

Meta