Loading...
Searching...
No Matches
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#include "pxr/base/tf/hash.h"
41
42#include <iosfwd>
43
44PXR_NAMESPACE_OPEN_SCOPE
45
46template <>
47struct GfIsGfDualQuat<class GfDualQuatd> { static const bool value = true; };
48
50double GfDot(const GfDualQuatd& dq1, const GfDualQuatd& dq2);
51
52
66class GfDualQuatd final
67{
68 public:
69 typedef double ScalarType;
70
73
81 explicit GfDualQuatd( double realVal ) : _real( realVal ), _dual( 0 ) {}
82
86 explicit GfDualQuatd( const GfQuatd &real )
87 : _real( real ), _dual( 0 ) {
88 }
89
91 GfDualQuatd( const GfQuatd &real, const GfQuatd &dual )
92 : _real( real ), _dual( dual ) {
93 }
94
96 GfDualQuatd( const GfQuatd &rotation, const GfVec3d &translation )
97 : _real( rotation ) {
98 SetTranslation( translation );
99 }
100
102 GF_API
105 GF_API
107
109 void SetReal(const GfQuatd &real) {
110 _real = real;
111 }
112
114 void SetDual(const GfQuatd &dual) {
115 _dual = dual;
116 }
117
119 const GfQuatd &GetReal() const {
120 return _real;
121 }
122
124 const GfQuatd &GetDual() const {
125 return _dual;
126 }
127
132 }
133
138 }
139
141 GF_API
142 std::pair<double, double> GetLength() const;
143
147 GF_API
149
154 GF_API
155 std::pair<double, double> Normalize(double eps = GF_MIN_VECTOR_LENGTH);
156
158 GF_API
160
162 GF_API
164
166 GF_API
167 void SetTranslation( const GfVec3d &translation );
168
170 GF_API
172
174 friend inline size_t hash_value(const GfDualQuatd &dq) {
175 return TfHash::Combine(dq.GetReal(), dq.GetDual());
176 }
177
180 bool operator ==(const GfDualQuatd &dq) const {
181 return (GetReal() == dq.GetReal() &&
182 GetDual() == dq.GetDual());
183 }
184
187 bool operator !=(const GfDualQuatd &dq) const {
188 return ! (*this == dq);
189 }
190
193 _real += dq._real;
194 _dual += dq._dual;
195 return *this;
196 }
197
200 _real -= dq._real;
201 _dual -= dq._dual;
202 return *this;
203 }
204
206 GF_API
208
211 _real *= s;
212 _dual *= s;
213 return *this;
214 }
215
218 return (*this) *= 1.0 / s;
219 }
220
223 const GfDualQuatd &dq2) {
224 GfDualQuatd dqt = dq1;
225 return dqt += dq2;
226 }
227
230 const GfDualQuatd &dq2) {
231 GfDualQuatd dqt = dq1;
232 return dqt -= dq2;
233 }
234
237 const GfDualQuatd &dq2) {
238 GfDualQuatd dqt = dq1;
239 return dqt *= dq2;
240 }
241
243 friend GfDualQuatd operator *(const GfDualQuatd &dq, double s) {
244 GfDualQuatd dqt = dq;
245 return dqt *= s;
246 }
247
249 friend GfDualQuatd operator *(double s, const GfDualQuatd &dq) {
250 GfDualQuatd dqt = dq;
251 return dqt *= s;
252 }
253
255 friend GfDualQuatd operator /(const GfDualQuatd &dq, double s) {
256 GfDualQuatd dqt = dq;
257 return dqt /= s;
258 }
259
261 GF_API
262 GfVec3d Transform(const GfVec3d &vec) const;
263
264 private:
265 GfQuatd _real; // for rotation
266 GfQuatd _dual; // for translation
267};
268
269
272GF_API std::ostream &operator<<(std::ostream &out, const GfDualQuatd &dq);
273
274
276inline double
277GfDot(const GfDualQuatd& dq1, const GfDualQuatd& dq2) {
278 return GfDot(dq1.GetReal(), dq2.GetReal()) + GfDot(dq1.GetDual(), dq2.GetDual());
279}
280
281PXR_NAMESPACE_CLOSE_SCOPE
282
283#endif // PXR_BASE_GF_DUALQUATD_H
Declares Gf types.
Basic type: a real part quaternion and a dual part quaternion.
Definition: dualQuatd.h:67
GF_API GfDualQuatd(const GfDualQuath &other)
Implicitly convert from GfDualQuath.
GF_API std::pair< double, double > GetLength() const
Returns geometric length of this dual quaternion.
GF_API std::pair< double, double > Normalize(double eps=GF_MIN_VECTOR_LENGTH)
Normalizes this dual quaternion in place.
GF_API GfDualQuatd GetConjugate() const
Returns the conjugate of this dual quaternion.
bool operator==(const GfDualQuatd &dq) const
Component-wise dual quaternion equality test.
Definition: dualQuatd.h:180
const GfQuatd & GetDual() const
Returns the dual part of the dual quaternion.
Definition: dualQuatd.h:124
GfDualQuatd & operator/=(double s)
Scales this dual quaternion by 1 / s.
Definition: dualQuatd.h:217
GF_API GfDualQuatd GetNormalized(double eps=GF_MIN_VECTOR_LENGTH) const
Returns a normalized (unit-length) version of this dual quaternion.
void SetReal(const GfQuatd &real)
Sets the real part of the dual quaternion.
Definition: dualQuatd.h:109
GfDualQuatd(const GfQuatd &real, const GfQuatd &dual)
This constructor initializes the real and dual parts.
Definition: dualQuatd.h:91
GfDualQuatd & operator-=(const GfDualQuatd &dq)
Component-wise unary difference operator.
Definition: dualQuatd.h:199
GfDualQuatd & operator+=(const GfDualQuatd &dq)
Component-wise unary sum operator.
Definition: dualQuatd.h:192
friend GfDualQuatd operator/(const GfDualQuatd &dq, double s)
Returns the product of dual quaternion dq and scalar 1 / s.
Definition: dualQuatd.h:255
GF_API GfVec3d GetTranslation() const
Get the translation component of this dual quaternion.
friend GfDualQuatd operator+(const GfDualQuatd &dq1, const GfDualQuatd &dq2)
Component-wise binary sum operator.
Definition: dualQuatd.h:222
GfDualQuatd(const GfQuatd &real)
Initialize the real part to real quaternion and the imaginary part to zero quaternion.
Definition: dualQuatd.h:86
GF_API GfDualQuatd GetInverse() const
Returns the inverse of this dual quaternion.
GF_API GfDualQuatd(const GfDualQuatf &other)
Implicitly convert from GfDualQuatf.
const GfQuatd & GetReal() const
Returns the real part of the dual quaternion.
Definition: dualQuatd.h:119
friend GfDualQuatd operator*(const GfDualQuatd &dq1, const GfDualQuatd &dq2)
Returns the product of dual quaternions dq1 and dq2.
Definition: dualQuatd.h:236
GfDualQuatd(const GfQuatd &rotation, const GfVec3d &translation)
This constructor initializes from a rotation and a translation components.
Definition: dualQuatd.h:96
GF_API GfDualQuatd & operator*=(const GfDualQuatd &dq)
Post-multiplies dual quaternion dq into 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:130
GF_API GfVec3d Transform(const GfVec3d &vec) const
Transforms the row vector vec by the dual quaternion.
GF_API void SetTranslation(const GfVec3d &translation)
Set the translation component of this dual quaternion.
bool operator!=(const GfDualQuatd &dq) const
Component-wise dual quaternion inequality test.
Definition: dualQuatd.h:187
GfDualQuatd(double realVal)
Initialize the real part to realVal and the imaginary part to zero quaternion.
Definition: dualQuatd.h:81
friend size_t hash_value(const GfDualQuatd &dq)
Hash.
Definition: dualQuatd.h:174
GfDualQuatd()
The default constructor leaves the dual quaternion undefined.
Definition: dualQuatd.h:72
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:136
void SetDual(const GfQuatd &dual)
Sets the dual part of the dual quaternion.
Definition: dualQuatd.h:114
friend GfDualQuatd operator-(const GfDualQuatd &dq1, const GfDualQuatd &dq2)
Component-wise binary difference operator.
Definition: dualQuatd.h:229
Basic type: a real part quaternion and a dual part quaternion.
Definition: dualQuatf.h:67
Basic type: a real part quaternion and a dual part quaternion.
Definition: dualQuath.h:68
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
Definition: quatd.h:60
static GfQuatd GetIdentity()
Return the identity quaternion, with real coefficient 1 and an imaginary coefficients all zero.
Definition: quatd.h:102
static GfQuatd GetZero()
Return the zero quaternion, with real coefficient 0 and an imaginary coefficients all zero.
Definition: quatd.h:98
Basic type for a vector of 3 double components.
Definition: vec3d.h:63
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
Definition: hash.h:492
double GfDot(const GfDualQuatd &dq1, const GfDualQuatd &dq2)
Return the dot (inner) product of two dual quaternions.
Definition: dualQuatd.h:277
#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
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
A metafunction with a static const bool member 'value' that is true for GfDualQuat types and false fo...
Definition: traits.h:52