QUATERNION(2)QUATERNION(2)
NAME
qtom, mtoq, qadd, qsub, qneg, qmul, qdiv, qunit, qinv, qlen, slerp, qmid, qsqrt – Quaternion arithmetic
SYNOPSIS
#include <draw.h>
#include <geometry.h>
Quaternion qadd(Quaternion q, Quaternion r)
Quaternion qsub(Quaternion q, Quaternion r)
Quaternion qneg(Quaternion q)
Quaternion qmul(Quaternion q, Quaternion r)
Quaternion qdiv(Quaternion q, Quaternion r)
Quaternion qinv(Quaternion q)
double qlen(Quaternion p)
Quaternion qunit(Quaternion q)
void qtom(Matrix m, Quaternion q)
Quaternion mtoq(Matrix mat)
Quaternion slerp(Quaternion q, Quaternion r, double a)
Quaternion qmid(Quaternion q, Quaternion r)
Quaternion qsqrt(Quaternion q)
DESCRIPTION
The Quaternions are a non-commutative extension field of the Real numbers, designed
to do for rotations in 3-space what the complex numbers do for rotations in 2-space.
Quaternions have a real component
The following routines do arithmetic on quaternions, represented as
typedef struct Quaternion Quaternion; struct Quaternion{ double r, i, j, k; };
Description
Add two quaternions.
Subtract two quaternions.
Negate a quaternion.
Multiply two quaternions.
Divide two quaternions.
Return the multiplicative inverse of a quaternion.
Return
Return a unit quaternion
A rotation by angle θ about axis
The following routines operate on rotations or orientations represented as unit quaternions:
Convert a rotation matrix (see
Convert a unit quaternion to a rotation matrix.
Spherical lerp. Interpolate between two orientations.
The rotation that carries
The square root of