40 #include <visp3/core/vpConfig.h>
43 #ifndef DOXYGEN_SHOULD_SKIP_THIS
45 #define ADD_COORD2(r,a,b) { (r).x = (a).x + (b).x;\
46 (r).y = (a).y + (b).y; }
48 #define ADD_COORD3(r,a,b) { (r).x = (a).x + (b).x;\
49 (r).y = (a).y + (b).y;\
50 (r).z = (a).z + (b).z; }
52 #define INC_COORD2(r,a) { (r).x += (a).x; (r).y += (a).y; }
54 #define INC_COORD3(r,a) { (r).x += (a).x; (r).y += (a).y;\
57 #define CROSS_PRODUCT(r,a,b) { (r).x = (a).y * (b).z - (a).z * (b).y;\
58 (r).y = (a).z * (b).x - (a).x * (b).z;\
59 (r).z = (a).x * (b).y - (a).y * (b).x; }
61 #define DIF_COORD2(r,a,b) { (r).x = (a).x - (b).x;\
62 (r).y = (a).y - (b).y; }
64 #define DIF_COORD3(r,a,b) { (r).x = (a).x - (b).x;\
65 (r).y = (a).y - (b).y;\
66 (r).z = (a).z - (b).z; }
68 #define DOT_PRODUCT(a,b) ( ((a).x * (b).x) +\
72 #define LENGTH3(a) (sqrt((double) DOT_PRODUCT((a),(a))))
74 #define MID_COORD3(r,a,b) { (r).x = ((a).x + (b).x) / 2.0;\
75 (r).y = ((a).y + (b).y) / 2.0;\
76 (r).z = ((a).z + (b).z) / 2.0; }
78 #define MUL_COORD3(r,a,b,c) { (r).x *= (a); (r).y *= (b); (r).z *= (c); }
80 #define PAR_COORD3(r,t,a,b) { (r).x = ((b).x - (a).x) * (t) + (a).x;\
81 (r).y = ((b).y - (a).y) * (t) + (a).y;\
82 (r).z = ((b).z - (a).z) * (t) + (a).z; }
84 #define SET_COORD2(r,a,b) { (r).x = (a); (r).y = (b); }
86 #define SET_COORD3(r,a,b,c) { (r).x = (a); (r).y = (b); (r).z = (c); }
88 #define SUB_COORD2(r,a) { (r).x -= (a).x; (r).y -= (a).y; }
90 #define SUB_COORD3(r,a) { (r).x -= (a).x; (r).y -= (a).y;\
93 #define COORD3_COL(x,y,z,m,i) ( ((x) * (m)[0][i]) +\
98 #define COORD4_COL(x,y,z,w,m,i) ( ((x) * (m)[0][i]) +\
103 #define M_POLY1(x,a,b) ((a) * (x) + (b))
104 #define M_POLY2(x,a,b,c) (M_POLY1((x),(a),(b)) * (x) + (c))
105 #define M_POLY3(x,a,b,c,d) (M_POLY2((x),(a),(b),(c)) * (x) + (d))
142 typedef float Matrix[4][4];
144 #define IDENTITY_MATRIX { {1.0, 0.0, 0.0, 0.0},\
145 {0.0, 1.0, 0.0, 0.0},\
146 {0.0, 0.0, 1.0, 0.0},\
147 {0.0, 0.0, 0.0, 1.0} }
167 #define IDENTITY_ROTATE { 0.0, 0.0, 0.0 }
168 #define IDENTITY_SCALE { 1.0, 1.0, 1.0 }
169 #define IDENTITY_TRANSLATE { 0.0, 0.0, 0.0 }
171 #define IDENTITY_POSITION { IDENTITY_ROTATE,\
175 void fprintf_matrix (FILE *fp, Matrix m);
176 void ident_matrix (Matrix m);
177 void premult_matrix (Matrix a, Matrix b);
178 void premult3_matrix (Matrix a, Matrix b);
179 void prescale_matrix (Matrix m, Vector *vp);
180 void pretrans_matrix (Matrix m, Vector *vp);
181 void postleft_matrix (Matrix m,
char axis);
182 void postmult_matrix (Matrix a, Matrix b);
183 void postmult3_matrix (Matrix a, Matrix b);
184 void postscale_matrix (Matrix m, Vector *vp);
185 void posttrans_matrix (Matrix m, Vector *vp);
186 void transpose_matrix (Matrix m);
188 float cosin_to_angle (
float ca,
float sa);
189 float norm_vector (Vector *vp);
190 void point_matrix (Point4f *p4, Point3f *p3, Matrix m);
191 void plane_norme (Vector *np, Point3f *ap, Point3f *bp, Point3f *cp);
192 void point_3D_3D (Point3f *ip,
int size, Matrix m, Point3f *op);
193 void point_3D_4D (Point3f *p3,
int size, Matrix m, Point4f *p4);
194 void rotate_vector (Vector *vp,
float a, Vector *axis);
195 void upright_vector (Vector *vp, Vector *up);
197 void Matrix_to_Position (Matrix m, AritPosition *pp);
198 void Matrix_to_Rotate (Matrix m, Vector *vp);
199 void Position_to_Matrix (AritPosition *pp, Matrix m);
200 void Rotate_to_Matrix (Vector *vp, Matrix m);
201 void Rotaxis_to_Matrix (
float a, Vector *axis, Matrix m);
202 void Rotrans_to_Matrix (Vector *rp, Vector *tp, Matrix m);
203 void Scale_to_Matrix (Vector *vp, Matrix m);
204 void Translate_to_Matrix (Vector *vp, Matrix m);
206 void fscanf_Point3f (Point3f *pp);
207 void fscanf_Vector (Vector *vp);