Itasca C++ Interface
Loading...
Searching...
No Matches
caxes.h
Go to the documentation of this file.
1#pragma once
8#include "vect.h"
9#include "avect.h"
10#include "orientation.h"
11
13
25class CAxes2D {
26public:
30 BASE_EXPORT CAxes2D(const CAxes2D &a) : d1_(a.d1_) { }
33 BASE_EXPORT CAxes2D(const DVect2 &vx);
36 BASE_EXPORT explicit CAxes2D(const double &dip) { setOrientation(dip); }
40
42 BASE_EXPORT const CAxes2D &operator=(const CAxes2D &a) { d1_=a.d1_; return *this; }
44 BASE_EXPORT bool operator==(const CAxes2D &a) const;
46 BASE_EXPORT bool operator!=(const CAxes2D &a) const { return !operator==(a); }
47
49 BASE_EXPORT void setOrientation(const double &dip);
52
54 BASE_EXPORT const DVect2 &e1() const { return d1_; }
56 BASE_EXPORT DVect2 e2() const { return DVect2(-d1_.y(),d1_.x()); }
57
60 BASE_EXPORT DVect2 &re1() { return d1_; }
61
63 BASE_EXPORT DVect2 toLocal(const DVect2 &v) const;
65 BASE_EXPORT const DAVect2 &toLocal(const DAVect2 &v) const { return v; }
67 BASE_EXPORT DVect2 toGlobal(const DVect2 &v) const;
69 BASE_EXPORT const DAVect2 &toGlobal(const DAVect2 &v) const { return v; }
71 BASE_EXPORT DVect2 getDir(unsigned int dof) const;
73 BASE_EXPORT Orientation2 getOrientation(unsigned int dof=0) const;
74
75 // Static
77 static BASE_EXPORT CAxes2D make(const DVect2 &y);
79 static BASE_EXPORT CAxes2D makeX(const DVect2 &x);
86 static BASE_EXPORT void setTolerance(const double &d);
87private:
88 DVect2 d1_;
89};
90
92
103class CAxes3D {
104public:
108 BASE_EXPORT CAxes3D(const CAxes3D &a) : d1_(a.d1_), d2_(a.d2_) { }
110 BASE_EXPORT explicit CAxes3D(const CAxes2D &a) : d1_(toVect3(a.e1())), d2_(toVect3(a.e2())) { }
113 BASE_EXPORT CAxes3D(const DVect3 &vx, const DVect3 &vy);
119 BASE_EXPORT CAxes3D(const double &dip, const double &ddir, const double &roll=0.0) { setOrientation(dip,ddir,roll); }
122 BASE_EXPORT explicit CAxes3D(const Orientation3 &o,const double &roll=0.0) { setOrientation(o,roll); }
123
125 BASE_EXPORT const CAxes3D &operator=(const CAxes3D &a) { d1_=a.d1_; d2_=a.d2_; return *this; }
127 BASE_EXPORT bool operator==(const CAxes3D &a) const;
129 BASE_EXPORT bool operator!=(const CAxes3D &a) const { return !operator==(a); }
130
134 BASE_EXPORT void setOrientation(const double &dip, const double &ddir, const double &roll=0.0); // radians
137 BASE_EXPORT void setOrientation(const Orientation3 &o,const double &roll=0.0);
138
140 BASE_EXPORT const DVect3 &e1() const { return d1_; }
142 BASE_EXPORT const DVect3 &e2() const { return d2_; }
144 BASE_EXPORT DVect3 e3() const { return d1_&d2_; }
145
148 BASE_EXPORT DVect3 &re1() { return d1_; }
151 BASE_EXPORT DVect3 &re2() { return d2_; }
152
154 BASE_EXPORT DVect3 toLocal(const DVect3 &v) const;
156 BASE_EXPORT DVect3 toGlobal(const DVect3 &v) const;
158 BASE_EXPORT DVect3 getDir(unsigned int dof) const;
160 BASE_EXPORT Orientation3 getOrientation(unsigned int dof=0) const;
163 BASE_EXPORT double getRoll() const;
164
165 // Static
170 static BASE_EXPORT CAxes3D make(const DVect3 &z,const double &roll=0.0);
173 static BASE_EXPORT CAxes3D makeX(const DVect3 &x,const double &roll=0.0);
178 static BASE_EXPORT CAxes3D make(const Orientation3 &o,const double &roll=0.0);
181 static BASE_EXPORT CAxes3D makeX(const Orientation3 &o,const double &roll=0.0);
184 static BASE_EXPORT void setTolerance(const double &d); // Defaults to 1e-6
185private:
186 DVect3 d1_;
187 DVect3 d2_;
188};
189
191// EOF
Angular Vectors.
Class for specifying a particular 2D cartesian axes system, and converting to and from it.
Definition caxes.h:25
static BASE_EXPORT CAxes2D makeX(const Orientation2 &o)
Creates an Axes using orientaion o for the +x direction.
BASE_EXPORT bool operator==(const CAxes2D &a) const
Comparison operator.
Definition caxes.cpp:33
BASE_EXPORT const DAVect2 & toGlobal(const DAVect2 &v) const
Convert DAVect2 v from this system to a "global" system (identity transformation).
Definition caxes.h:69
BASE_EXPORT DVect2 toGlobal(const DVect2 &v) const
Convert DVect2 v from this system to a "global" system.
Definition caxes.cpp:28
BASE_EXPORT DVect2 & re1()
Definition caxes.h:60
BASE_EXPORT const DAVect2 & toLocal(const DAVect2 &v) const
Convert DAVect2 v from "global" system to this system (identity transformation).
Definition caxes.h:65
BASE_EXPORT const CAxes2D & operator=(const CAxes2D &a)
Equality operator.
Definition caxes.h:42
BASE_EXPORT CAxes2D(const double &dip)
Definition caxes.h:36
BASE_EXPORT CAxes2D()
Default construction, no initialization of data.
Definition caxes.h:28
static BASE_EXPORT CAxes2D make(const DVect2 &y)
Creates an Axes using vector y in the +y direction (need not be unit).
Definition caxes.cpp:56
BASE_EXPORT DVect2 toLocal(const DVect2 &v) const
Convert Dvect2 v from "global" system to this system.
Definition caxes.cpp:24
BASE_EXPORT CAxes2D(const CAxes2D &a)
Copy constructor.
Definition caxes.h:30
BASE_EXPORT void setOrientation(const double &dip)
Specifies a new orientation for the axes, by dip (in radians).
Definition caxes.cpp:12
BASE_EXPORT bool operator!=(const CAxes2D &a) const
Comparison operator.
Definition caxes.h:46
BASE_EXPORT DVect2 e2() const
The y unit vector.
Definition caxes.h:56
static BASE_EXPORT CAxes2D makeX(const DVect2 &x)
Creates an Axes using vector x in the +x direction (need not be unit).
Definition caxes.cpp:61
static BASE_EXPORT CAxes2D make(const Orientation2 &o)
Creates an Axes using orientaion o for the +y direction.
BASE_EXPORT DVect2 getDir(unsigned int dof) const
Return e1 or e2 given degree-of-freedom dof (0-1)
Definition caxes.cpp:38
BASE_EXPORT Orientation2 getOrientation(unsigned int dof=0) const
Returns the equivalent orientation of degree-of-freedom dof (0-1)
Definition caxes.cpp:51
static BASE_EXPORT void setTolerance(const double &d)
Definition caxes.cpp:66
BASE_EXPORT CAxes2D(const Orientation2 &o)
Definition caxes.h:39
BASE_EXPORT const DVect2 & e1() const
The x unit vector.
Definition caxes.h:54
Class for specifying a particular 3D cartesian axes system, and converting to and from it.
Definition caxes.h:103
BASE_EXPORT const CAxes3D & operator=(const CAxes3D &a)
Equality operator.
Definition caxes.h:125
BASE_EXPORT CAxes3D()
Default constructor, no initialization of data.
Definition caxes.h:106
BASE_EXPORT CAxes3D(const CAxes2D &a)
Explicit construction from CAxes2D. e3() = (0,0,1).
Definition caxes.h:110
static BASE_EXPORT CAxes3D make(const DVect3 &z, const double &roll=0.0)
Definition caxes.cpp:160
BASE_EXPORT DVect3 & re2()
Definition caxes.h:151
static BASE_EXPORT CAxes3D makeX(const DVect3 &x, const double &roll=0.0)
Definition caxes.cpp:166
BASE_EXPORT bool operator==(const CAxes3D &a) const
Comparison operator.
Definition caxes.cpp:123
BASE_EXPORT const DVect3 & e2() const
The y unit direction.
Definition caxes.h:142
BASE_EXPORT DVect3 e3() const
The z unit direction.
Definition caxes.h:144
BASE_EXPORT DVect3 getDir(unsigned int dof) const
Return e1, e2, or e3 based on degree-of-freedom (0-2)
Definition caxes.cpp:129
BASE_EXPORT DVect3 toLocal(const DVect3 &v) const
Converts a vector from "global" (cartesian) system to this system.
Definition caxes.cpp:111
BASE_EXPORT Orientation3 getOrientation(unsigned int dof=0) const
Returns equivalent orientation of e1, e2, or e2 based on degree-of-freedom (0-2)
Definition caxes.cpp:144
BASE_EXPORT CAxes3D(const Orientation3 &o, const double &roll=0.0)
Definition caxes.h:122
BASE_EXPORT CAxes3D(const CAxes3D &a)
Copy constructor.
Definition caxes.h:108
BASE_EXPORT DVect3 toGlobal(const DVect3 &v) const
Converts a vector from this system to a "global" system.
Definition caxes.cpp:115
BASE_EXPORT const DVect3 & e1() const
The x unit direction.
Definition caxes.h:140
BASE_EXPORT CAxes3D(const double &dip, const double &ddir, const double &roll=0.0)
Definition caxes.h:119
BASE_EXPORT void setOrientation(const double &dip, const double &ddir, const double &roll=0.0)
Definition caxes.cpp:73
BASE_EXPORT DVect3 & re1()
Definition caxes.h:148
static BASE_EXPORT void setTolerance(const double &d)
Definition caxes.cpp:179
BASE_EXPORT double getRoll() const
Definition caxes.cpp:149
BASE_EXPORT bool operator!=(const CAxes3D &a) const
Comparison operator.
Definition caxes.h:129
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.