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>
81 {
82 public:
83 
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 
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 
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 
void normalize()
normalize dual quaternion
static DualQuaternion zero()
zero dual quaternion [ R(0, 0, 0, 0), D(0,0,0,0) ]
Namespace providing different geometric functions concerning angles.
Vec3 transform_point(const Vec3 &_point) const
Transform a point with the dual quaternion.
DualQuaternion conjugate() const
conjugate dual quaternion
bool operator!=(const DualQuaternion &_other) const
dual quaternion comparison
DualQuaternion class for representing rigid motions in 3d.
Quaternion real_
real and dual quaternion parts
static DualQuaternion identity()
identity dual quaternion [ R(1, 0, 0, 0), D(0,0,0,0) ]
DualQuaternion invert() const
invert dual quaternion
DualQuaternion operator+(const DualQuaternion &_other) const
addition
DualQuaternion & operator*=(const DualQuaternion &_q)
dualQuaternion *= dualQuaternion
bool operator==(const DualQuaternion &_other) const
dual quaternion comparison
DualQuaternion & operator-=(const DualQuaternion &_other)
substraction
static DualQuaternion interpolate(VectorType &_weights, const std::vector< DualQuaternion > &_dualQuaternions)
linear interpolation of dual quaternions. Result is normalized afterwards
DualQuaternion operator-(const DualQuaternion &_other) const
substraction
DualQuaternion & operator+=(const DualQuaternion &_other)
addition
DualQuaternion operator*(const DualQuaternion &_q) const
dualQuaternion * dualQuaternion
void printInfo()
print some info about the DQ
Vec3 transform_vector(const Vec3 &_point) const
Transform a vector with the dual quaternion.
Scalar & operator[](const unsigned int &b)
Access as one big vector.
DualQuaternionT()
Default constructor ( constructs an identity dual quaternion )