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.
toString
alias toString = as_string
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

invert
void invert()

Inverts the quaternion.

make_identity
void make_identity()

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.
opCast
bool opCast()
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.
rotate_axis
Quaternion rotate_axis(real alpha, Vector!(qt, 3) axis)

Rotates the current quaternion around an axis and returns this.

rotate_euler
Quaternion rotate_euler(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.

to_axis_angle
vec3 to_axis_angle()

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

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

Returns the quaternion as matrix.

Properties

as_string
string as_string [@property getter]

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

get_
qt get_ [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
identity
Quaternion identity [@property getter]

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

inverse
Quaternion inverse [@property getter]

Returns an inverted copy of the current quaternion.

isFinite
bool isFinite [@property getter]

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

magnitude
real magnitude [@property getter]

Returns the magnitude of the quaternion.

magnitude_squared
real magnitude_squared [@property getter]

Returns the squared magnitude of the quaternion.

pitch
real pitch [@property getter]

Returns the pitch.

roll
real roll [@property getter]

Returns the roll.

set_
qt set_ [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
value_ptr
auto value_ptr [@property getter]

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

yaw
real yaw [@property getter]

Returns the yaw.

Static functions

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

Returns a quaternion with applied rotation around an axis.

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

Creates a quaternion from an euler rotation.

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

Creates a quaternion from a 3x3 matrix.

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

coord_to_index
template coord_to_index(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