Doxygen Source Code Documentation
SUMA_trackball.h File Reference
Go to the source code of this file.
Functions | |
void | trackball (float q[4], float p1x, float p1y, float p2x, float p2y) |
void | trackball_Phi (float q[4], float p1x, float p1y, float p2x, float p2y, float phi) |
void | add_quats (float *q1, float *q2, float *dest) |
void | SUMA_build_rotmatrix (float m[4][4], float q[4]) |
void | axis_to_quat (float a[3], float phi, float q[4]) |
Function Documentation
|
Referenced by SUMA_input(), and SUMA_momentum(). |
|
Definition at line 174 of file SUMA_trackball.c. References a, q, vcopy(), vnormal(), and vscale(). Referenced by SUMA_input(), trackball(), and trackball_Phi().
|
|
Referenced by SUMA_cmap_wid_display(), SUMA_display(), SUMA_GetSelectionLine(), and SUMA_World2ScreenCoords(). |
|
functions defined in SUMA_trackball.c Definition at line 99 of file SUMA_trackball.c. References a, axis_to_quat(), q, tb_project_to_sphere(), TRACKBALLSIZE, vcross(), vlength(), vset(), vsub(), and vzero(). Referenced by SUMA_input().
00100 { 00101 float a[3]; /* Axis of rotation. */ 00102 float phi; /* How much to rotate about axis. */ 00103 float p1[3], p2[3], d[3]; 00104 float t; 00105 00106 if (p1x == p2x && p1y == p2y) { 00107 /* Zero rotation */ 00108 vzero(q); 00109 q[3] = 1.0; 00110 return; 00111 } 00112 /* First, figure out z-coordinates for projection of P1 and 00113 P2 to deformed sphere. */ 00114 vset(p1, p1x, p1y, tb_project_to_sphere(TRACKBALLSIZE, p1x, p1y)); 00115 vset(p2, p2x, p2y, tb_project_to_sphere(TRACKBALLSIZE, p2x, p2y)); 00116 00117 /* Now, we want the cross product of P1 and P2. */ 00118 vcross(p2, p1, a); 00119 /* Figure out how much to rotate around that axis. */ 00120 vsub(p1, p2, d); 00121 t = vlength(d) / (2.0 * TRACKBALLSIZE); 00122 00123 /* Avoid problems with out-of-control values. */ 00124 if (t > 1.0) 00125 t = 1.0; 00126 if (t < -1.0) 00127 t = -1.0; 00128 phi = 2.0 * asin(t); 00129 axis_to_quat(a, phi, q); 00130 } |
|
A modification/hack of trackball function to control the rotation angle directement Definition at line 136 of file SUMA_trackball.c. References a, axis_to_quat(), q, tb_project_to_sphere(), TRACKBALLSIZE, vcross(), vlength(), vset(), vsub(), and vzero(). Referenced by SUMA_input().
00137 { 00138 float a[3]; /* Axis of rotation. */ 00139 float p1[3], p2[3], d[3]; 00140 float t; 00141 00142 if (p1x == p2x && p1y == p2y) { 00143 /* Zero rotation */ 00144 vzero(q); 00145 q[3] = 1.0; 00146 return; 00147 } 00148 /* First, figure out z-coordinates for projection of P1 and 00149 P2 to deformed sphere. */ 00150 vset(p1, p1x, p1y, tb_project_to_sphere(TRACKBALLSIZE, p1x, p1y)); 00151 vset(p2, p2x, p2y, tb_project_to_sphere(TRACKBALLSIZE, p2x, p2y)); 00152 00153 /* Now, we want the cross product of P1 and P2. */ 00154 vcross(p2, p1, a); 00155 /* Figure out how much to rotate around that axis. */ 00156 vsub(p1, p2, d); 00157 t = vlength(d) / (2.0 * TRACKBALLSIZE); 00158 00159 /* Avoid problems with out-of-control values. */ 00160 if (t > 1.0) { 00161 t = 1.0; 00162 phi = 2.0 * asin(t); 00163 } 00164 if (t < -1.0) { 00165 t = -1.0; 00166 phi = 2.0 * asin(t); 00167 } 00168 00169 axis_to_quat(a, phi, q); 00170 } |