Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

quaternion(9) [plan9 man page]

QUATERNION(9.2) 														   QUATERNION(9.2)

NAME
qtom, mtoq, qadd, qsub, qneg, qmul, qdiv, qunit, qinv, qlen, slerp, qmid, qsqrt - Quaternion arithmetic SYNOPSIS
#include <libg.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 r and an imaginary vector component v=(i,j,k). Quaternions add component- wise and multiply according to the rule (r,v)(s,w)=(rs-v.w, rw+vs+vxw), where . and x 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 typedef struct Quaternion Quaternion; struct Quaternion{ double r, i, j, k; }; Name Description qadd Add two quaternions. qsub Subtract two quaternions. qneg Negate a quaternion. qmul Multiply two quaternions. qdiv Divide two quaternions. qinv Return the multiplicative inverse of a quaternion. qlen Return sqrt(q.r*q.r+q.i*q.i+q.j*q.j+q.k*q.k), the length of a quaternion. qunit Return a unit quaternion (length=1) with components proportional to q's. A rotation by angle 0 about axis A (where A is a unit vector) can be represented by the unit quaternion q=(cos 0/2, Asin 0/2). The same rotation is represented by -q; a rotation by -0 about -A is the same as a rotation by 0 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: mtoq Convert a rotation matrix (see tstack(9.2)) to a unit quaternion. qtom Convert a unit quaternion to a rotation matrix. slerp Spherical lerp. Interpolate between two orientations. The rotation that carries q to r is q-1r, so slerp(q, r, t) is q(q-1r)t. qmid slerp(q, r, .5) qsqrt The square root of q. This is just a rotation about the same axis by half the angle. SOURCE
/sys/src/libgeometry/quaternion.c SEE ALSO
tstack(9.2), qball(9.2) QUATERNION(9.2)

Check Out this Related Man Page

SbDPRotation(3) 						       Coin							   SbDPRotation(3)

