44 #include <visp/vpConfig.h>
47 #ifndef DOXYGEN_SHOULD_SKIP_THIS
49 #define ADD_COORD2(r,a,b) { (r).x = (a).x + (b).x;\
50 (r).y = (a).y + (b).y; }
52 #define ADD_COORD3(r,a,b) { (r).x = (a).x + (b).x;\
53 (r).y = (a).y + (b).y;\
54 (r).z = (a).z + (b).z; }
56 #define INC_COORD2(r,a) { (r).x += (a).x; (r).y += (a).y; }
58 #define INC_COORD3(r,a) { (r).x += (a).x; (r).y += (a).y;\
61 #define CROSS_PRODUCT(r,a,b) { (r).x = (a).y * (b).z - (a).z * (b).y;\
62 (r).y = (a).z * (b).x - (a).x * (b).z;\
63 (r).z = (a).x * (b).y - (a).y * (b).x; }
65 #define DIF_COORD2(r,a,b) { (r).x = (a).x - (b).x;\
66 (r).y = (a).y - (b).y; }
68 #define DIF_COORD3(r,a,b) { (r).x = (a).x - (b).x;\
69 (r).y = (a).y - (b).y;\
70 (r).z = (a).z - (b).z; }
72 #define DOT_PRODUCT(a,b) ( ((a).x * (b).x) +\
76 #define LENGTH3(a) (sqrt((double) DOT_PRODUCT((a),(a))))
78 #define MID_COORD3(r,a,b) { (r).x = ((a).x + (b).x) / 2.0;\
79 (r).y = ((a).y + (b).y) / 2.0;\
80 (r).z = ((a).z + (b).z) / 2.0; }
82 #define MUL_COORD3(r,a,b,c) { (r).x *= (a); (r).y *= (b); (r).z *= (c); }
84 #define PAR_COORD3(r,t,a,b) { (r).x = ((b).x - (a).x) * (t) + (a).x;\
85 (r).y = ((b).y - (a).y) * (t) + (a).y;\
86 (r).z = ((b).z - (a).z) * (t) + (a).z; }
88 #define SET_COORD2(r,a,b) { (r).x = (a); (r).y = (b); }
90 #define SET_COORD3(r,a,b,c) { (r).x = (a); (r).y = (b); (r).z = (c); }
92 #define SUB_COORD2(r,a) { (r).x -= (a).x; (r).y -= (a).y; }
94 #define SUB_COORD3(r,a) { (r).x -= (a).x; (r).y -= (a).y;\
97 #define COORD3_COL(x,y,z,m,i) ( ((x) * (m)[0][i]) +\
102 #define COORD4_COL(x,y,z,w,m,i) ( ((x) * (m)[0][i]) +\
107 #define M_POLY1(x,a,b) ((a) * (x) + (b))
108 #define M_POLY2(x,a,b,c) (M_POLY1((x),(a),(b)) * (x) + (c))
109 #define M_POLY3(x,a,b,c,d) (M_POLY2((x),(a),(b),(c)) * (x) + (d))
146 typedef float Matrix[4][4];
148 #define IDENTITY_MATRIX { {1.0, 0.0, 0.0, 0.0},\
149 {0.0, 1.0, 0.0, 0.0},\
150 {0.0, 0.0, 1.0, 0.0},\
151 {0.0, 0.0, 0.0, 1.0} }
171 #define IDENTITY_ROTATE { 0.0, 0.0, 0.0 }
172 #define IDENTITY_SCALE { 1.0, 1.0, 1.0 }
173 #define IDENTITY_TRANSLATE { 0.0, 0.0, 0.0 }
175 #define IDENTITY_POSITION { IDENTITY_ROTATE,\
179 void fprintf_matrix (FILE *fp, Matrix m);
180 void ident_matrix (Matrix m);
181 void premult_matrix (Matrix a, Matrix b);
182 void premult3_matrix (Matrix a, Matrix b);
183 void prescale_matrix (Matrix m, Vector *vp);
184 void pretrans_matrix (Matrix m, Vector *vp);
185 void postleft_matrix (Matrix m,
char axis);
186 void postmult_matrix (Matrix a, Matrix b);
187 void postmult3_matrix (Matrix a, Matrix b);
188 void postscale_matrix (Matrix m, Vector *vp);
189 void posttrans_matrix (Matrix m, Vector *vp);
190 void transpose_matrix (Matrix m);
192 float cosin_to_angle (
float ca,
float sa);
193 float norm_vector (Vector *vp);
194 void point_matrix (Point4f *p4, Point3f *p3, Matrix m);
195 void plane_norme (Vector *np, Point3f *ap, Point3f *bp, Point3f *cp);
196 void point_3D_3D (Point3f *ip,
int size, Matrix m, Point3f *op);
197 void point_3D_4D (Point3f *p3,
int size, Matrix m, Point4f *p4);
198 void rotate_vector (Vector *vp,
float a, Vector *axis);
199 void upright_vector (Vector *vp, Vector *up);
201 void Matrix_to_Position (Matrix m, AritPosition *pp);
202 void Matrix_to_Rotate (Matrix m, Vector *vp);
203 void Position_to_Matrix (AritPosition *pp, Matrix m);
204 void Rotate_to_Matrix (Vector *vp, Matrix m);
205 void Rotaxis_to_Matrix (
float a, Vector *axis, Matrix m);
206 void Rotrans_to_Matrix (Vector *rp, Vector *tp, Matrix m);
207 void Scale_to_Matrix (Vector *vp, Matrix m);
208 void Translate_to_Matrix (Vector *vp, Matrix m);
210 void fscanf_Point3f (Point3f *pp);
211 void fscanf_Vector (Vector *vp);