dualQuatd.h
Go to the documentation of this file.
1 //
2 // Copyright 2021 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
25 // This file is generated by a script. Do not edit directly. Edit the
26 // dualQuat.template.h file to make changes.
27 
28 #ifndef PXR_BASE_GF_DUALQUATD_H
29 #define PXR_BASE_GF_DUALQUATD_H
30 
33 
34 #include "pxr/pxr.h"
35 #include "pxr/base/gf/api.h"
36 #include "pxr/base/gf/declare.h"
37 #include "pxr/base/gf/traits.h"
38 
39 #include "pxr/base/gf/quatd.h"
40 
41 #include <boost/functional/hash.hpp>
42 
43 #include <iosfwd>
44 
45 PXR_NAMESPACE_OPEN_SCOPE
46 
47 template <>
48 struct GfIsGfDualQuat<class GfDualQuatd> { static const bool value = true; };
49 
51 double GfDot(const GfDualQuatd& dq1, const GfDualQuatd& dq2);
52 
53 
67 class GfDualQuatd final
68 {
69  public:
70  typedef double ScalarType;
71 
74 
82  explicit GfDualQuatd( double realVal ) : _real( realVal ), _dual( 0 ) {}
83 
87  explicit GfDualQuatd( const GfQuatd &real )
88  : _real( real ), _dual( 0 ) {
89  }
90 
92  GfDualQuatd( const GfQuatd &real, const GfQuatd &dual )
93  : _real( real ), _dual( dual ) {
94  }
95 
97  GfDualQuatd( const GfQuatd &rotation, const GfVec3d &translation )
98  : _real( rotation ) {
99  SetTranslation( translation );
100  }
101 
103  GF_API
104  GfDualQuatd(const GfDualQuatf &other);
106  GF_API
107  GfDualQuatd(const GfDualQuath &other);
108 
110  void SetReal(const GfQuatd &real) {
111  _real = real;
112  }
113 
115  void SetDual(const GfQuatd &dual) {
116  _dual = dual;
117  }
118 
120  const GfQuatd &GetReal() const {
121  return _real;
122  }
123 
125  const GfQuatd &GetDual() const {
126  return _dual;
127  }
128 
131  static GfDualQuatd GetZero() {
133  }
134 
139  }
140 
142  GF_API
143  std::pair<double, double> GetLength() const;
144 
148  GF_API
149  GfDualQuatd GetNormalized(double eps = GF_MIN_VECTOR_LENGTH) const;
150 
155  GF_API
156  std::pair<double, double> Normalize(double eps = GF_MIN_VECTOR_LENGTH);
157 
159  GF_API
160  GfDualQuatd GetConjugate() const;
161 
163  GF_API
164  GfDualQuatd GetInverse() const;
165 
167  GF_API
168  void SetTranslation( const GfVec3d &translation );
169 
171  GF_API
172  GfVec3d GetTranslation() const;
173 
175  friend inline size_t hash_value(const GfDualQuatd &dq) {
176  size_t h = 0;
177  boost::hash_combine(h, dq.GetReal());
178  boost::hash_combine(h, dq.GetDual());
179  return h;
180  }
181 
184  bool operator ==(const GfDualQuatd &dq) const {
185  return (GetReal() == dq.GetReal() &&
186  GetDual() == dq.GetDual());
187  }
188 
191  bool operator !=(const GfDualQuatd &dq) const {
192  return ! (*this == dq);
193  }
194 
197  _real += dq._real;
198  _dual += dq._dual;
199  return *this;
200  }
201 
204  _real -= dq._real;
205  _dual -= dq._dual;
206  return *this;
207  }
208 
210  GF_API
211  GfDualQuatd &operator *=(const GfDualQuatd &dq);
212 
215  _real *= s;
216  _dual *= s;
217  return *this;
218  }
219 
222  return (*this) *= 1.0 / s;
223  }
224 
226  friend GfDualQuatd operator +(const GfDualQuatd &dq1,
227  const GfDualQuatd &dq2) {
228  GfDualQuatd dqt = dq1;
229  return dqt += dq2;
230  }
231 
233  friend GfDualQuatd operator -(const GfDualQuatd &dq1,
234  const GfDualQuatd &dq2) {
235  GfDualQuatd dqt = dq1;
236  return dqt -= dq2;
237  }
238 
240  friend GfDualQuatd operator *(const GfDualQuatd &dq1,
241  const GfDualQuatd &dq2) {
242  GfDualQuatd dqt = dq1;
243  return dqt *= dq2;
244  }
245 
247  friend GfDualQuatd operator *(const GfDualQuatd &dq, double s) {
248  GfDualQuatd dqt = dq;
249  return dqt *= s;
250  }
251 
253  friend GfDualQuatd operator *(double s, const GfDualQuatd &dq) {
254  GfDualQuatd dqt = dq;
255  return dqt *= s;
256  }
257 
259  friend GfDualQuatd operator /(const GfDualQuatd &dq, double s) {
260  GfDualQuatd dqt = dq;
261  return dqt /= s;
262  }
263 
265  GF_API
266  GfVec3d Transform(const GfVec3d &vec) const;
267 
268  private:
269  GfQuatd _real; // for rotation
270  GfQuatd _dual; // for translation
271 };
272 
273 
276 GF_API std::ostream &operator<<(std::ostream &out, const GfDualQuatd &dq);
277 
278 
280 inline double
281 GfDot(const GfDualQuatd& dq1, const GfDualQuatd& dq2) {
282  return GfDot(dq1.GetReal(), dq2.GetReal()) + GfDot(dq1.GetDual(), dq2.GetDual());
283 }
284 
285 PXR_NAMESPACE_CLOSE_SCOPE
286 
287 #endif // PXR_BASE_GF_DUALQUATD_H
friend size_t hash_value(const GfDualQuatd &dq)
Hash.
Definition: dualQuatd.h:175
friend GfDualQuatd operator/(const GfDualQuatd &dq, double s)
Returns the product of dual quaternion dq and scalar 1 / s.
Definition: dualQuatd.h:259
Basic type: a real part quaternion and a dual part quaternion.
Definition: dualQuatd.h:67
static GfDualQuatd GetIdentity()
Returns the identity dual quaternion, which has a real part of (1,0,0,0) and a dual part of (0,...
Definition: dualQuatd.h:137
GfDualQuatd(const GfQuatd &rotation, const GfVec3d &translation)
This constructor initializes from a rotation and a translation components.
Definition: dualQuatd.h:97
friend GfDualQuatd operator *(double s, const GfDualQuatd &dq)
Returns the product of dual quaternion dq and scalar s.
Definition: dualQuatd.h:253
GfDualQuatd(const GfQuatd &real, const GfQuatd &dual)
This constructor initializes the real and dual parts.
Definition: dualQuatd.h:92
GF_API GfVec3d GetTranslation() const
Get the translation component of this dual quaternion.
A metafunction with a static const bool member 'value' that is true for GfDualQuat types and false fo...
Definition: traits.h:52
Declares Gf types.
friend GfDualQuatd operator *(const GfDualQuatd &dq1, const GfDualQuatd &dq2)
Returns the product of dual quaternions dq1 and dq2.
Definition: dualQuatd.h:240
GfDualQuatd()
The default constructor leaves the dual quaternion undefined.
Definition: dualQuatd.h:73
friend GfDualQuatd operator+(const GfDualQuatd &dq1, const GfDualQuatd &dq2)
Component-wise binary sum operator.
Definition: dualQuatd.h:226
static GfQuatd GetZero()
Return the zero quaternion, with real coefficient 0 and an imaginary coefficients all zero.
Definition: quatd.h:99
bool operator==(const GfDualQuatd &dq) const
Component-wise dual quaternion equality test.
Definition: dualQuatd.h:184
bool operator !=(const GfDualQuatd &dq) const
Component-wise dual quaternion inequality test.
Definition: dualQuatd.h:191
const GfQuatd & GetReal() const
Returns the real part of the dual quaternion.
Definition: dualQuatd.h:120
GF_API std::pair< double, double > GetLength() const
Returns geometric length of this dual quaternion.
static GfQuatd GetIdentity()
Return the identity quaternion, with real coefficient 1 and an imaginary coefficients all zero.
Definition: quatd.h:103
GF_API GfDualQuatd & operator *=(const GfDualQuatd &dq)
Post-multiplies dual quaternion dq into this dual quaternion.
GF_API GfDualQuatd GetNormalized(double eps=GF_MIN_VECTOR_LENGTH) const
Returns a normalized (unit-length) version of this dual quaternion.
GfDualQuatd & operator+=(const GfDualQuatd &dq)
Component-wise unary sum operator.
Definition: dualQuatd.h:196
Basic type: a real part quaternion and a dual part quaternion.
Definition: dualQuatf.h:67
GfDualQuatd & operator *=(double s)
Scales this dual quaternion by s.
Definition: dualQuatd.h:214
friend GfDualQuatd operator -(const GfDualQuatd &dq1, const GfDualQuatd &dq2)
Component-wise binary difference operator.
Definition: dualQuatd.h:233
const GfQuatd & GetDual() const
Returns the dual part of the dual quaternion.
Definition: dualQuatd.h:125
void SetDual(const GfQuatd &dual)
Sets the dual part of the dual quaternion.
Definition: dualQuatd.h:115
GF_API GfDualQuatd GetConjugate() const
Returns the conjugate of this dual quaternion.
GF_API std::ostream & operator<<(std::ostream &out, const GfDualQuatd &dq)
Output a GfDualQuatd using the format ((rw, rx, ry, rz), (dw, dx, dy, dz)).
friend GfDualQuatd operator *(const GfDualQuatd &dq, double s)
Returns the product of dual quaternion dq and scalar s.
Definition: dualQuatd.h:247
double GfDot(const GfDualQuatd &dq1, const GfDualQuatd &dq2)
Return the dot (inner) product of two dual quaternions.
Definition: dualQuatd.h:281
GF_API void SetTranslation(const GfVec3d &translation)
Set the translation component of this dual quaternion.
GF_API GfDualQuatd GetInverse() const
Returns the inverse of this dual quaternion.
static GfDualQuatd GetZero()
Returns the zero dual quaternion, which has a real part of (0,0,0,0) and a dual part of (0,...
Definition: dualQuatd.h:131
GfDualQuatd(double realVal)
Initialize the real part to realVal and the imaginary part to zero quaternion.
Definition: dualQuatd.h:82
GF_API std::pair< double, double > Normalize(double eps=GF_MIN_VECTOR_LENGTH)
Normalizes this dual quaternion in place.
Basic type for a vector of 3 double components.
Definition: vec3d.h:63
GfDualQuatd(const GfQuatd &real)
Initialize the real part to real quaternion and the imaginary part to zero quaternion.
Definition: dualQuatd.h:87
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
Definition: quatd.h:60
GF_API GfVec3d Transform(const GfVec3d &vec) const
Transforms the row vector vec by the dual quaternion.
GfDualQuatd & operator -=(const GfDualQuatd &dq)
Component-wise unary difference operator.
Definition: dualQuatd.h:203
Basic type: a real part quaternion and a dual part quaternion.
Definition: dualQuath.h:68
void SetReal(const GfQuatd &real)
Sets the real part of the dual quaternion.
Definition: dualQuatd.h:110
#define GF_MIN_VECTOR_LENGTH
This constant is used to determine whether the length of a vector is too small to handle accurately.
Definition: limits.h:34
GfDualQuatd & operator/=(double s)
Scales this dual quaternion by 1 / s.
Definition: dualQuatd.h:221