Developer Documentation
Loading...
Searching...
No Matches
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
59namespace ACG {
60
61
62//== CLASS DEFINITION =========================================================
63
64
79template <class Scalar>
81{
82public:
83
86 typedef VectorT<Scalar,3> Vec3;
87 typedef VectorT<Scalar,4> Vec4;
89
92 Quaternion dual_;
93
94
95 // Constructors
96 //
97
100
102 DualQuaternionT(const DualQuaternion& _other);
103
104 DualQuaternion& operator=(const DualQuaternion& _other);
105
107 DualQuaternionT(const Quaternion& _real, const Quaternion& _dual);
108
110 DualQuaternionT(Scalar _Rw, Scalar _Rx, Scalar _Ry, Scalar _Rz,
111 Scalar _Dw, Scalar _Dx, Scalar _Dy, Scalar _Dz);
112
114 DualQuaternionT(Quaternion _rotation);
115
117 DualQuaternionT(const Vec3& _translation);
118
120 DualQuaternionT(const Vec3& _translation, const Quaternion& _rotation);
121
123 DualQuaternionT(const Matrix& _transformation);
124
125 // default quaternions
126
128 static DualQuaternion identity();
129
131 static DualQuaternion zero();
132
133 // Operators
134 //
135
138
140 DualQuaternion invert() const;
141
143 void normalize();
144
146 bool operator==(const DualQuaternion& _other) const;
147 bool operator!=(const DualQuaternion& _other) const;
148
150 DualQuaternion operator+(const DualQuaternion& _other) const;
152
154 DualQuaternion operator-(const DualQuaternion& _other) const;
156
158 DualQuaternion operator*(const DualQuaternion& _q) const;
159
161 DualQuaternion operator*(const Scalar& _scalar) const;
162
165
167 Scalar& operator [](const unsigned int& b);
168
170 template <typename VectorType>
171 static DualQuaternion interpolate(VectorType& _weights, const std::vector<DualQuaternion>& _dualQuaternions);
172
174 Vec3 transform_point(const Vec3& _point) const;
175
177 Vec3 transform_vector(const Vec3& _point) const;
178
180 void printInfo();
181
182};
183
184
187
188
189//=============================================================================
190} // namespace ACG
191//=============================================================================
192#if defined(INCLUDE_TEMPLATES) && !defined(ACG_DUALQUATERNIONT_C)
193#define ACG_QUATERNIONT_TEMPLATES
194#include "DualQuaternionT_impl.hh"
195#endif
196//=============================================================================
197#endif // ACG_DUALQUATERNION_HH defined
198//=============================================================================
199
DualQuaternion class for representing rigid motions in 3d.
DualQuaternion operator*(const DualQuaternion &_q) const
dualQuaternion * dualQuaternion
static DualQuaternion interpolate(VectorType &_weights, const std::vector< DualQuaternion > &_dualQuaternions)
linear interpolation of dual quaternions. Result is normalized afterwards
DualQuaternion & operator-=(const DualQuaternion &_other)
substraction
DualQuaternion invert() const
invert dual quaternion
Vec3 transform_point(const Vec3 &_point) const
Transform a point with the dual quaternion.
Quaternion real_
real and dual quaternion parts
static DualQuaternion identity()
identity dual quaternion [ R(1, 0, 0, 0), D(0,0,0,0) ]
DualQuaternion conjugate() const
conjugate dual quaternion
DualQuaternion operator-(const DualQuaternion &_other) const
substraction
Vec3 transform_vector(const Vec3 &_point) const
Transform a vector with the dual quaternion.
DualQuaternion & operator*=(const DualQuaternion &_q)
dualQuaternion *= dualQuaternion
void normalize()
normalize dual quaternion
void printInfo()
print some info about the DQ
static DualQuaternion zero()
zero dual quaternion [ R(0, 0, 0, 0), D(0,0,0,0) ]
DualQuaternion operator+(const DualQuaternion &_other) const
addition
bool operator!=(const DualQuaternion &_other) const
dual quaternion comparison
DualQuaternion & operator+=(const DualQuaternion &_other)
addition
bool operator==(const DualQuaternion &_other) const
dual quaternion comparison
Scalar & operator[](const unsigned int &b)
Access as one big vector.
DualQuaternionT()
Default constructor ( constructs an identity dual quaternion )
Namespace providing different geometric functions concerning angles.