2
* Quat.h - quaternion rotation and mathematics header.
3
* Copyright (C) 2010 D Haley
4
* THanks to R. Minehan for mathematical discussions.
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24
//needed for sin and cos
42
//conjugates the argument
47
void quat_conj(Quaternion *quat);
48
//calculates the square length of the quaternion
49
float quat_sqrlen(Quaternion *quat);
50
//multiplies two quaternions result=q1*q2
51
void quat_mult(Quaternion *result, Quaternion *q1, Quaternion *q2);
53
//this is a little optimisation that doesnt calculate the a component for
54
//the returned quaternion. Note that the result is specific to quaternion rotation
55
void quat_pointmult(Point3f *result, Quaternion *q1, Quaternion *q2);
57
//Uses quaternion mathematics to perform a rotation around your favourite axis
58
//IMPORTANT: rotVec must be normalised before passing to this function
59
//failure to do so will have wierd results
60
//Note result is stored in point passsed as argument
61
void quat_rot(Point3f *point, Point3f *rotVec, float angle);
63
//Retrieve the two quaternions for repeated rotations. pass to the quat_rot_apply_quats
64
void quat_get_rot_quats(Point3f *rotVec, float angle,
65
Quaternion *rotQuat, Quaternion *conjQuat);
67
//Use previously generated quats from quat_get_rot_quats to rotate a point
68
void quat_rot_apply_quats(Point3f *point, Quaternion *rotQuat, Quaternion *conjQuat);
70
//this performs an optimised rotation of a point around 3 angles
71
//pitch, then yaw and then roll. Pitch is defined to be rotation around x
72
//yaw around z and roll around y. x is right, y is forwards, z is up
73
//The results are derived by special case quaternion rotation around basis vectors
74
void quat_rot_pitchyawroll(Point3f *point, float pitchAngle,float yawAngle, float rollAngle);
76
//As for the above but in reverse order. This allows you to undo the above transform by simply
77
//passing through the negative roll yaw and pitch angles
78
void quat_rot_rollyawpitch(Point3f *point, float rollAngle,float yawAngle,float pitchAngle);
83
//TODO: determine if we need an array version of the quat_rot_pyr/ryp funcs