Image Component Library (ICL)
PhysicsDefs.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2014 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLPhysics/src/ICLPhysics/PhysicsDefs.h **
10 ** Module : ICLPhysics **
11 ** Author : Christof Elbrechter, Matthias Esau **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 #pragma once
31 
32 #include <ICLGeom/GeomDefs.h>
33 #include <LinearMath/btTransform.h>
34 
35 namespace icl{
36  namespace physics{
37  ICLPhysics_API extern float ICL_UNIT_TO_METER;
39  #define ICL_UNIT_TO_BULLET_UNIT (ICL_UNIT_TO_METER / METER_TO_BULLET_UNIT)
40 
42  inline float icl2bullet(float x) { return ICL_UNIT_TO_BULLET_UNIT * x; }
43 
45  inline float bullet2icl(float x) { return x / ICL_UNIT_TO_BULLET_UNIT; }
46 
48  inline geom::Mat bullet2icl(const btTransform &T)
49  {
50  const btMatrix3x3 &R = T.getBasis();
51  const btVector3 &t = T.getOrigin();
52  return geom::Mat(R[0][0],R[0][1],R[0][2],bullet2icl(t[0]),
53  R[1][0],R[1][1],R[1][2],bullet2icl(t[1]),
54  R[2][0],R[2][1],R[2][2],bullet2icl(t[2]),
55  0,0,0,1);
56  }
57 
58 
59  inline btTransform icl2bullet_unscaled_mat(const geom::Mat &M)
60  {
61  btTransform T;
62  T.setBasis(btMatrix3x3(M[0],M[1],M[2],
63  M[4],M[5],M[6],
64  M[8],M[9],M[10]));
65  T.setOrigin(btVector3(M[3],M[7],M[11]));
66  return T;
67  }
68 
70  inline btTransform icl2bullet_scaled_mat(const geom::Mat &M)
71  {
72  btTransform T;
73  T.setBasis(btMatrix3x3(M[0],M[1],M[2],
74  M[4],M[5],M[6],
75  M[8],M[9],M[10]));
76  T.setOrigin(btVector3(icl2bullet(M[3]),
77  icl2bullet(M[7]),
78  icl2bullet(M[11])));
79  return T;
80  }
81 
83  inline btVector3 icl2bullet_unscaled(const geom::Vec &v) { return btVector3(v[0],v[1],v[2]); }
84 
86  inline geom::Vec bullet2icl_unscaled(const btVector3 &v) { return geom::Vec(v[0],v[1],v[2],1.0); }
87 
89  inline btVector3 icl2bullet_scaled(const geom::Vec &v) { return btVector3(icl2bullet(v[0]),icl2bullet(v[1]),icl2bullet(v[2])); }
90 
92  inline geom::Vec bullet2icl_scaled(const btVector3 &v) { return geom::Vec(bullet2icl(v[0]),bullet2icl(v[1]),bullet2icl(v[2]),1.0); }
93  }
94 }
float icl2bullet(float x)
Converts from icl to bullet units.
Definition: PhysicsDefs.h:42
undocument this line if you encounter any issues!
Definition: Any.h:37
btTransform icl2bullet_scaled_mat(const geom::Mat &M)
Creates a bullet transform from an icl Mat and scales accordingly.
Definition: PhysicsDefs.h:70
Mat4D32f Mat
Short typedef for 4D float matrices.
Definition: GeomDefs.h:90
geom::Vec bullet2icl_unscaled(const btVector3 &v)
Creates an icl vector from a bullet vector WITHOUT scaling.
Definition: PhysicsDefs.h:86
#define ICL_UNIT_TO_BULLET_UNIT
Definition: PhysicsDefs.h:39
btTransform icl2bullet_unscaled_mat(const geom::Mat &M)
Definition: PhysicsDefs.h:59
#define ICLPhysics_API
Definition: CompatMacros.h:181
Vec4D32f Vec
Short typedef for 4D float vectors.
Definition: GeomDefs.h:87
ICLPhysics_API float METER_TO_BULLET_UNIT
float bullet2icl(float x)
Converts from bullet to icl units.
Definition: PhysicsDefs.h:45
geom::Vec bullet2icl_scaled(const btVector3 &v)
Creates an icl vector from a bullet vector WITH scaling.
Definition: PhysicsDefs.h:92
btVector3 icl2bullet_unscaled(const geom::Vec &v)
Creates a bullet vector from an icl vector WITHOUT scaling.
Definition: PhysicsDefs.h:83
ICLPhysics_API float ICL_UNIT_TO_METER
btVector3 icl2bullet_scaled(const geom::Vec &v)
Creates a bullet vector from an icl vector WITH scaling.
Definition: PhysicsDefs.h:89