-
Notifications
You must be signed in to change notification settings - Fork 0
/
defs.h
20 lines (15 loc) · 1.17 KB
/
defs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#define VDOT(v1,v2) ( (v1)[0]*(v2)[0]+(v1)[1]*(v2)[1]+(v1)[2]*(v2)[2] )
#define VSET(v,a,b,c) {(v)[0]=a; (v)[1]=b; (v)[2]=c;}
#define VLENSQ(v) ( (v)[0]*(v)[0]+(v)[1]*(v)[1]+(v)[2]*(v)[2] )
#define VLEN(v) sqrt((v)[0]*(v)[0]+(v)[1]*(v)[1]+(v)[2]*(v)[2])
#define VSUB(v,v1,v2) {(v)[0]=(v1)[0]-(v2)[0]; (v)[1]=(v1)[1]-(v2)[1]; (v)[2]=(v1)[2]-(v2)[2];}
#define VADD(v,v1,v2) {(v)[0]=(v1)[0]+(v2)[0]; (v)[1]=(v1)[1]+(v2)[1]; (v)[2]=(v1)[2]+(v2)[2];}
#define VSMUL(v,v1,s1) {(v)[0]=(v1)[0]*s1; (v)[1]=(v1)[1]*s1; (v)[2]=(v1)[2]*s1;}
#define MDET(m) ( (m)[0]*(m)[4]*(m)[8] + (m)[1]*(m)[5]*(m)[6] + (m)[2]*(m)[3]*(m)[7] \
-(m)[0]*(m)[5]*(m)[7] - (m)[1]*(m)[3]*(m)[8] - (m)[2]*(m)[4]*(m)[6] )
#define MSET(m,ax,ay,az,bx,by,bz,cx,cy,cz) {(m)[0]=ax; (m)[1]=ay; (m)[2]=az; \
(m)[3]=bx; (m)[4]=by; (m)[5]=bz; \
(m)[6]=cx; (m)[7]=cy; (m)[8]=cz; }
#define DET(m) ((m)[0][0]*(m)[1][1]*(m)[2][2]+(m)[0][2]*(m)[1][0]*(m)[2][1]+(m)[0][1]*(m)[1][2]*(m)[2][0]-\
(m)[0][2]*(m)[1][1]*(m)[2][0]-(m)[0][0]*(m)[1][2]*(m)[2][1]-(m)[0][1]*(m)[1][0]*(m)[2][2])
void matrix_inverse(float a[3][3],float ainv[3][3]);