convert line ends
[canaan.git] / prj / tech / libsrc / matrix / matvecd.c
blob6f71fcfe223b9bcfb7a4b006587879c571b4b055
1 /*
2 * $Source: x:/prj/tech/libsrc/matrix/RCS/matvec.c $
3 * $Revision: 1.3 $
4 * $Author: kate $
5 * $Date: 1997/11/20 13:32:02 $
6 */
8 #include <matrixd.h>
10 #define MXD_VERSION
12 // element wise mul of m by v to make different coordinate
13 // system
14 // dest = M .* v
15 void mxd_mat_elmul_vec(mxds_matrix *dest,const mxds_matrix *m,const mxds_vector *v)
17 dest->el[0] = m->el[0] * v->x;
18 dest->el[1] = m->el[1] * v->x;
19 dest->el[2] = m->el[2] * v->x;
21 dest->el[3] = m->el[3] * v->y;
22 dest->el[4] = m->el[4] * v->y;
23 dest->el[5] = m->el[5] * v->y;
25 dest->el[6] = m->el[6] * v->z;
26 dest->el[7] = m->el[7] * v->z;
27 dest->el[8] = m->el[8] * v->z;
30 // M .*= v
31 void mxd_mat_elmuleq_vec(mxds_matrix *m,const mxds_vector *v)
33 m->el[0] *= v->x;
34 m->el[1] *= v->x;
35 m->el[2] *= v->x;
37 m->el[3] *= v->y;
38 m->el[4] *= v->y;
39 m->el[5] *= v->y;
41 m->el[6] *= v->z;
42 m->el[7] *= v->z;
43 m->el[8] *= v->z;
46 // dest = v^t .* M
47 void mxd_mat_eltmul_vec(mxds_matrix *dest,const mxds_matrix *m,const mxds_vector *v)
49 dest->el[0] = m->el[0] * v->x;
50 dest->el[3] = m->el[3] * v->x;
51 dest->el[6] = m->el[6] * v->x;
53 dest->el[1] = m->el[1] * v->y;
54 dest->el[4] = m->el[4] * v->y;
55 dest->el[7] = m->el[7] * v->y;
57 dest->el[2] = m->el[2] * v->z;
58 dest->el[5] = m->el[5] * v->z;
59 dest->el[8] = m->el[8] * v->z;
62 // M .*= v^t
63 void mxd_mat_eltmuleq_vec(mxds_matrix *m,const mxds_vector *v)
65 m->el[0] *= v->x;
66 m->el[3] *= v->x;
67 m->el[6] *= v->x;
69 m->el[1] *= v->y;
70 m->el[4] *= v->y;
71 m->el[7] *= v->y;
73 m->el[2] *= v->z;
74 m->el[5] *= v->z;
75 m->el[8] *= v->z;
78 // dest = M x v
79 void mxd_mat_mul_vec(mxds_vector *dest,const mxds_matrix *m,const mxds_vector *v)
81 dest->x = m->el[0]*v->x + m->el[3]*v->y + m->el[6]*v->z;
82 dest->y = m->el[1]*v->x + m->el[4]*v->y + m->el[7]*v->z;
83 dest->z = m->el[2]*v->x + m->el[5]*v->y + m->el[8]*v->z;
86 // v x= M, this is idiotic
87 void mxd_mat_muleq_vec(const mxds_matrix *m,mxds_vector *v)
89 mxds_vector t;
90 mxd_mat_mul_vec(&t,m,v);
91 mxd_copy_vec(v,&t);
94 // dest = M^t x v, this is for multing by inverse if unit
95 void mxd_mat_tmul_vec(mxds_vector *dest,const mxds_matrix *m, const mxds_vector *v)
97 dest->x = m->el[0]*v->x + m->el[1]*v->y + m->el[2]*v->z;
98 dest->y = m->el[3]*v->x + m->el[4]*v->y + m->el[5]*v->z;
99 dest->z = m->el[6]*v->x + m->el[7]*v->y + m->el[8]*v->z;
102 // v x= M^t, retarded
103 void mxd_mat_tmuleq_vec(const mxds_matrix *m,mxds_vector *v)
105 mxds_vector t;
106 mxd_mat_tmul_vec(&t,m,v);
107 mxd_copy_vec(v,&t);