Klamp't  0.8.1
ODECommon.h
1 #ifndef ODE_INTERFACE_COMMON_H
2 #define ODE_INTERFACE_COMMON_H
3 
4 #include <KrisLibrary/math3d/primitives.h>
5 using namespace Math3D;
6 
7 inline void CopyVector(dVector4 x,const Vector3& v)
8 {
9  x[0] = v.x;
10  x[1] = v.y;
11  x[2] = v.z;
12  x[3] = 1;
13 }
14 
15 inline void CopyVector3(dReal* x,const Vector3& v)
16 {
17  x[0] = v.x;
18  x[1] = v.y;
19  x[2] = v.z;
20 }
21 
22 inline void CopyVector(Vector3& x,const dVector4 v)
23 {
24  x.set(v[0],v[1],v[2]);
25 }
26 
27 inline void CopyMatrix(dMatrix3 x,const Matrix3& v)
28 {
29  //column major 4x3?
30  for(int i=0;i<3;i++)
31  for(int j=0;j<3;j++)
32  x[i*4+j] = v(i,j);
33 }
34 
35 inline void CopyMatrix(Matrix3& x,const dMatrix3 v)
36 {
37  for(int i=0;i<3;i++)
38  for(int j=0;j<3;j++)
39  x(i,j) = v[i*4+j];
40 }
41 
42 //column matrix format
43 inline void CopyMatrixCM(dReal* x,const Matrix4& v)
44 {
45  //column major 4x4?
46  for(int i=0;i<4;i++)
47  for(int j=0;j<4;j++)
48  x[i+j*4] = v(i,j);
49 }
50 
51 //column matrix format
52 inline void CopyMatrixCM(Matrix4& x,const dReal* v)
53 {
54  for(int i=0;i<4;i++)
55  for(int j=0;j<4;j++)
56  x(i,j) = v[i+j*4];
57 }
58 
59 
60 #endif