zmath.quaternion
A Quaternion it's used to store a space orientation / rotation, and makes easy to interpolate rotations, at same time that avoid grimbal locks that have using Euler angles
-
Declaration
aliasQua_f= Quaternion!float.Quaternion;Alias of a Quaternion with floats
-
Declaration
aliasQua_d= Quaternion!double.Quaternion;Alias of a Quaternion with doubles
-
Declaration
aliasQua_r= Quaternion!real.Quaternion;Alias of a Quaternion with reals
-
Declaration
structQuaternion(T = floatt) if (__traits(isFloating, T));Quaternionover a FloatPoint type,-
Declaration
static enum size_tdim;Quaternion Dimension
-
Declaration
Ti;icomplex component -
Declaration
Tj;jcomplex component -
Declaration
Tk;kcomplex component -
Declaration
Tw;wreal component -
Declaration
Tx;alias of i component
-
Declaration
Ty;alias of j component
-
Declaration
Tz;alias of k component
-
Declaration
this(in Ti, in Tj, in Tk, in Tw);Build a new Quaternion from a set of initial values
Parameters
Tiiimaginary componentTjjimaginary componentTkkimaginary componentTwireal component -
Declaration
this(in T[]xs);Build a new Quaternion from a array If no there values for j, and k, will be set to 0. w is set to 1
Parameters
T[]xsArray with coords
-
Declaration
pure @nogc this(in Vector!(T, 3)vec);Build a new Quaternion from a 3D Vector w will be set to 1
Parameters
Vector!(T, 3)vecVector 3d
-
Declaration
pure @nogc this(in Vector!(T, 4)vec);Build a new Quaternion from a 4D Vector
Parameters
Vector!(T, 4)vecVector 4d
-
Declaration
@nogc this(U)(Vector!(T, 3)v, Uangle) if (is(U : real));Creates a Quaternion from a 3d Vector and
angleParameters
Vector!(T, 3)vRotation axis
UangleRotation
anglein radiansReturn Value
Quaternion that represents a rotation
-
Declaration
@nogc this(U)(Uroll, Upitch, Uyaw) if (__traits(isFloating, U));Creates a new Quaternion from Euler angles Params :
roll= Rotation around X axis in radians (aka bank)pitch= Rotation around Y axis in radians (aka attitude)yaw= Rotation around Z axis in radians (aka heading)Return Value
Quaternion that represents a rotation
-
Declaration
const pure @nogc TopIndex(size_ti);Returns
icoord of this vector -
Declaration
@nogc voidopIndexAssign(Tc, size_ti);Assigns a value to a coord
-
Declaration
const pure @nogc @property Tlength();Returns the actual
lengthof this quaternion -
Declaration
const pure @nogc @property Tsq_length();Returns the actual squared length of this quaternion
-
Declaration
const pure @nogc boolopEquals()(auto ref const Quaternionrhs);Define Equality
-
Declaration
const pure @nogc boolapproxEqual()(auto ref const Quaternionrhs, TmaxRelDiff= 0.01, TmaxAbsDiff= 1e-05);Approximated equality with controlable precision
-
Declaration
const pure @nogc QuaternionopUnary(string op)() if (op == "+" || op == "-");Define unary operators + and -
-
Declaration
const pure @nogc QuaternionopBinary(string op)(auto ref const Quaternionrhs) if (op == "+" || op == "-");Define binary operator + and -
-
Declaration
const pure @nogc QuaternionopBinary(string op)(in Trhs) if (op == "*");Define Scalar multiplication
-
Declaration
const pure @nogc QuaternionopBinary(string op)(auto ref const Quaternionrhs) if (op == "*");Defines Hamilton product for Quaternions
Parameters
QuaternionrhsQuaternion at rigth of operation
Return: Quaternion result of hamilton product of this and
rhs(thisrhs) -
Declaration
const pure @nogc Quaternionconj();Obtain conjugate of a Quaternion
-
Declaration
const pure @nogc @property boolisUnit();It's a unitary Quaternion (length == 1)
-
Declaration
pure @nogc voidnormalize();Normalize this Quaternion
-
Declaration
const pure Vrotate(V)(auto ref const Vv) if (isVector!V && (V.dim >= 3));Apply a 3d rotation Quaternion over a 3d/4d Vector
-
Declaration
const pure @nogc Vector!(T, 3)toAxisAngle(out Tangle);Calc the Axis and
angleof rotation of this QuaternionParameters
TangleSet to
angleof rotationReturn Value
Axis of rotation vector
-
Declaration
const pure @nogc Vector!(T, 3)toEuler();Returns a Vector with euler's angles
Return Value
Vector with Euler angles of rotation in radians
TODO: Improve using code from here to avoid requiring pre-normalize the quaternion http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/
-
Declaration
const pure @nogc ToutopCast(Tout)() if (isQuaternion!Tout);Casting for convert between Quaternions
-
Declaration
const pure @nogc ToutopCast(Tout)() if (isMatrix!Tout && (Tout.dim >= 3));Casting to rotation Matrix
-
Declaration
stringtoString();Returns a string representation of this Quaternion
-
-
Declaration
immutable boolisQuaternion(T);Say if a thing it's a Quaternion