Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

qball(9) [plan9 man page]

QBALL(9.2)																QBALL(9.2)

NAME
qball - 3-d rotation controller SYNOPSIS
#include <libg.h> #include <geometry.h> void qball(Rectangle r, Mouse *mousep, Quaternion *orientation, void (*redraw)(void), Quaternion *ap) DESCRIPTION
Qball is an interactive controller that allows arbitrary 3-space rotations to be specified with the mouse. Imagine a sphere with its cen- ter at the midpoint of rectangle r, and diameter the smaller of r's dimensions. Dragging from one point on the sphere to another specifies the endpoints of a great-circle arc. (Mouse points outside the sphere are projected to the nearest point on the sphere.) The axis of rotation is normal to the plane of the arc, and the angle of rotation is twice the angle of the arc. Argument mousep is a pointer to the mouse event that triggered the interaction. It should have some button set. Qball will read more events into mousep, and return when no buttons are down. While qball is reading mouse events, it calls out to the caller-supplied routine redraw, which is expected to update the screen to reflect the changing orientation. Argument orientation is the orientation that redraw should examine, represented as a unit Quaternion (see quaternion(9.2)). The caller may set it to any orientation. It will be updated before each call to redraw (and on return) by multiplying by the rotation specified with the mouse. It is possible to restrict qball's attention to rotations about a particular axis. If ap is null, the rotation is unconstrained. Other- wise, the rotation will be about the same axis as *ap. This is accomplished by projecting points on the sphere to the nearest point also on the plane through the sphere's center and normal to the axis. SOURCE
/sys/src/libgeometry/qball.c SEE ALSO
quaternion(9.2) Ken Shoemake, ``Animating Rotation with Quaternion Curves'', SIGGRAPH '85 Conference Proceedings. QBALL(9.2)

Check Out this Related 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)
Man Page