Itasca C++ Interface
Loading...
Searching...
No Matches
axes.h
Go to the documentation of this file.
1#pragma once
2
9#include "vect.h"
10#include "avect.h"
11#include "orientation.h"
12
14
21class Axes2D {
22public:
26 BASE_EXPORT Axes2D(const Axes2D &a) : c_(a.c_), d1_(a.d1_), d2_(a.d2_) { }
32 BASE_EXPORT Axes2D(const DVect2 &vx,const DVect2 &vy,bool normalize,const DVect2 &c=DVect2(0));
36 BASE_EXPORT explicit Axes2D(double dip,const DVect2 &c=DVect2(0)) { setOrientation(dip); setOrigin(c); }
40 BASE_EXPORT explicit Axes2D(const Orientation2 &o,const DVect2 &c=DVect2(0)) { setOrientation(o); setOrigin(c); }
41
43 BASE_EXPORT constexpr const Axes2D &operator=(const Axes2D &a) { d1_=a.d1_; d2_=a.d2_; c_=a.c_; return *this; }
45 BASE_EXPORT bool operator==(const Axes2D &a) const;
47 BASE_EXPORT bool operator!=(const Axes2D &a) const { return !operator==(a); }
48
50 BASE_EXPORT void setOrigin(const DVect2 &c) { c_=c; }
52 BASE_EXPORT void setOrientation(double dip);
55
57 BASE_EXPORT const DVect2 &c() const { return c_; }
59 BASE_EXPORT const DVect2 &e1() const { return d1_; }
61 BASE_EXPORT const DVect2 &e2() const { return d2_; }
62 // Note: If you use these - no checks are made to ensure vectors are orthonormal!
63
65 BASE_EXPORT DVect2 &rc() { return c_; }
68 BASE_EXPORT DVect2 &re1() { return d1_; }
71 BASE_EXPORT DVect2 &re2() { return d2_; }
72
74 BASE_EXPORT DVect2 toLocal(const DVect2 &v) const;
76 BASE_EXPORT const DAVect2 &toLocal(const DAVect2 &v) const { return v; }
78 BASE_EXPORT DVect2 toGlobal(const DVect2 &v) const;
80 BASE_EXPORT const DAVect2 &toGlobal(const DAVect2 &v) const { return v; }
82 BASE_EXPORT DVect2 getDir(uint32 dof) const;
83 BASE_EXPORT void setDir(uint32 dof,const DVect2 &v);
84 BASE_EXPORT void setDirAuto(uint32 dof,uint32 keepDOF=0xFFFFFFFF);
86 BASE_EXPORT Orientation2 getOrientation(uint32 dof=0) const;
87
88 // Static
90 static BASE_EXPORT Axes2D make(const DVect2 &y,bool normalize);
92 static BASE_EXPORT Axes2D makeX(const DVect2 &x,bool normalize);
97 // Makes a default axes assuming dir only is specified.
98 static BASE_EXPORT Axes2D make(const DVect2 &dir,uint32 dof,bool normalize);
99 static BASE_EXPORT Axes2D makeDef() { Axes2D a(DVect2(1,0),DVect2(0,1),false); return a; }
102 static BASE_EXPORT void setTolerance(double d);
104 static BASE_EXPORT double getTolerance();
105 static BASE_EXPORT Axes2D global() { return Axes2D(DVect2(1,0),DVect2(0,1),false); }
106private:
107 DVect2 c_ = DVect2(0.0, 0.0);
108 DVect2 d1_ = DVect2(1.0, 0.0);
109 DVect2 d2_ = DVect2(0.0, 1.0);
110};
111
112
113
115
121class Axes3D {
122public:
126 BASE_EXPORT Axes3D(const Axes3D &a) : c_(a.c_), d1_(a.d1_), d2_(a.d2_), d3_(a.d3_) { }
128 BASE_EXPORT explicit Axes3D(const Axes2D &a) : c_(toVect3(a.c())), d1_(toVect3(a.e1())), d2_(toVect3(a.e2())), d3_(0,0,1) { }
131 BASE_EXPORT Axes3D(const DVect3 &vx, const DVect3 &vy, const DVect3 &vz, bool normalize,const DVect3 &c=DVect3(0));
137 BASE_EXPORT Axes3D(double dip,double ddir,double roll=0.0, const DVect3 &c=DVect3(0)) { setOrientation(dip,ddir,roll); setOrigin(c); }
140 BASE_EXPORT explicit Axes3D(const Orientation3 &o,double roll=0.0,const DVect3 &c=DVect3(0)) { setOrientation(o,roll); setOrigin(c); }
141
143 BASE_EXPORT constexpr const Axes3D &operator=(const Axes3D &a) { d1_=a.d1_; d2_=a.d2_; d3_=a.d3_; c_=a.c_; return *this; }
145 BASE_EXPORT bool operator==(const Axes3D &a) const;
147 BASE_EXPORT bool operator!=(const Axes3D &a) const { return !operator==(a); }
148
150 BASE_EXPORT void setOrigin(const DVect3 &c) { c_=c; }
154 BASE_EXPORT void setOrientation(double dip,double ddir,double roll); // radians
157 BASE_EXPORT void setOrientation(const Orientation3 &o,double roll);
158
159 // These return the unit vectors e1,e2,e3, defining an orthonormal basis....
161 BASE_EXPORT const DVect3 &c() const { return c_; }
163 BASE_EXPORT const DVect3 &e1() const { return d1_; }
165 BASE_EXPORT const DVect3 &e2() const { return d2_; }
167 BASE_EXPORT const DVect3 &e3() const { return d3_; }
168
170 BASE_EXPORT DVect3 &rc() { return c_; }
173 BASE_EXPORT DVect3 &re1() { return d1_; }
176 BASE_EXPORT DVect3 &re2() { return d2_; }
179 BASE_EXPORT DVect3 &re3() { return d3_; }
180 BASE_EXPORT DVect3 &rdof(uint32 dof) { if (!dof) return d1_; else if (dof==1) return d2_; else if (dof==2) return d3_; else return c_; }
181
183 BASE_EXPORT DVect3 toLocal(const DVect3 &v) const;
185 BASE_EXPORT DVect3 toGlobal(const DVect3 &v) const;
187 BASE_EXPORT DVect3 getDir(uint32 dof) const;
188 BASE_EXPORT void setDir(uint32 dof,const DVect3 &v);
189 BASE_EXPORT void setDirAuto(uint32 dof,uint32 keepDOF=0xFFFFFFFF);
191 BASE_EXPORT Orientation3 getOrientation(uint32 dof=0) const;
194 BASE_EXPORT double getRoll() const;
195
196 // Static
201 static BASE_EXPORT Axes3D make(const DVect3 &z,bool normalize,double roll=0.0);
204 static BASE_EXPORT Axes3D makeX(const DVect3 &x,bool normalize,double roll=0.0);
209 static BASE_EXPORT Axes3D make(const Orientation3 &o,double roll=0.0);
212 static BASE_EXPORT Axes3D makeX(const Orientation3 &o,double roll=0.0);
215 static BASE_EXPORT Axes3D make(const DVect3 &z,const DVect3 &x,bool normalize);
216 // Makes a default axes assuming dir only is specified.
217 static BASE_EXPORT Axes3D make(const DVect3 &dir,uint32 dof,bool normalize);
218 static BASE_EXPORT Axes3D makeDef() { Axes3D a(DVect3(1,0,0),DVect3(0,1,0),DVect3(0,0,1),false); return a; }
221 static BASE_EXPORT void setTolerance(double d); // Defaults to 1e-6
223 static BASE_EXPORT double getTolerance();
224 static BASE_EXPORT Axes3D global() { return Axes3D(DVect3(1,0,0),DVect3(0,1,0),DVect3(0,0,1),false); }
225private:
226 DVect3 c_ = DVect3(0.0, 0.0, 0.0);
227 DVect3 d1_ = DVect3(1.0, 0.0, 0.0);
228 DVect3 d2_ = DVect3(0.0, 1.0, 0.0);
229 DVect3 d3_ = DVect3(0.0, 0.0, 1.0);
230};
231
233// EOF
Angular Vectors.
Class for specifying a particular 2D cartesian axes system, and converting to and from it.
Definition axes.h:21
static BASE_EXPORT Axes2D makeX(const Orientation2 &o)
Creates an Axes using orientaion o for the +x direction.
BASE_EXPORT Axes2D(const Orientation2 &o, const DVect2 &c=DVect2(0))
Definition axes.h:40
BASE_EXPORT const DAVect2 & toLocal(const DAVect2 &v) const
Convert DAVect2 v from "global" system to this system (identity transformation).
Definition axes.h:76
BASE_EXPORT DVect2 getDir(uint32 dof) const
Return e1 or e2 given degree-of-freedom dof (0-1)
Definition axes.cpp:47
BASE_EXPORT DVect2 & re2()
Definition axes.h:71
BASE_EXPORT DVect2 toGlobal(const DVect2 &v) const
Convert DVect2 v from this system to a "global" system.
Definition axes.cpp:34
BASE_EXPORT Axes2D(double dip, const DVect2 &c=DVect2(0))
Definition axes.h:36
static BASE_EXPORT void setTolerance(double d)
Definition axes.cpp:95
BASE_EXPORT bool operator!=(const Axes2D &a) const
Comparison operator.
Definition axes.h:47
static BASE_EXPORT double getTolerance()
Returns the tolerance used for comparison and detecting "near enough to zero".
Definition axes.cpp:99
BASE_EXPORT void setOrigin(const DVect2 &c)
Specifies a new origin for the axes system.
Definition axes.h:50
BASE_EXPORT constexpr const Axes2D & operator=(const Axes2D &a)
Equality operator.
Definition axes.h:43
BASE_EXPORT void setOrientation(double dip)
Specifies a new orientation for the axes, by dip (in radians).
Definition axes.cpp:16
BASE_EXPORT Axes2D()
Default construction, no initialization of data.
Definition axes.h:24
static BASE_EXPORT Axes2D make(const DVect2 &y, bool normalize)
Creates an Axes using vector y in the +y direction (need not be unit).
Definition axes.cpp:77
BASE_EXPORT Orientation2 getOrientation(uint32 dof=0) const
Returns the equivalent orientation of degree-of-freedom dof (0-1)
Definition axes.cpp:72
BASE_EXPORT DVect2 & rc()
Reference access to the axes origin.
Definition axes.h:65
BASE_EXPORT DVect2 toLocal(const DVect2 &v) const
Convert Dvect2 v from "global" system to this system.
Definition axes.cpp:28
BASE_EXPORT bool operator==(const Axes2D &a) const
Comparison operator.
Definition axes.cpp:40
BASE_EXPORT Axes2D(const Axes2D &a)
Copy constructor.
Definition axes.h:26
static BASE_EXPORT Axes2D makeX(const DVect2 &x, bool normalize)
Creates an Axes using vector x in the +x direction (need not be unit).
Definition axes.cpp:83
static BASE_EXPORT Axes2D make(const Orientation2 &o)
Creates an Axes using orientaion o for the +y direction.
BASE_EXPORT DVect2 & re1()
Definition axes.h:68
BASE_EXPORT const DVect2 & e2() const
The y unit vector.
Definition axes.h:61
BASE_EXPORT const DVect2 & c() const
The origin of the axes system.
Definition axes.h:57
BASE_EXPORT const DVect2 & e1() const
The x unit vector.
Definition axes.h:59
BASE_EXPORT const DAVect2 & toGlobal(const DAVect2 &v) const
Convert DAVect2 v from this system to a "global" system (identity transformation).
Definition axes.h:80
Class for specifying a particular 3D cartesian axes system, and converting to and from it.
Definition axes.h:121
static BASE_EXPORT double getTolerance()
Returns the Tolerance used for comparison and detecting "near enough to zero".
Definition axes.cpp:299
BASE_EXPORT void setOrigin(const DVect3 &c)
Change the origin of the axes sytem.
Definition axes.h:150
static BASE_EXPORT Axes3D make(const DVect3 &z, bool normalize, double roll=0.0)
Definition axes.cpp:253
BASE_EXPORT DVect3 & re3()
Definition axes.h:179
BASE_EXPORT DVect3 & re2()
Definition axes.h:176
BASE_EXPORT Orientation3 getOrientation(uint32 dof=0) const
Returns equivalent orientation of e1, e2, or e2 based on degree-of-freedom (0-2)
Definition axes.cpp:237
BASE_EXPORT Axes3D(const Axes2D &a)
Explicit construction from Axes2D. e3() = (0,0,1).
Definition axes.h:128
BASE_EXPORT DVect3 & rc()
Reference access to the origin of the axes system.
Definition axes.h:170
BASE_EXPORT Axes3D(const Axes3D &a)
Copy constructor.
Definition axes.h:126
static BASE_EXPORT Axes3D makeX(const DVect3 &x, bool normalize, double roll=0.0)
Definition axes.cpp:257
static BASE_EXPORT void setTolerance(double d)
Definition axes.cpp:295
BASE_EXPORT const DVect3 & c() const
The origin of the axes system.
Definition axes.h:161
BASE_EXPORT void setOrientation(double dip, double ddir, double roll)
Definition axes.cpp:141
BASE_EXPORT bool operator==(const Axes3D &a) const
Comparison operator.
Definition axes.cpp:167
BASE_EXPORT const DVect3 & e1() const
The x unit direction.
Definition axes.h:163
BASE_EXPORT bool operator!=(const Axes3D &a) const
Comparison operator.
Definition axes.h:147
BASE_EXPORT Axes3D(const Orientation3 &o, double roll=0.0, const DVect3 &c=DVect3(0))
Definition axes.h:140
BASE_EXPORT Axes3D()
Default constructor, no initialization of data.
Definition axes.h:124
BASE_EXPORT DVect3 toGlobal(const DVect3 &v) const
Converts a vector from this system to a "global" system.
Definition axes.cpp:160
BASE_EXPORT const DVect3 & e2() const
The y unit direction.
Definition axes.h:165
BASE_EXPORT double getRoll() const
Definition axes.cpp:242
BASE_EXPORT const DVect3 & e3() const
The z unit direction.
Definition axes.h:167
BASE_EXPORT constexpr const Axes3D & operator=(const Axes3D &a)
Equality operator.
Definition axes.h:143
BASE_EXPORT DVect3 toLocal(const DVect3 &v) const
Converts a vector from "global" (cartesian) system to this system.
Definition axes.cpp:154
BASE_EXPORT DVect3 & re1()
Definition axes.h:173
BASE_EXPORT DVect3 getDir(uint32 dof) const
Return e1, e2, or e3 based on degree-of-freedom (0-2)
Definition axes.cpp:179
BASE_EXPORT Axes3D(double dip, double ddir, double roll=0.0, const DVect3 &c=DVect3(0))
Definition axes.h:137
Class for storing an "orientation", or a direction in 2D or 3D space.
Definition orientation.h:50
Class for storing an "orientation", or a direction in 2D or 3D space.
Definition orientation.h:99
constexpr Vector3< T > toVect3(const Vector2< T > &v, const T &t=0)
Conversion between vectors of different dimension.
Definition vect.h:341
#define BASE_EXPORT
Definition basedef.h:24
Class for storing an "orientation", or a direction in 2D or 3D space.
2D and 3D vector utility classes.