Loading...
Searching...
No Matches
dualQuath.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_DUALQUATH_H
29#define PXR_BASE_GF_DUALQUATH_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#include "pxr/base/gf/half.h"
39
40#include "pxr/base/gf/quath.h"
41#include "pxr/base/tf/hash.h"
42
43#include <iosfwd>
44
45PXR_NAMESPACE_OPEN_SCOPE
46
47template <>
48struct GfIsGfDualQuat<class GfDualQuath> { static const bool value = true; };
49
51GfHalf GfDot(const GfDualQuath& dq1, const GfDualQuath& dq2);
52
53
67class GfDualQuath final
68{
69 public:
70 typedef GfHalf ScalarType;
71
74
82 explicit GfDualQuath( GfHalf realVal ) : _real( realVal ), _dual( 0 ) {}
83
87 explicit GfDualQuath( const GfQuath &real )
88 : _real( real ), _dual( 0 ) {
89 }
90
92 GfDualQuath( const GfQuath &real, const GfQuath &dual )
93 : _real( real ), _dual( dual ) {
94 }
95
97 GfDualQuath( const GfQuath &rotation, const GfVec3h &translation )
98 : _real( rotation ) {
99 SetTranslation( translation );
100 }
101
103 GF_API
104 explicit GfDualQuath(const GfDualQuatd &other);
106 GF_API
107 explicit GfDualQuath(const GfDualQuatf &other);
108
110 void SetReal(const GfQuath &real) {
111 _real = real;
112 }
113
115 void SetDual(const GfQuath &dual) {
116 _dual = dual;
117 }
118
120 const GfQuath &GetReal() const {
121 return _real;
122 }
123
125 const GfQuath &GetDual() const {
126 return _dual;
127 }
128
133 }
134
139 }
140
142 GF_API
143 std::pair<GfHalf, GfHalf> GetLength() const;
144
148 GF_API
150
155 GF_API
156 std::pair<GfHalf, GfHalf> Normalize(GfHalf eps = GF_MIN_VECTOR_LENGTH);
157
159 GF_API
161
163 GF_API
165
167 GF_API
168 void SetTranslation( const GfVec3h &translation );
169
171 GF_API
173
175 friend inline size_t hash_value(const GfDualQuath &dq) {
176 return TfHash::Combine(dq.GetReal(), dq.GetDual());
177 }
178
181 bool operator ==(const GfDualQuath &dq) const {
182 return (GetReal() == dq.GetReal() &&
183 GetDual() == dq.GetDual());
184 }
185
188 bool operator !=(const GfDualQuath &dq) const {
189 return ! (*this == dq);
190 }
191
194 _real += dq._real;
195 _dual += dq._dual;
196 return *this;
197 }
198
201 _real -= dq._real;
202 _dual -= dq._dual;
203 return *this;
204 }
205
207 GF_API
209
212 _real *= s;
213 _dual *= s;
214 return *this;
215 }
216
219 return (*this) *= 1.0 / s;
220 }
221
224 const GfDualQuath &dq2) {
225 GfDualQuath dqt = dq1;
226 return dqt += dq2;
227 }
228
231 const GfDualQuath &dq2) {
232 GfDualQuath dqt = dq1;
233 return dqt -= dq2;
234 }
235
238 const GfDualQuath &dq2) {
239 GfDualQuath dqt = dq1;
240 return dqt *= dq2;
241 }
242
245 GfDualQuath dqt = dq;
246 return dqt *= s;
247 }
248
251 GfDualQuath dqt = dq;
252 return dqt *= s;
253 }
254
257 GfDualQuath dqt = dq;
258 return dqt /= s;
259 }
260
262 GF_API
263 GfVec3h Transform(const GfVec3h &vec) const;
264
265 private:
266 GfQuath _real; // for rotation
267 GfQuath _dual; // for translation
268};
269
270
273GF_API std::ostream &operator<<(std::ostream &out, const GfDualQuath &dq);
274
275
277inline GfHalf
278GfDot(const GfDualQuath& dq1, const GfDualQuath& dq2) {
279 return GfDot(dq1.GetReal(), dq2.GetReal()) + GfDot(dq1.GetDual(), dq2.GetDual());
280}
281
282PXR_NAMESPACE_CLOSE_SCOPE
283
284#endif // PXR_BASE_GF_DUALQUATH_H
Declares Gf types.
Basic type: a real part quaternion and a dual part quaternion.
Definition: dualQuatd.h:67
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
GF_API GfDualQuath GetConjugate() const
Returns the conjugate of this dual quaternion.
const GfQuath & GetDual() const
Returns the dual part of the dual quaternion.
Definition: dualQuath.h:125
GF_API GfDualQuath(const GfDualQuatf &other)
Construct from GfDualQuatf.
GF_API GfDualQuath GetInverse() const
Returns the inverse of this dual quaternion.
GF_API GfDualQuath & operator*=(const GfDualQuath &dq)
Post-multiplies dual quaternion dq into this dual quaternion.
friend GfDualQuath operator-(const GfDualQuath &dq1, const GfDualQuath &dq2)
Component-wise binary difference operator.
Definition: dualQuath.h:230
friend size_t hash_value(const GfDualQuath &dq)
Hash.
Definition: dualQuath.h:175
bool operator!=(const GfDualQuath &dq) const
Component-wise dual quaternion inequality test.
Definition: dualQuath.h:188
GfDualQuath()
The default constructor leaves the dual quaternion undefined.
Definition: dualQuath.h:73
GfDualQuath & operator-=(const GfDualQuath &dq)
Component-wise unary difference operator.
Definition: dualQuath.h:200
GF_API std::pair< GfHalf, GfHalf > GetLength() const
Returns geometric length of this dual quaternion.
GfDualQuath(const GfQuath &real, const GfQuath &dual)
This constructor initializes the real and dual parts.
Definition: dualQuath.h:92
GfDualQuath(const GfQuath &rotation, const GfVec3h &translation)
This constructor initializes from a rotation and a translation components.
Definition: dualQuath.h:97
GfDualQuath(const GfQuath &real)
Initialize the real part to real quaternion and the imaginary part to zero quaternion.
Definition: dualQuath.h:87
GF_API std::pair< GfHalf, GfHalf > Normalize(GfHalf eps=GF_MIN_VECTOR_LENGTH)
Normalizes this dual quaternion in place.
const GfQuath & GetReal() const
Returns the real part of the dual quaternion.
Definition: dualQuath.h:120
GfDualQuath(GfHalf realVal)
Initialize the real part to realVal and the imaginary part to zero quaternion.
Definition: dualQuath.h:82
void SetDual(const GfQuath &dual)
Sets the dual part of the dual quaternion.
Definition: dualQuath.h:115
GF_API GfDualQuath GetNormalized(GfHalf eps=GF_MIN_VECTOR_LENGTH) const
Returns a normalized (unit-length) version of this dual quaternion.
static GfDualQuath GetZero()
Returns the zero dual quaternion, which has a real part of (0,0,0,0) and a dual part of (0,...
Definition: dualQuath.h:131
friend GfDualQuath operator+(const GfDualQuath &dq1, const GfDualQuath &dq2)
Component-wise binary sum operator.
Definition: dualQuath.h:223
GF_API GfVec3h GetTranslation() const
Get the translation component of this dual quaternion.
GfDualQuath & operator+=(const GfDualQuath &dq)
Component-wise unary sum operator.
Definition: dualQuath.h:193
GF_API GfDualQuath(const GfDualQuatd &other)
Construct from GfDualQuatd.
friend GfDualQuath operator/(const GfDualQuath &dq, GfHalf s)
Returns the product of dual quaternion dq and scalar 1 / s.
Definition: dualQuath.h:256
GF_API GfVec3h Transform(const GfVec3h &vec) const
Transforms the row vector vec by the dual quaternion.
GfDualQuath & operator/=(GfHalf s)
Scales this dual quaternion by 1 / s.
Definition: dualQuath.h:218
bool operator==(const GfDualQuath &dq) const
Component-wise dual quaternion equality test.
Definition: dualQuath.h:181
void SetReal(const GfQuath &real)
Sets the real part of the dual quaternion.
Definition: dualQuath.h:110
friend GfDualQuath operator*(const GfDualQuath &dq1, const GfDualQuath &dq2)
Returns the product of dual quaternions dq1 and dq2.
Definition: dualQuath.h:237
GF_API void SetTranslation(const GfVec3h &translation)
Set the translation component of this dual quaternion.
static GfDualQuath GetIdentity()
Returns the identity dual quaternion, which has a real part of (1,0,0,0) and a dual part of (0,...
Definition: dualQuath.h:137
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
Definition: quath.h:61
static GfQuath GetZero()
Return the zero quaternion, with real coefficient 0 and an imaginary coefficients all zero.
Definition: quath.h:99
static GfQuath GetIdentity()
Return the identity quaternion, with real coefficient 1 and an imaginary coefficients all zero.
Definition: quath.h:103
Basic type for a vector of 3 GfHalf components.
Definition: vec3h.h:64
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
Definition: hash.h:492
GfHalf GfDot(const GfDualQuath &dq1, const GfDualQuath &dq2)
Return the dot (inner) product of two dual quaternions.
Definition: dualQuath.h:278
#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].
This header serves to simply bring in the half float datatype and provide a hash_value function.
pxr_half::half GfHalf
A 16-bit floating point data type.
Definition: half.h:41
A metafunction with a static const bool member 'value' that is true for GfDualQuat types and false fo...
Definition: traits.h:52