libg3d Reference Manual | ||||
---|---|---|---|---|
#include <g3d/quat.h> typedef G3DQuat; gboolean g3d_quat_add (G3DQuat *qr, G3DQuat *q1, G3DQuat *q2); gboolean g3d_quat_normalize (G3DQuat *q); gboolean g3d_quat_rotate (G3DQuat *q, G3DVector *axis, G3DFloat angle); gboolean g3d_quat_to_matrix (G3DQuat *q, G3DMatrix *matrix); gboolean g3d_quat_to_rotation_xyz (G3DQuat *q, G3DFloat *rx, G3DFloat *ry, G3DFloat *rz); gboolean g3d_quat_trackball (G3DQuat *q, G3DFloat x1, G3DFloat y1, G3DFloat x2, G3DFloat y2, G3DFloat r);
gboolean g3d_quat_add (G3DQuat *qr, G3DQuat *q1, G3DQuat *q2);
Add two quats.
|
result quat |
|
first quat |
|
second quat |
Returns : |
TRUE on success, FALSE else |
gboolean g3d_quat_normalize (G3DQuat *q);
normalize the quaternion to a length of 1.0.
|
a quaternion |
Returns : |
TRUE on success, FALSE else |
gboolean g3d_quat_rotate (G3DQuat *q, G3DVector *axis, G3DFloat angle);
Encode a rotation around an axis into quaternion.
|
resulting quat |
|
rotation axis |
|
rotation angle |
Returns : |
TRUE on success, FALSE else |
gboolean g3d_quat_to_matrix (G3DQuat *q, G3DMatrix *matrix);
Convert a quaternion to a transformation matrix.
|
source quat |
|
resulting matrix |
Returns : |
TRUE on success, FALSE else |
gboolean g3d_quat_to_rotation_xyz (G3DQuat *q, G3DFloat *rx, G3DFloat *ry, G3DFloat *rz);
Calculate the rotation around the three coordinate axes from a given quaternion.
|
a quaternion |
|
rotation around x axis |
|
rotation around y axis |
|
rotation around z axis |
Returns : |
TRUE on success, FALSE else |
gboolean g3d_quat_trackball (G3DQuat *q, G3DFloat x1, G3DFloat y1, G3DFloat x2, G3DFloat y2, G3DFloat r);
Emulate a virtual trackball movement and return rotation as quaternion. The x and y values of the starting and end point of the movement have to be in the range -1.0 .. 1.0.
|
resulting quaternion |
|
x value of first point |
|
y value of first point |
|
x value of second point |
|
y value of second point |
|
radius of virtual trackball, usually 0.8 |
Returns : |
TRUE on success, FALSE else |