Developer Documentation

DualQuaternionT.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42 //=============================================================================
43 //
44 // CLASS DualQuaternion
45 //
46 //=============================================================================
47
48 #ifndef ACG_DUALQUATERNION_HH
49 #define ACG_DUALQUATERNION_HH
50
51
52 //== INCLUDES =================================================================
53
54 #include "QuaternionT.hh"
55
56
57 //== NAMESPACES ==============================================================
58
59 namespace ACG {
60
61
62 //== CLASS DEFINITION =========================================================
63
64
79 template <class Scalar>
80 class DualQuaternionT
81 {
82 public:
83
84 typedef QuaternionT<Scalar> Quaternion;
85 typedef DualQuaternionT<Scalar> DualQuaternion;
86 typedef VectorT<Scalar,3> Vec3;
87 typedef VectorT<Scalar,4> Vec4;
88 typedef Matrix4x4T<Scalar> Matrix;
89
91 Quaternion real_;
92 Quaternion dual_;
93
94
95 // Constructors
96 //
97
99 DualQuaternionT();
100
102 DualQuaternionT(const DualQuaternion& _other);
103
105 DualQuaternionT(const Quaternion& _real, const Quaternion& _dual);
106
108 DualQuaternionT(Scalar _Rw, Scalar _Rx, Scalar _Ry, Scalar _Rz,
109 Scalar _Dw, Scalar _Dx, Scalar _Dy, Scalar _Dz);
110
112 DualQuaternionT(Quaternion _rotation);
113
115 DualQuaternionT(const Vec3& _translation);
116
118 DualQuaternionT(const Vec3& _translation, const Quaternion& _rotation);
119
121 DualQuaternionT(const Matrix& _transformation);
122
123 // default quaternions
124
126 static DualQuaternion identity();
127
129 static DualQuaternion zero();
130
131 // Operators
132 //
133
135 DualQuaternion conjugate() const;
136
138 DualQuaternion invert() const;
139
141 void normalize();
142
144 bool operator==(const DualQuaternion& _other) const;
145 bool operator!=(const DualQuaternion& _other) const;
146
148 DualQuaternion operator+(const DualQuaternion& _other) const;
149 DualQuaternion& operator+=(const DualQuaternion& _other);
150
152 DualQuaternion operator-(const DualQuaternion& _other) const;
153 DualQuaternion& operator-=(const DualQuaternion& _other);
154
156 DualQuaternion operator*(const DualQuaternion& _q) const;
157
159 DualQuaternion operator*(const Scalar& _scalar) const;
160
162 DualQuaternion& operator*=(const DualQuaternion& _q);
163
165 Scalar& operator [](const unsigned int& b);
166
168 template <typename VectorType>
169 static DualQuaternion interpolate(VectorType& _weights, const std::vector<DualQuaternion>& _dualQuaternions);
170
172 Vec3 transform_point(const Vec3& _point) const;
173
175 Vec3 transform_vector(const Vec3& _point) const;
176
178 void printInfo();
179
180 };
181
182
183 typedef DualQuaternionT<float> DualQuaternionf;
184 typedef DualQuaternionT<double> DualQuaterniond;
185
186
187 //=============================================================================
188 } // namespace ACG
189 //=============================================================================
190 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_DUALQUATERNIONT_C)
191 #define ACG_QUATERNIONT_TEMPLATES
192 #include "DualQuaternionT_impl.hh"
193 #endif
194 //=============================================================================
195 #endif // ACG_DUALQUATERNION_HH defined
196 //=============================================================================
197
ACG
Namespace providing different geometric functions concerning angles.
Definition: BaseObjectData.hh:68
ACG::DualQuaternionT::operator!=
bool operator!=(const DualQuaternion &_other) const
dual quaternion comparison
Definition: DualQuaternionT_impl.hh:231
ACG::DualQuaternionT::real_
Quaternion real_
real and dual quaternion parts
Definition: DualQuaternionT.hh:91
ACG::DualQuaternionT::printInfo
void printInfo()
print some info about the DQ
Definition: DualQuaternionT_impl.hh:416
ACG::DualQuaternionT::normalize
void normalize()
normalize dual quaternion
Definition: DualQuaternionT_impl.hh:205
ACG::DualQuaternionT::operator-=
DualQuaternion & operator-=(const DualQuaternion &_other)
substraction
Definition: DualQuaternionT_impl.hh:266
ACG::DualQuaternionT::operator-
DualQuaternion operator-(const DualQuaternion &_other) const
substraction
Definition: DualQuaternionT_impl.hh:258
ACG::DualQuaternionT::conjugate
DualQuaternion conjugate() const
conjugate dual quaternion
Definition: DualQuaternionT_impl.hh:172
ACG::DualQuaternionT::invert
DualQuaternion invert() const
invert dual quaternion
Definition: DualQuaternionT_impl.hh:180
ACG::QuaternionT
Definition: QuaternionT.hh:75
ACG::DualQuaternionT::operator*
DualQuaternion operator*(const DualQuaternion &_q) const
dualQuaternion * dualQuaternion
Definition: DualQuaternionT_impl.hh:277
ACG::DualQuaternionT::transform_vector
Vec3 transform_vector(const Vec3 &_point) const
Transform a vector with the dual quaternion.
Definition: DualQuaternionT_impl.hh:395
ACG::DualQuaternionT::operator+=
DualQuaternion & operator+=(const DualQuaternion &_other)
addition
Definition: DualQuaternionT_impl.hh:247
ACG::DualQuaternionT::operator*=
DualQuaternion & operator*=(const DualQuaternion &_q)
dualQuaternion *= dualQuaternion
Definition: DualQuaternionT_impl.hh:285
ACG::DualQuaternionT::interpolate
static DualQuaternion interpolate(VectorType &_weights, const std::vector< DualQuaternion > &_dualQuaternions)
linear interpolation of dual quaternions. Result is normalized afterwards
ACG::Matrix4x4T
Definition: Matrix4x4T.hh:92
ACG::DualQuaternionT::operator+
DualQuaternion operator+(const DualQuaternion &_other) const
addition
Definition: DualQuaternionT_impl.hh:239
ACG::DualQuaternionT
DualQuaternion class for representing rigid motions in 3d.
Definition: DualQuaternionT.hh:80
ACG::DualQuaternionT::DualQuaternionT
DualQuaternionT()
Default constructor ( constructs an identity dual quaternion )
Definition: DualQuaternionT_impl.hh:69
ACG::DualQuaternionT::operator==
bool operator==(const DualQuaternion &_other) const
dual quaternion comparison
Definition: DualQuaternionT_impl.hh:223
OpenMesh::VectorT
Definition: Vector11T.hh:83
ACG::DualQuaternionT::zero
static DualQuaternion zero()
zero dual quaternion [ R(0, 0, 0, 0), D(0,0,0,0) ]
Definition: DualQuaternionT_impl.hh:160
ACG::DualQuaternionT::identity
static DualQuaternion identity()
identity dual quaternion [ R(1, 0, 0, 0), D(0,0,0,0) ]
Definition: DualQuaternionT_impl.hh:146
ACG::DualQuaternionT::transform_point
Vec3 transform_point(const Vec3 &_point) const
Transform a point with the dual quaternion.
Definition: DualQuaternionT_impl.hh:366
ACG::DualQuaternionT::operator[]
Scalar & operator[](const unsigned int &b)
Access as one big vector.
Definition: DualQuaternionT_impl.hh:308