versor  3.0
C++11 library for Geometric algebra
vsr_cga3D_frame.h
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: vsr_cga3D_frame.h
5  *
6  * Description: position, orientation, velocities, accelerations
7  *
8  * Version: 1.0
9  * Created: 03/05/2014 20:11:53
10  * Revision: none
11  * Compiler: gcc
12  *
13  * Author: Pablo Colapinto (), gmail -> wolftype
14  * Organization:
15  *
16  * =====================================================================================
17  */
18 
19 
24 #ifndef vsr_cga3D_frame_INC
25 #define vsr_cga3D_frame_INC
26 
27 #include "space/vsr_cga3D_op.h"
28 
29 namespace vsr { namespace cga {
30 
38 // using namespace types;
47  class Frame{
48 
49 
50  protected:
51 
54 
55  VSR_PRECISION aBiv;
57  VSR_PRECISION aVec;
59  VSR_PRECISION mScale;
60 
61  public:
62 
63  // these typedefs help Frame play nice with Field class . . .
64  //template< class B > using BType = CGAMV<5, B >;
65  using space = typename conformal<5>::types;
66 
68  Frame();
70  Frame(VSR_PRECISION _x, VSR_PRECISION _y, VSR_PRECISION _z);
72  Frame(const Vec& v, const Rotor& r = Rot(1,0,0,0), VSR_PRECISION s = 1);
74  Frame(const Point& p, const Rotor& r = Rot(1,0,0,0), VSR_PRECISION s = 1 );
76  Frame(const DualLine& d );
78  Frame(const Motor& m );
79 
81  Frame& set( Pnt p, Rot r = Rot(1,0,0,0) ) { mPos = p; mRot = r; return *this; }
83  Frame& scale( VSR_PRECISION s ) { mScale = s; return *this; }
85  Frame& reset() { mPos = Round::point(0,0,0); mRot = Rot(1,0,0,0); return *this; }
86 
88  VSR_PRECISION scale() const { return mScale; }
89  VSR_PRECISION& scale() { return mScale; }
90 
91  /*-----------------------------------------------------------------------------
92  * ORIENTATION METHODS (ROTOR, QUATERNION, ETC)
93  *-----------------------------------------------------------------------------*/
95  //gfx::Mat4f image(){ return xf::mat(mRot); }
97  Rotor rot() const { return mRot; }
99  Rotor rotor() const { return mRot; }
100 
102  Rot& rot() { return mRot; }
103  // Get Rotor by reference
104  Rot& rotor() { return mRot; }
106  Frame& rot( const Rot& r) { mRot = r; return *this; }
108  Frame& rot( const Biv& B) { mRot = Gen::rot(B); return *this; }
110  Rot quat() const { return Rot( mRot[0], -(mRot[3]), (mRot[2]), -(mRot[1]) ); }
113  Frame& orient( const Vec& v, bool pos=true);
116  Frame& orient( const Vec& v, float amt, bool pos=true);
119  Frame& orientX( const Vec& v, float amt, bool pos=true);
122  Rotor relOrientRot( const Vec& v, bool pos=true);
124  Biv relOrientBiv( const Vec& v, bool pos=true);
126  Frame& relOrient( const Vec& v, float t, bool pos=true );
128  Motor relMotor( const Frame& target );
130  Frame& relTwist( const Frame& target, float t);
132  Frame& relTwistAway( const Frame& target, float t);
133 
134  /*-----------------------------------------------------------------------------
135  * POSITION METHODS
136  *-----------------------------------------------------------------------------*/
138  Point pos() const { return mPos; }
140  Point& pos() { return mPos; }
142  Vec vec() const { return mPos; }
144  Frame& pos( const Vec& v) { mPos = v.null(); return *this; }
146  Frame& pos( const Pnt& p ) { mPos = p; return *this; }
148  Frame& pos( VSR_PRECISION _x, VSR_PRECISION _y, VSR_PRECISION _z) { mPos = Round::point(_x,_y,_z); return *this; }
149  //Frame& set( VSR_PRECISION _x, VSR_PRECISION _y, VSR_PRECISION _z) { mPos = Round::null(_x,_y,_z); return *this; }
150 
151 
152  Vec x() const;
153  Vec y() const;
154  Vec z() const;
155 
156  //Positve and negative axis
157  Point posX() const { return (mPos + x()).null(); }
158  Point negX() const { return (mPos - x()).null(); }
159  Point posY() const { return (mPos + y()).null(); }
160  Point negY() const { return (mPos - y()).null(); }
161  Point posZ() const { return (mPos + z()).null(); }
162  Point negZ() const { return (mPos - z()).null(); }
163 
164  Biv xy() const;
165  Biv xz() const;
166  Biv yz() const;
167 
168  Lin lx() const;
169  Lin ly() const;
170  Lin lz() const;
171 
172  Dll dlx() const;
173  Dll dly() const;
174  Dll dlz() const;
175 
176  /* Homogenous Planes in Conformal Space */
177  Dlp dxz() const;
178  Dlp dxy() const;
179  Dlp dyz() const;
180 
181 
182  /* Real Pair */
183  Par px() const;
184  Par py() const;
185  Par pz() const;
186 
187  /* Imaginary Pair */
188  Par ipx() const;
189  Par ipy() const;
190  Par ipz() const;
191 
192  /* Global Tangent as Null Point Pair*/
193  Par tx() const;
194  Par ty() const;
195  Par tz() const;
196 
197  /* Global Weighted Tangent as Null Point Pair*/
198  Par tx( VSR_PRECISION v) const;
199  Par ty( VSR_PRECISION v) const;
200  Par tz( VSR_PRECISION v) const;
201 
202  /* Real Circles */
203  Cir cxy() const;
204  Cir cxz() const;
205  Cir cyz() const;
206 
207  /* Imaginary Circles */
208  Cir icxy() const;
209  Cir icxz() const;
210  Cir icyz() const;
211 
212  Vec right() const { return x(); }
213  Vec up() const { return y(); }
214  Vec forward() const { return -z(); }
215 
217  Frame& mot(const Mot& m);
218 
220  Trs trs() const;
221 
223  Mot mot() const;
224 
226  Motor motor() const;
227 
229  Dls bound() const;
230 
232  Dls ibound() const;
233 
235  Dll dll() const;
236  DualLine dualLine() const;
237 
238  VSR_PRECISION& ab() { return aBiv; }
239  VSR_PRECISION ab() const { return aBiv; }
240  VSR_PRECISION& ax() { return aVec; }
241  VSR_PRECISION ax() const { return aVec; }
242  Biv& db() { return dBiv; }
243  Biv db() const { return dBiv; }
244  Vec& dx() { return dVec; }
245  Vec dx() const { return dVec; }
246 
248  Frame& step();
249 
251  Frame& move();
252 
254  Frame& spin();
255 
257  Frame& dilate(double t);
259  Frame& dilate(const Point& p, double t);
260 
262  Frame rotXY( VSR_PRECISION amt) const;
263 
265  Frame& move( VSR_PRECISION dx , VSR_PRECISION dy, VSR_PRECISION dz );
267  Frame& move( const Vec& v);
268  // Spin by Biv
269  Frame& rotate( const Biv& b);
271  Frame& rotate( const Rot& r);
273  Frame& twist( const Dll& );
275  Frame& twist( const Mot& );
277  Frame& boost( const Par&);
279  Frame& boost( const Bst&);
280 
281  Frame moveX( VSR_PRECISION amt ) const;
282  Frame moveY( VSR_PRECISION amt ) const;
283  Frame moveZ( VSR_PRECISION amt ) const;
284 
285  //DEPRECATED
287  //Frame move( VSR_PRECISION dx , VSR_PRECISION dy, VSR_PRECISION dz ) const;
288 
289  };
290 
291 } } //vsr::
292 
293 
294 #endif /* ----- #ifndef vsr_cga3D_frame_INC ----- */
Biv & db()
Set bivector velocity (rotational)
Definition: vsr_cga3D_frame.h:242
Frame & rot(const Biv &B)
Set rotor with bivector generator.
Definition: vsr_cga3D_frame.h:108
Par px() const
x direction point pair around center
Vec & dx()
Set vector velocity.
Definition: vsr_cga3D_frame.h:244
Par tx() const
Null Point Pair in local x direction.
Common Operations Specific to CGA3D.
NDlp< 5 > Dlp
DualPlane
Definition: vsr_cga3D_types.h:81
Dlp dxz() const
xz dual plane
NCir< 5 > Cir
Circle
Definition: vsr_cga3D_types.h:74
Par ipz() const
z direction imaginary point pair around center
NVec< 5 > Vec
Vector
Definition: vsr_cga3D_types.h:62
Point pos() const
Get Position.
Definition: vsr_cga3D_frame.h:138
Mot mot() const
Get Absolute Motor Relative to Origin.
Vec y() const
Local y.
Motor motor() const
Get Absolute Motor Relative to Origin.
Par ipx() const
x direction imaginary point pair around center
NDls< 5 > Dls
DualSphere
Definition: vsr_cga3D_types.h:76
Frame & twist(const Dll &)
Twist by dualLine and return *this.
Generic Geometric Number Types (templated on an algebra and a basis )
Definition: vsr_algebra.h:69
Frame & pos(VSR_PRECISION _x, VSR_PRECISION _y, VSR_PRECISION _z)
Set Position from x,y,z coordinates.
Definition: vsr_cga3D_frame.h:148
Definition: vsr_algebra.h:73
Frame & spin()
Spin Step (Local Rotation) */.
Rotor mRot
Orientation.
Definition: vsr_cga3D_frame.h:53
NLin< 5 > Lin
Line
Definition: vsr_cga3D_types.h:80
Par py() const
y direction point pair around center
static Rot rot(const Biv &b)
vsr::cga::Rotor from vsr::cga::Bivector
Biv db() const
Get bivector velocity (rotational)
Definition: vsr_cga3D_frame.h:243
Multivector< algebra, typename algebra::vector_basis > null() const
Conformal Mapping \(\boldsymbol(x)\to n_o + \boldsymbol{x} + \boldsymbol{x}^2n_\infty \) ...
Definition: vsr_generic_op.h:1118
Rotor relOrientRot(const Vec &v, bool pos=true)
Rotor to Orient Current Orientation towards v Rotor to Orient Current Orientation towards v...
Rotor rotor() const
Get Rotor.
Definition: vsr_cga3D_frame.h:99
Dls bound() const
Dual Sphere Shell.
Dlp dxy() const
xy dual plane
Frame & dilate(double t)
Dilate by t around center.
Frame & reset()
Reset to Origin.
Definition: vsr_cga3D_frame.h:85
Dlp dyz() const
yz dual plane
Frame & scale(VSR_PRECISION s)
Set Scale.
Definition: vsr_cga3D_frame.h:83
Lin lz() const
z direction direct line
Frame & pos(const Vec &v)
Set Postion from Vec v.
Definition: vsr_cga3D_frame.h:144
Biv relOrientBiv(const Vec &v, bool pos=true)
Get Bivector generator to Orient towards v.
Vec vec() const
Get Euclidean Vector of position.
Definition: vsr_cga3D_frame.h:142
Point & pos()
Get / Set Position by Reference.
Definition: vsr_cga3D_frame.h:140
Cir cyz() const
yz circle (real, direct)
Lin ly() const
y direction direct line
Frame & relOrient(const Vec &v, float t, bool pos=true)
Relative Orientation by amt t.
NPar< 5 > Par
Pair
Definition: vsr_cga3D_types.h:73
VSR_PRECISION aVec
Translational acceleration.
Definition: vsr_cga3D_frame.h:57
Vec dx() const
Get vector velocity.
Definition: vsr_cga3D_frame.h:245
Frame()
Default Constructor.
VSR_PRECISION ax() const
Get vector accelerator.
Definition: vsr_cga3D_frame.h:241
NDll< 5 > Dll
DualLine
Definition: vsr_cga3D_types.h:79
Vec dVec
Translational Velocity.
Definition: vsr_cga3D_frame.h:58
VSR_PRECISION & ax()
Set vector accelerator.
Definition: vsr_cga3D_frame.h:240
Frame & set(Pnt p, Rot r=Rot(1, 0, 0, 0))
Set Position and Orientation from Point and Rotor.
Definition: vsr_cga3D_frame.h:81
Frame & boost(const Par &)
Boost by point pair and return *this.
Frame & relTwist(const Frame &target, float t)
Relative twist towards frame f by amt t.
VSR_PRECISION scale() const
Get Scale.
Definition: vsr_cga3D_frame.h:88
Dll dll() const
DualLine Representation of Pose.
Cir icxz() const
xz circle (imaginary, direct)
Biv xz() const
xy euclidean bivector
Pnt Point
Null Vector \(p=\{e_1,e_2,e_3,n_o,n_\infty\}\)
Definition: vsr_cga3D_types.h:128
Trs trs() const
Generate Translation versor based on Position.
Rot & rot()
Get Rotor by reference.
Definition: vsr_cga3D_frame.h:102
Cir icxy() const
xy circle (imaginary, direct)
Frame & orient(const Vec &v, bool pos=true)
Orient z axis towards coordinate v, keeping y axis as vertical as possible (uses projection) boolean ...
Frame & move()
Translation Step (translate by velocity vector)
Cir cxz() const
xz circle (real, direct)
the versor library namespace
Definition: vsr_algebra.h:29
Lin lx() const
x direction direct line
Par ty() const
Null Point Pair in local y direction.
VSR_PRECISION aBiv
Rotational acceleration.
Definition: vsr_cga3D_frame.h:55
Rotor rot() const
Get 4x4 Rotation Matrix.
Definition: vsr_cga3D_frame.h:97
Frame & rot(const Rot &r)
Set rotor with rotor.
Definition: vsr_cga3D_frame.h:106
Frame rotXY(VSR_PRECISION amt) const
Rotate around local xy and return a new frame.
Dll DualLine
Dual Line bivector \(\lambda=\boldsymbol{B}+\boldsymbol{x}n_\infty\)
Definition: vsr_cga3D_types.h:139
Frame & orientX(const Vec &v, float amt, bool pos=true)
Orient X axis towards coordinate v, by amt t, keeping y axis as vertical as possible (uses projection...
Rot quat() const
Transpose rotor to quaternionic representation.
Definition: vsr_cga3D_frame.h:110
Frame & pos(const Pnt &p)
Set Position from Point p.
Definition: vsr_cga3D_frame.h:146
Orthonormal Frame composed from a Position and Orientation.
Definition: vsr_cga3D_frame.h:47
Par ipy() const
y direction imaginary point pair around center
NBiv< 5 > Biv
Bivector
Definition: vsr_cga3D_types.h:63
Point mPos
Position.
Definition: vsr_cga3D_frame.h:52
static Point point(VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z)
Null Point from Coordinates.
Motor relMotor(const Frame &target)
Relative Motor to Take this to Frame f.
Par pz() const
z direction point pair around center
Biv yz() const
yz euclidean bivector
VSR_PRECISION mScale
Scale.
Definition: vsr_cga3D_frame.h:59
VSR_PRECISION ab() const
Get bivector accelerator (rotational)
Definition: vsr_cga3D_frame.h:239
Dls ibound() const
Dual Imaginary Sphere Shell.
NTrs< 5 > Trs
Translator
Definition: vsr_cga3D_types.h:91
Mot Motor
Twisting Rotor \(e^\lambda\)
Definition: vsr_cga3D_types.h:145
Cir cxy() const
xy circle (real, direct)
Cir icyz() const
yz circle (imaginary, direct)
Dll dlz() const
z direction dual line
Biv xy() const
xz euclidean bivector
Frame & relTwistAway(const Frame &target, float t)
Relative twist away frome frame f by amt t.
Vec z() const
Local z.
Vec x() const
Local x.
Par tz() const
Null Point Pair in local z direction.
VSR_PRECISION & ab()
Set bivector accelerator (rotational)
Definition: vsr_cga3D_frame.h:238
Dll dly() const
y direction dual line
Frame & step()
Move and Spin.
Dll dlx() const
x direction dual line
Biv dBiv
Rotational Velocity.
Definition: vsr_cga3D_frame.h:56
NMot< 5 > Mot
Motor
Definition: vsr_cga3D_types.h:92
NRot< 5 > Rot
Rotor
Definition: vsr_cga3D_types.h:64