25 Quat2(
const double &a): ang_(a) { }
33 void setQuat(
const double &a){ ang_ = a; }
36 const double &
ang()
const {
return ang_; }
39 double &
rang() {
return ang_; }
57 BASE_EXPORT void fromEuler(
const DAVect2 &v) { *
this =
Quat2(v.z()) * dDegrad; }
111 Quat3(): w_(0), i_(0), j_(0), k_(0) { }
114 Quat3(
const double &w1,
const double &x,
const double &y,
const double &z) { w_ = w1; i_ = x; j_ = y; k_ = z; }
118 Quat3(
const Quat3 &q) { w_ = q.w_; i_ = q.i_; j_ = q.j_; k_ = q.k_; }
120 constexpr const Quat3 &
operator=(
const Quat3 &q) { w_ = q.w_; i_ = q.i_; j_ = q.j_; k_ = q.k_;
return *
this; }
122 void setQuat(
const double &w1,
const double &x,
const double &y,
const double &z){ w_ = w1; i_ = x; j_ = y; k_ = z; }
125 const double &
w()
const {
return w_; }
127 const double &
i()
const {
return i_; }
129 const double &
j()
const {
return j_; }
131 const double &
k()
const {
return k_; }
134 double &
rw() {
return w_; }
136 double &
ri() {
return i_; }
138 double &
rj() {
return j_; }
140 double &
rk() {
return k_; }
143 void reset() { w_=0.0; i_=0.0; j_=0.0; k_=0.0; }
145 void ident() { w_=1.0; i_=0.0; j_=0.0; k_=0.0; }
149 BASE_EXPORT bool isNull()
const {
return (abs(w_) > std::numeric_limits<double>::epsilon() || abs(i_) > std::numeric_limits<double>::epsilon() || abs(j_) > std::numeric_limits<double>::epsilon() || abs(k_) > std::numeric_limits<double>::epsilon()) ? false :
true; }
191 void conj() { i_=-i_; j_=-j_; k_=-k_; }
204 Quat3 operator *(
const Quat3 &v)
const {
Quat3 q(w_*v.w_-i_*v.i_-j_*v.j_-k_*v.k_,w_*v.i_+i_*v.w_+j_*v.k_-k_*v.j_,w_*v.j_-i_*v.k_+j_*v.w_+k_*v.i_,w_*v.k_+i_*v.j_-j_*v.i_+k_*v.w_);
return q; }
213 const Quat3 &
operator *=(
const double &d) { w_ *= d; i_ *= d; j_ *= d; k_ *= d;
return *
this; }
215 const Quat3 &
operator /=(
const double &d) { w_ /= d; i_ /= d; j_ /= d; k_ /= d;
return *
this; }
218 double ti(w_*v.i_+i_*v.w_+j_*v.k_-k_*v.j_);
219 double tj(w_*v.j_-i_*v.k_+j_*v.w_+k_*v.i_);
220 double tk(w_*v.k_+i_*v.j_-j_*v.i_+k_*v.w_);
225 w_ = tw; i_ = ti; j_ = tj; k_ = tk;
230 bool operator ==(
const Quat3 &v)
const {
return (w_ == v.w_ && i_==v.i_ && j_==v.j_ && k_==v.k_); }
238 BASE_EXPORT string ts(
const Quat2 &q,
int width=0,
char notation =
'\0',
int precision = -1,
char fill =
' ');
240 BASE_EXPORT string ts(
const Quat3 &q,
int width=0,
char notation =
'\0',
int precision = -1,
char fill =
' ');
DMatrix is a Matrix that defaults to type double...
Definition matrix.h:758
2D quaternion-like utility class. In this case only the angle (in radians) is stored as opposed to th...
Definition quat.h:20
Quat2 operator+(const Quat2 &v) const
Addition of quaterions. This is also the composition of rotations in 2D.
Definition quat.h:87
friend Quat2 operator*(const double &d, const Quat2 &p2)
Multiplication of a double times a quaternion.
Definition quat.h:82
BASE_EXPORT void fromUnitAxes(const DVect2 &, const DVect2 &)
Definition quat.cpp:62
double & rang()
Access a reference to the angle.
Definition quat.h:39
BASE_EXPORT void incrementAxisAngle(const DVect2 &, const double &)
Increment by this rotation. In this case the axis is ignored.
Definition quat.cpp:49
constexpr Quat2 & operator=(const Quat2 &in)
Equals operator.
Definition quat.h:31
void conj()
Convert to the conjugate quaternion - rotation by the opposite sign.
Definition quat.h:71
void setQuat(const double &a)
Set the angle.
Definition quat.h:33
Quat2(const double &a)
Constructor initializing the angle.
Definition quat.h:25
static BASE_EXPORT Quat2 identity()
Return the identity quaternion.
Definition quat.h:46
Quat2(const Quat2 &q)
Copy constructor.
Definition quat.h:29
Quat2 getConj() const
Return the conjugate of the quaternion.
Definition quat.h:73
Quat2()
Default constructor.
Definition quat.h:23
static BASE_EXPORT Quat2 fromVect(const DVect2 &v)
Convert a DVect2 into a quaternion. This assumes a rotation from the positive x axis.
Definition quat.cpp:17
const double & ang() const
Access the angle.
Definition quat.h:36
BASE_EXPORT void fromMatrix(const DMatrix< 2, 2 > &)
Convert a matrix into a quaternion.
Definition quat.cpp:21
BASE_EXPORT void spinAboutZ(const double &)
Just spin about the Z axis.
Definition quat.cpp:53
BASE_EXPORT void increment(const DAVect2 &)
Increment the quaternion due to a rotation about Z by the DAVect.
Definition quat.cpp:66
~Quat2()
Destructor.
Definition quat.h:27
const Quat2 & operator/=(const double &d)
In place division by a double.
Definition quat.h:92
const Quat2 & operator*=(const double &d)
In place multiplaction by a double.
Definition quat.h:90
BASE_EXPORT void fromAxisAngle(const DVect2 &, const double &)
Definition quat.cpp:45
bool operator==(const Quat2 &v) const
Euality operator.
Definition quat.h:100
void reset()
Reset the angle to 0.
Definition quat.h:42
BASE_EXPORT DMatrix< 2, 2 > quatToMatrix() const
Convert the quaternion to a rotation matrix.
Definition quat.cpp:6
const Quat2 & operator+=(const Quat2 &v)
Definition quat.h:98
void normalize()
Normalize the quaternion.
Definition quat.h:75
BASE_EXPORT DVect2 rotate(const DVect2 &v) const
Rotate a DVect2 by the quaternian to get a new DVect2.
Definition quat.cpp:57
void ident()
Reset to the identity.
Definition quat.h:44
Quat2 operator/(const double &d) const
Division by a double.
Definition quat.h:80
3D quaternion utility class.
Definition quat.h:108
Quat3(const Quat3 &q)
Copy constructor.
Definition quat.h:118
BASE_EXPORT DVect3 rotate(const DVect3 &v) const
Rotate a DVect3 by the quaternian to get a new DVect3.
Definition quat.cpp:212
BASE_EXPORT void increment(const DAVect3 &)
Increment the quaternion due to a rotation about the x, y, and z axes by the DAVect.
Definition quat.cpp:248
const Quat3 & operator/=(const double &d)
In place division by a double.
Definition quat.h:215
constexpr const Quat3 & operator=(const Quat3 &q)
Equality operator.
Definition quat.h:120
const double & k() const
Access the third imaginary part.
Definition quat.h:131
Quat3 getConj() const
Return the conjugate of the quaternion.
Definition quat.h:193
void setQuat(const double &w1, const double &x, const double &y, const double &z)
Set the real and imaginary parts.
Definition quat.h:122
void conj()
Convert the quaternion to the conjugate.
Definition quat.h:191
double & rj()
Access a reference to the second imaginary part.
Definition quat.h:138
static BASE_EXPORT Quat3 fromVect(const DVect3 &v)
Convert a DVect3 into a quaternion.
Definition quat.cpp:119
Quat3 operator+(const Quat3 &v) const
Addition of two quaternions.
Definition quat.h:206
BASE_EXPORT void incrementAxisAngle(const DVect3 &, const double &)
Increment by this rotation.
Definition quat.cpp:194
double & rw()
Access a reference to the real part.
Definition quat.h:134
const Quat3 & operator+=(const Quat3 &v)
In place addition of two quaternions.
Definition quat.h:228
BASE_EXPORT DVect3 e1() const
Get component e1 of the rotation matrix.
Definition quat.cpp:252
~Quat3()
Default destructor.
Definition quat.h:116
BASE_EXPORT bool isNull() const
Returns a boolean indicating whether or not the quaternion is null.
Definition quat.h:149
BASE_EXPORT void fromEuler(const DVect3 &)
Definition quat.cpp:173
static BASE_EXPORT Quat3 identity()
Returns the identity quaternion.
Definition quat.h:147
const double & j() const
Access the second imaginary part.
Definition quat.h:129
BASE_EXPORT void fromUnitAxes(const DVect3 &, const DVect3 &)
Take 2 orthogonal axis for an axis system and convert to a quaternion.
Definition quat.cpp:218
void ident()
Reset the quaternion to the identity.
Definition quat.h:145
BASE_EXPORT DVect3 quatToAAngle() const
Convert to Axis Angle where the magnitude of the axis is the angle in radians.
Definition quat.cpp:98
double & rk()
Access a reference to the third imaginary part.
Definition quat.h:140
Quat3()
Default constructor.
Definition quat.h:111
BASE_EXPORT void spinAboutY(const double &)
Just spin about the Y axis.
Definition quat.cpp:204
friend Quat3 operator*(const double &d, const Quat3 &p2)
Product of a double and a quaternion.
Definition quat.h:202
BASE_EXPORT DVect3 e3() const
Get component e3 of the rotation matrix.
Definition quat.cpp:260
Quat3(const double &w1, const double &x, const double &y, const double &z)
Definition quat.h:114
const double & w() const
Access the real part.
Definition quat.h:125
BASE_EXPORT DVect3 e2() const
Get component e2 of the rotation matrix.
Definition quat.cpp:256
double & ri()
Access a reference to the first imaginary part.
Definition quat.h:136
BASE_EXPORT DVect3 real() const
Return the "real" vector part of the quaternian.
Definition quat.h:174
void reset()
Reset the quaternion.
Definition quat.h:143
BASE_EXPORT void spinAboutX(const double &)
Just spin about the X axis.
Definition quat.cpp:200
BASE_EXPORT void fromAxisAngle(const DVect3 &, const double &)
Take an axis-angle representation and convert it to a quaternion where the angle is in radians.
Definition quat.cpp:159
const double & i() const
Access the first imaginary part.
Definition quat.h:127
BASE_EXPORT DMatrix< 3, 3 > quatToMatrix() const
Convert the quaternion to a rotation matrix.
Definition quat.cpp:70
const Quat3 & operator*=(const double &d)
In place multiplaction by a double.
Definition quat.h:213
bool operator==(const Quat3 &v) const
Euality operator.
Definition quat.h:230
BASE_EXPORT void spinAboutZ(const double &)
Just spin about the Z axis.
Definition quat.cpp:208
BASE_EXPORT DVect3 quatToEuler() const
Definition quat.cpp:264
Quat3 operator/(const double &d) const
Division by a double.
Definition quat.h:200
BASE_EXPORT void fromMatrix(const DMatrix< 3, 3 > &)
Convert a matrix into a quaternion.
Definition quat.cpp:128
BASE_EXPORT void normalize()
Normalize the quaternion.
Definition quat.h:195
#define BASE_EXPORT
Definition basedef.h:24
A template-based matrix class, size fixed at compile time.
2D and 3D vector utility classes.