rotate3D.h Source File (original) (raw)
00001 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 #ifndef _GAN_ROTATE3D_H 00030 #define _GAN_ROTATE3D_H 00031 00032 #include <stdarg.h> 00033 #include <gandalf/linalg/3vector.h> 00034 #include <gandalf/linalg/4vector.h> 00035 #include <gandalf/linalg/3x3matrix.h> 00036 #include <gandalf/linalg/3x4matrix.h> 00037 #include <gandalf/linalg/4x4matrix.h> 00038 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif 00042 00056 typedef enum 00057 { 00059 GAN_ROT3D_QUATERNION, 00060 00062 GAN_ROT3D_EXPONENTIAL, 00063 00065 GAN_ROT3D_ANGLE_AXIS, 00066 00068 GAN_ROT3D_MATRIX 00069 } Gan_Rot3D_Type; 00070 00074 typedef struct Gan_Quaternion 00075 { 00076 double q0; 00077 double q1; 00078 double q2; 00079 double q3; 00080 } Gan_Quaternion; 00081 00085 typedef struct Gan_Rot3D 00086 { 00088 Gan_Rot3D_Type type; 00089 00091 union 00092 { 00094 Gan_Quaternion q; 00095 00097 Gan_Vector3 r; 00098 00100 struct { Gan_Vector3 axis; double angle; } aa; 00101 00103 Gan_Matrix33 R; 00104 } data; 00105 } Gan_Rot3D; 00106 00110 typedef struct Gan_Rot3D_Cov 00111 { 00113 Gan_Rot3D_Type type; 00114 00116 union 00117 { 00119 Gan_SquMatrix44 q; 00120 00122 Gan_SquMatrix33 r; 00123 } data; 00124 } Gan_Rot3D_Cov; 00125 00126 00127 00128 void gan_quat_fill_q ( Gan_Quaternion *q, 00129 double q0, double q1, 00130 double q2, double q3 ); 00131 Gan_Quaternion gan_quat_fill_s ( double q0, double q1, 00132 double q2, double q3 ); 00133 Gan_Quaternion gan_quat_scale_s ( Gan_Quaternion *q, double s ); 00134 Gan_Quaternion gan_quat_divide_s ( Gan_Quaternion *q, double s ); 00135 Gan_Quaternion gan_quat_unit_s ( Gan_Quaternion *q ); 00136 00142 Gan_Quaternion *gan_quat_scale_q ( Gan_Quaternion *q1, double s, 00143 Gan_Quaternion *q2 ); 00144 00150 Gan_Quaternion *gan_quat_scale_i ( Gan_Quaternion *q1, double s ); 00151 00157 Gan_Quaternion *gan_quat_divide_q ( Gan_Quaternion *q1, double s, 00158 Gan_Quaternion *q2 ); 00159 00165 Gan_Quaternion *gan_quat_divide_i ( Gan_Quaternion *q1, double s ); 00166 00172 Gan_Quaternion *gan_quat_unit_q ( Gan_Quaternion *q1, Gan_Quaternion *q2 ); 00173 00179 Gan_Quaternion *gan_quat_unit_i ( Gan_Quaternion *q1 ); 00180 00186 double gan_quat_sqrlen_q ( Gan_Quaternion *q1 ); 00187 00193 double gan_quat_sqrlen_s ( Gan_Quaternion *q1 ); 00194 00200 Gan_Quaternion *gan_quat_add_q ( Gan_Quaternion *q1, Gan_Quaternion *q2, 00201 Gan_Quaternion *q3 ); 00202 00208 Gan_Quaternion *gan_quat_sub_q ( Gan_Quaternion *q1, Gan_Quaternion *q2, 00209 Gan_Quaternion *q3 ); 00210 00211 Gan_Bool gan_rot3D_build_quaternion ( Gan_Rot3D *rot, 00212 double q0, double q1, 00213 double q2, double q3 ); 00214 Gan_Bool gan_rot3D_build_exponential ( Gan_Rot3D *rot, 00215 double rx, double ry, double rz ); 00216 Gan_Bool gan_rot3D_build_angle_axis ( Gan_Rot3D *rot, 00217 double angle, 00218 double ax, double ay, double az ); 00219 Gan_Bool gan_rot3D_build_matrix ( Gan_Rot3D *rot, 00220 double Rxx, double Rxy, double Rxz, 00221 double Ryx, double Ryy, double Ryz, 00222 double Rzx, double Rzy, double Rzz ); 00223 Gan_Bool gan_rot3D_ident_q ( Gan_Rot3D *rot, Gan_Rot3D_Type type ); 00224 Gan_Rot3D gan_rot3D_ident_s ( Gan_Rot3D_Type type ); 00225 Gan_Bool gan_rot3D_apply_v3_q ( Gan_Rot3D *rot, 00226 Gan_Vector3 *X, Gan_Vector3 *X_new ); 00227 Gan_Vector3 gan_rot3D_apply_v3_s ( Gan_Rot3D *rot, Gan_Vector3 *X ); 00228 Gan_Bool gan_rot3D_mult_q ( Gan_Rot3D *rot1, Gan_Rot3D *rot2, 00229 Gan_Rot3D *rot3 ); 00230 Gan_Rot3D gan_rot3D_mult_s ( Gan_Rot3D *rot1, Gan_Rot3D *rot2 ); 00231 Gan_Bool gan_rot3D_multI_q ( Gan_Rot3D *rot1, Gan_Rot3D *rot2, 00232 Gan_Rot3D *rot3 ); 00233 Gan_Rot3D gan_rot3D_multI_s ( Gan_Rot3D *rot1, Gan_Rot3D *rot2 ); 00234 Gan_Bool gan_rot3D_scale_q ( Gan_Rot3D *rot_s, double scale, 00235 Gan_Rot3D *rot_d ); 00236 Gan_Rot3D gan_rot3D_scale_s ( Gan_Rot3D *rot_s, double scale ); 00237 Gan_Bool gan_rot3D_divide_q ( Gan_Rot3D *rot_s, double scale, 00238 Gan_Rot3D *rot_d ); 00239 Gan_Rot3D gan_rot3D_divide_s ( Gan_Rot3D *rot_s, double scale ); 00240 Gan_Bool gan_rot3D_add_q ( Gan_Rot3D *rot1, Gan_Rot3D *rot2, Gan_Rot3D *rot3); 00241 Gan_Rot3D gan_rot3D_add_s ( Gan_Rot3D *rot1, Gan_Rot3D *rot2 ); 00242 Gan_Bool gan_rot3D_sub_q ( Gan_Rot3D *rot1, Gan_Rot3D *rot2, Gan_Rot3D *rot3); 00243 Gan_Rot3D gan_rot3D_sub_s ( Gan_Rot3D *rot1, Gan_Rot3D *rot2 ); 00244 Gan_Bool gan_rot3D_convert_q ( Gan_Rot3D *rot_s, Gan_Rot3D_Type type, 00245 Gan_Rot3D *rot_d ); 00246 Gan_Rot3D gan_rot3D_convert_s ( Gan_Rot3D *rot_s, Gan_Rot3D_Type type ); 00247 Gan_Bool gan_rot3D_from_quaternion_q ( Gan_Rot3D *rot, 00248 Gan_Quaternion *q, Gan_Rot3D_Type type ); 00249 Gan_Bool gan_rot3D_from_exponential_q ( Gan_Rot3D *rot, 00250 Gan_Vector3 *r, Gan_Rot3D_Type type ); 00251 Gan_Rot3D gan_rot3D_from_quaternion_s ( Gan_Quaternion *q, 00252 Gan_Rot3D_Type type ); 00253 Gan_Rot3D gan_rot3D_from_exponential_s ( Gan_Vector3 *r, Gan_Rot3D_Type type ); 00254 Gan_Bool gan_rot3D_from_angle_axis_q ( Gan_Rot3D *rot, 00255 double angle, Gan_Vector3 *axis, 00256 Gan_Rot3D_Type type ); 00257 Gan_Rot3D gan_rot3D_from_angle_axis_s ( double angle, Gan_Vector3 *axis, 00258 Gan_Rot3D_Type type ); 00259 Gan_Bool gan_rot3D_from_matrix_q ( Gan_Rot3D *rot, 00260 Gan_Matrix33 *R, Gan_Rot3D_Type type ); 00261 Gan_Rot3D gan_rot3D_from_matrix_s ( Gan_Matrix33 *R, Gan_Rot3D_Type type ); 00262 Gan_Bool gan_rot3D_matrix_adjust ( Gan_Matrix33 *R ); 00263 00269 Gan_Bool gan_rot3D_scale_i ( Gan_Rot3D *rot, double s ); 00270 00276 Gan_Bool gan_rot3D_divide_i ( Gan_Rot3D *rot, double s ); 00277 00284 Gan_Bool gan_rot3D_increment ( Gan_Rot3D *rot1, Gan_Rot3D *rot2 ); 00285 00292 Gan_Bool gan_rot3D_add_i2 ( Gan_Rot3D *rot1, Gan_Rot3D *rot2 ); 00293 00300 Gan_Bool gan_rot3D_decrement ( Gan_Rot3D *rot1, Gan_Rot3D *rot2 ); 00301 00308 Gan_Bool gan_rot3D_sub_i2 ( Gan_Rot3D *rot1, Gan_Rot3D *rot2 ); 00309 00318 #ifdef __cplusplus 00319 } 00320 #endif 00321 00322 #endif