Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  * $Revision: 9595 $ *
45  * $Author: wilden $ *
46  * $Date: 2010-06-17 12:48:23 +0200 (Thu, 17 Jun 2010) $ *
47  * *
48 \*===========================================================================*/
49 
50 
51 
52 //=============================================================================
53 //
54 // CLASS DualQuaternion
55 //
56 //=============================================================================
57 
58 #ifndef ACG_DUALQUATERNION_HH
59 #define ACG_DUALQUATERNION_HH
60 
61 
62 //== INCLUDES =================================================================
63 
64 #include "QuaternionT.hh"
65 
66 
67 //== NAMESPACES ==============================================================
68 
69 namespace ACG {
70 
71 
72 //== CLASS DEFINITION =========================================================
73 
74 
89 template <class Scalar>
91 {
92 public:
93 
96  typedef VectorT<Scalar,3> Vec3;
97  typedef VectorT<Scalar,4> Vec4;
98  typedef Matrix4x4T<Scalar> Matrix;
99 
101  Quaternion real_;
102  Quaternion dual_;
103 
104 
105  // Constructors
106  //
107 
109  DualQuaternionT();
110 
112  DualQuaternionT(const DualQuaternion& _other);
113 
115  DualQuaternionT(const Quaternion& _real, const Quaternion& _dual);
116 
118  DualQuaternionT(Scalar _Rw, Scalar _Rx, Scalar _Ry, Scalar _Rz,
119  Scalar _Dw, Scalar _Dx, Scalar _Dy, Scalar _Dz);
120 
122  DualQuaternionT(Quaternion _rotation);
123 
125  DualQuaternionT(const Vec3& _translation);
126 
128  DualQuaternionT(const Vec3& _translation, const Quaternion& _rotation);
129 
131  DualQuaternionT(const Matrix& _transformation);
132 
133  // default quaternions
134 
136  static DualQuaternion identity();
137 
139  static DualQuaternion zero();
140 
141  // Operators
142  //
143 
145  DualQuaternion conjugate() const;
146 
148  DualQuaternion invert() const;
149 
151  void normalize();
152 
154  bool operator==(const DualQuaternion& _other) const;
155  bool operator!=(const DualQuaternion& _other) const;
156 
158  DualQuaternion operator+(const DualQuaternion& _other) const;
159  DualQuaternion& operator+=(const DualQuaternion& _other);
160 
162  DualQuaternion operator-(const DualQuaternion& _other) const;
163  DualQuaternion& operator-=(const DualQuaternion& _other);
164 
166  DualQuaternion operator*(const DualQuaternion& _q) const;
167 
169  DualQuaternion operator*(const Scalar& _scalar) const;
170 
172  DualQuaternion& operator*=(const DualQuaternion& _q);
173 
175  Scalar& operator [](const unsigned int& b);
176 
178  template <typename VectorType>
179  static DualQuaternion interpolate(VectorType& _weights, const std::vector<DualQuaternion>& _dualQuaternions);
180 
182  Vec3 transform_point(const Vec3& _point) const;
183 
185  Vec3 transform_vector(const Vec3& _point) const;
186 
188  void printInfo();
189 
190 };
191 
192 
195 
196 
197 //=============================================================================
198 } // namespace ACG
199 //=============================================================================
200 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_DUALQUATERNIONT_C)
201 #define ACG_QUATERNIONT_TEMPLATES
202 #include "DualQuaternionT.cc"
203 #endif
204 //=============================================================================
205 #endif // ACG_DUALQUATERNION_HH defined
206 //=============================================================================
207 
bool operator!=(const DualQuaternion &_other) const
dual quaternion comparison
DualQuaternionT()
Default constructor ( constructs an identity dual quaternion )
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
DualQuaternion & operator*=(const DualQuaternion &_q)
dualQuaternion *= dualQuaternion
DualQuaternion conjugate() const
conjugate dual quaternion
void printInfo()
print some info about the DQ
Quaternion real_
real and dual quaternion parts
void normalize()
normalize dual quaternion
DualQuaternion & operator-=(const DualQuaternion &_other)
substraction
Vec3 transform_point(const Vec3 &_point) const
Transform a point with the dual quaternion.
static DualQuaternion interpolate(VectorType &_weights, const std::vector< DualQuaternion > &_dualQuaternions)
linear interpolation of dual quaternions. Result is normalized afterwards
DualQuaternion class for representing rigid motions in 3d.
DualQuaternion operator-(const DualQuaternion &_other) const
substraction
static DualQuaternion zero()
zero dual quaternion [ R(0, 0, 0, 0), D(0,0,0,0) ]
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.
static DualQuaternion identity()
identity dual quaternion [ R(1, 0, 0, 0), D(0,0,0,0) ]
DualQuaternion & operator+=(const DualQuaternion &_other)
addition
bool operator==(const DualQuaternion &_other) const
dual quaternion comparison
DualQuaternion operator*(const DualQuaternion &_q) const
dualQuaternion * dualQuaternion
DualQuaternion operator+(const DualQuaternion &_other) const
addition
DualQuaternion invert() const
invert dual quaternion