]> git.mxchange.org Git - flightgear.git/blob - src/GUI/trackball.h
GUI windows are now draggable. This missing feature has annoyed me
[flightgear.git] / src / GUI / trackball.h
1 /*
2  * trackball.h
3  * A virtual trackball implementation
4  * Written by Gavin Bell for Silicon Graphics, November 1988.
5  */
6
7 #ifndef _TRACKBALL_H
8 #define _TRACKBALL_H
9
10 #ifdef __cplusplus                                                          
11 extern "C" {                            
12 #endif                                   
13
14 /*
15  * Pass the x and y coordinates of the last and current positions of
16  * the mouse, scaled so they are from (-1.0 ... 1.0).
17  *
18  * The resulting rotation is returned as a quaternion rotation in the
19  * first paramater.
20  */
21 void
22    trackball(float q[4], float p1x, float p1y, float p2x, float p2y);
23
24 /*
25  * Given two quaternions, add them together to get a third quaternion.
26  * Adding quaternions to get a compound rotation is analagous to adding
27  * translations to get a compound translation.  When incrementally
28  * adding rotations, the first argument here should be the new
29
30  * rotation, the second and third the total rotation (which will be
31  * over-written with the resulting new total rotation).
32  */
33 void add_quats(float *q1, float *q2, float *dest);
34
35 /*
36  * A useful function, builds a rotation matrix in Matrix based on
37  * given quaternion.
38  */
39 void build_rotmatrix(float m[4][4], float q[4]);
40 void build_transposed_rotmatrix(float m[4][4], float q[4]);
41
42 /*
43  * This function computes a quaternion based on an axis (defined by
44  * the given vector) and an angle about which to rotate.  The angle is
45  * expressed in radians.  The result is put into the third argument.
46  */
47 void axis_to_quat(float a[3], float phi, float q[4]);
48
49
50 #ifdef __cplusplus
51 }
52 #endif
53
54
55 #endif /* _TRACKBALL_H */