KrisLibrary  1.0.0
Frame.h
1 #ifndef ROBOTICS_FRAME_H
2 #define ROBOTICS_FRAME_H
3 
6 using namespace Math3D;
7 
9 typedef RigidTransform Frame3D;
10 
11 //returns cross product [w]x
12 inline Vector2 cross(Real w,const Vector2& x)
13 {
14  return Vector2(x.y*w,-x.x*w);
15 }
16 
17 //returns cross product matrix [w]
18 inline Matrix2 crossProductMatrix2(Real w)
19 {
20  return Matrix2(Vector2(0,w),Vector2(-w,0));
21 }
22 
23 
24 //given the w (the 3,3 component of the homogeneous matrix) of frame b, this does the appropriate frame transform
25 inline Frame2D FrameMulWB(const Frame2D& a, const Frame2D& b, Real wb)
26 {
27  Frame2D x;
28  a.R.mul(b.t,x.t);
29  x.t.madd(a.t,wb);
30  x.R.mul(a.R,b.R);
31  return x;
32 }
33 
34 inline Frame2D FrameMulWB1(const Frame2D& a, const Frame2D& b)
35 {
36  Frame2D x;
37  a.R.mul(b.t,x.t);
38  x.t += a.t;
39  x.R.mul(a.R,b.R);
40  return x;
41 }
42 
43 inline Frame2D FrameMulWB0(const Frame2D& a, const Frame2D& b)
44 {
45  Frame2D x;
46  a.R.mul(b.t,x.t);
47  x.R.mul(a.R,b.R);
48  return x;
49 }
50 
51 //wb is the w coordinate of b
52 inline Vector2 FrameMulWB(const Frame2D& a, const Vector2& b, Real wb)
53 {
54  Vector2 x;
55  a.R.mul(b,x);
56  x.madd(b,wb);
57  return x;
58 }
59 
60 inline Vector2 FrameMulWB1(const Frame2D& a, const Vector2& b)
61 {
62  Vector2 x;
63  a.R.mul(b,x);
64  x += a.t;
65  return x;
66 }
67 
68 inline Vector2 FrameMulWB0(const Frame2D& a, const Vector2& b)
69 {
70  Vector2 x;
71  a.R.mul(b,x);
72  return x;
73 }
74 
75 
76 
77 //3D versions
78 
79 //given the w (the 4,4 component of the homogeneous matrix) of frame b, this does the appropriate frame transform
80 inline Frame3D FrameMulWB(const Frame3D& a, const Frame3D& b, Real wb)
81 {
82  Frame3D x;
83  a.R.mul(b.t,x.t);
84  x.t.madd(a.t,wb);
85  x.R.mul(a.R,b.R);
86  return x;
87 }
88 
89 inline Frame3D FrameMulWB1(const Frame3D& a, const Frame3D& b)
90 {
91  Frame3D x;
92  a.R.mul(b.t,x.t);
93  x.t += a.t;
94  x.R.mul(a.R,b.R);
95  return x;
96 }
97 
98 inline Frame3D FrameMulWB0(const Frame3D& a, const Frame3D& b)
99 {
100  Frame3D x;
101  a.R.mul(b.t,x.t);
102  x.R.mul(a.R,b.R);
103  return x;
104 }
105 
106 //wb is the w coordinate of b
107 inline Vector3 FrameMulWB(const Frame3D& a, const Vector3& b, Real wb)
108 {
109  Vector3 x;
110  a.R.mul(b,x);
111  x.madd(b,wb);
112  return x;
113 }
114 
115 inline Vector3 FrameMulWB1(const Frame3D& a, const Vector3& b)
116 {
117  Vector3 x;
118  a.R.mul(b,x);
119  x += a.t;
120  return x;
121 }
122 
123 inline Vector3 FrameMulWB0(const Frame3D& a, const Vector3& b)
124 {
125  Vector3 x;
126  a.R.mul(b,x);
127  return x;
128 }
129 
130 #endif
A 2x2 matrix class.
Definition: math3d/primitives.h:333
A 3D vector class.
Definition: math3d/primitives.h:136
3D rotation representations.
Class declarations for useful 3D math types.
A rigid-body transformation.
Definition: math3d/primitives.h:820
Contains all the definitions in the Math3D package.
Definition: AnyGeometry.h:13
A 2D vector class.
Definition: math3d/primitives.h:41
Same as above, but in 2D.
Definition: math3d/primitives.h:902