|
NAMEqtom, mtoq, qadd, qsub, qneg, qmul, qdiv, qunit, qinv, qlen, slerp, qmid, qsqrt - Quaternion arithmeticSYNOPSIS#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) DESCRIPTIONThe 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 r and an imaginary vector component v=(i,j,k). Quaternions add componentwise and multiply according to the rule (r,v)(s,w)=(rs-v.w, rw+vs+v×w), where . and × are the ordinary vector dot and cross products. The multiplicative inverse of a non-zero quaternion (r,v) is (r,-v)/(r2-v.v).The following routines do arithmetic on quaternions, represented as
A rotation by angle θ about axis A (where A is a unit vector) can be represented by the unit quaternion q=(cos θ/2, Asin θ/2). The same rotation is represented by −q; a rotation by −θ about −A is the same as a rotation by θ about A. The quaternion q transforms points by (0,x',y',z') = q-1(0,x,y,z)q. Quaternion multiplication composes rotations. The orientation of an object in 3-space can be represented by a quaternion giving its rotation relative to some `standard' orientation. The following routines operate on rotations or orientations represented as unit quaternions:
SOURCE/src/libgeometry/quaternion.cSEE ALSOBUGSTo avoid name conflicts with NetBSD, qdiv is a preprocessor macro defined as p9qdiv; see Visit the GSP FreeBSD Man Page Interface. |