NAME
SbDPRotation - The SbDPRotation class represents a rotation in 3D space. SbDPRotation is used extensively throughout the Coin library. SYNOPSIS
#include <Inventor/SbLinear.h> Public Member Functions SbDPRotation (void) SbDPRotation (const SbVec3d &axis, const double radians) SbDPRotation (const double q[4]) SbDPRotation (const double q0, const double q1, const double q2, const double q3) SbDPRotation (const SbDPMatrix &m) SbDPRotation (const SbVec3d &rotateFrom, const SbVec3d &rotateTo) const double * getValue (void) const void getValue (double &q0, double &q1, double &q2, double &q3) const SbDPRotation & setValue (const double q0, const double q1, const double q2, const double q3) void getValue (SbVec3d &axis, double &radians) const void getValue (SbDPMatrix &matrix) const SbDPRotation & invert (void) SbDPRotation inverse (void) const SbDPRotation & setValue (const double q[4]) SbDPRotation & setValue (const SbDPMatrix &m) SbDPRotation & setValue (const SbVec3d &axis, const double radians) SbDPRotation & setValue (const SbVec3d &rotateFrom, const SbVec3d &rotateTo) SbDPRotation & operator*= (const SbDPRotation &q) SbDPRotation & operator*= (const double s) SbBool equals (const SbDPRotation &r, const double tolerance) const void multVec (const SbVec3d &src, SbVec3d &dst) const void scaleAngle (const double scaleFactor) void print (FILE *fp) const Static Public Member Functions static SbDPRotation slerp (const SbDPRotation &rot0, const SbDPRotation &rot1, double t) static SbDPRotation identity (void) Friends int operator== (const SbDPRotation &q1, const SbDPRotation &q2) int operator!= (const SbDPRotation &q1, const SbDPRotation &q2) SbDPRotation operator* (const SbDPRotation &q1, const SbDPRotation &q2) Detailed Description The SbDPRotation class represents a rotation in 3D space. SbDPRotation is used extensively throughout the Coin library. An SbDPRotation is stored internally as a quaternion for speed and storage reasons, but inquiries can be done to get and set axis and angle values for convenience. See also: SbDPMatrix Constructor &; Destructor Documentation SbDPRotation::SbDPRotation (void) The default constructor just initializes a valid rotation. The actual value is unspecified, and you should not depend on it. SbDPRotation::SbDPRotation (const SbVec3d &axis, const doubleradians) Construct a new SbDPRotation object initialized with the given axis-of-rotation and rotation angle. SbDPRotation::SbDPRotation (const doubleq[4]) Construct a new SbDPRotation object initialized with the given quaternion components. The array must be ordered as follows: q[0] = x, q[1] = y, q[2] = z and q[3] = w, where the quaternion is specified by q=w+xi+yj+zk. SbDPRotation::SbDPRotation (const doubleq0, const doubleq1, const doubleq2, const doubleq3) Construct a new SbDPRotation object initialized with the given quaternion components. SbDPRotation::SbDPRotation (const SbDPMatrix &m) Construct a new SbDPRotation object initialized with the given rotation matrix. SbDPRotation::SbDPRotation (const SbVec3d &rotateFrom, const SbVec3d &rotateTo) Construct a rotation which is the minimum rotation necessary to make vector rotateFrom point in the direction of vector rotateTo. Member Function Documentation const double * SbDPRotation::getValue (void) const Return pointer to an array with the rotation expressed as four quaternion values. See also: setValue(). void SbDPRotation::getValue (double &q0, double &q1, double &q2, double &q3) const Return the four quaternion components representing the rotation. See also: setValue(). SbDPRotation & SbDPRotation::setValue (const doubleq0, const doubleq1, const doubleq2, const doubleq3) Set the rotation. See also: getValue(). void SbDPRotation::getValue (SbVec3d &axis, double &radians) const Return the rotation in the form of an axis-of-rotation and a rotation angle. See also: setValue(). void SbDPRotation::getValue (SbDPMatrix &matrix) const Return this rotation in the form of a matrix. See also: setValue(). SbDPRotation & SbDPRotation::invert (void) Invert the rotation. Returns reference to self. See also: inverse() SbDPRotation SbDPRotation::inverse (void) const Non-destructively inverses the rotation and returns the result. See also: invert() SbDPRotation & SbDPRotation::setValue (const doubleq[4]) Reset the rotation by the four quaternions in the array. See also: getValue(). SbDPRotation & SbDPRotation::setValue (const SbDPMatrix &m) Set the rotation from the components of the given matrix. Returns reference to self. See also: getValue(). SbDPRotation & SbDPRotation::setValue (const SbVec3d &axis, const doubleradians) Reset rotation with the given axis-of-rotation and rotation angle. Returns reference to self. Make sure axis is not the null vector when calling this method. See also: getValue(). SbDPRotation & SbDPRotation::setValue (const SbVec3d &rotateFrom, const SbVec3d &rotateTo) Construct a rotation which is the minimum rotation necessary to make vector rotateFrom point in the direction of vector rotateTo. Returns reference to self. See also: getValue(). SbDPRotation & SbDPRotation::operator*= (const SbDPRotation &q) Multiplies the quaternions. Note that order is important when combining quaternions with the multiplication operator. SbDPRotation & SbDPRotation::operator*= (const doubles) Multiplies components of quaternion with scalar value s. Returns reference to self. SbBool SbDPRotation::equals (const SbDPRotation &r, const doubletolerance) const Check the internal quaternion representation vectors for equality within the given tolerance. void SbDPRotation::multVec (const SbVec3d &src, SbVec3d &dst) const Rotate the src vector and put the result in dst. void SbDPRotation::scaleAngle (const doublescaleFactor) Scale the angle of rotation by scaleFactor. SbDPRotation slerp (const SbDPRotation &rot0, const SbDPRotation &rot1, doublet) [static] Interpolates along the shortest path between the two rotation positions (from rot0 to rot1). Returns the SbDPRotation which will rotate rot0 the given part t of the spherical distance towards rot1, where t=0 will yield rot0 and t=1 will yield rot1. t should be in the interval [0, 1]. SbDPRotation SbDPRotation::identity (void) [static] Returns an identity rotation. void SbDPRotation::print (FILE *fp) const Dump the state of this object to the file stream. Only works in debug version of library, method does nothing in an optimized compile. Friends And Related Function Documentation int operator== (const SbDPRotation &q1, const SbDPRotation &q2) [friend] Check if the two rotations are equal. See also: equals(). int operator!= (const SbDPRotation &q1, const SbDPRotation &q2) [friend] Check if the two rotations are unequal. See also: equals(). SbDPRotation operator* (const SbDPRotation &q1, const SbDPRotation &q2) [friend] Multiplies the two rotations and returns the result. Note that order is important when combining quaternions with the multiplication operator. Author Generated automatically by Doxygen for Coin from the source code. Version 3.1.3 Wed May 23 2012 SbDPRotation(3)
Man Page