Loading...
Searching...
No Matches
dualQuatf.h
Go to the documentation of this file.
1//
2// Copyright 2021 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
8// This file is generated by a script. Do not edit directly. Edit the
9// dualQuat.template.h file to make changes.
10
11#ifndef PXR_BASE_GF_DUALQUATF_H
12#define PXR_BASE_GF_DUALQUATF_H
13
16
17#include "pxr/pxr.h"
18#include "pxr/base/gf/api.h"
19#include "pxr/base/gf/declare.h"
20#include "pxr/base/gf/traits.h"
21
22#include "pxr/base/gf/quatf.h"
23#include "pxr/base/tf/hash.h"
24
25#include <iosfwd>
26
27PXR_NAMESPACE_OPEN_SCOPE
28
29template <>
30struct GfIsGfDualQuat<class GfDualQuatf> { static const bool value = true; };
31
33float GfDot(const GfDualQuatf& dq1, const GfDualQuatf& dq2);
34
35
49class GfDualQuatf final
50{
51 public:
52 typedef float ScalarType;
53
56 GfDualQuatf() = default;
57
65 explicit GfDualQuatf( float realVal ) : _real( realVal ), _dual( 0 ) {}
66
70 explicit GfDualQuatf( const GfQuatf &real )
71 : _real( real ), _dual( 0 ) {
72 }
73
75 GfDualQuatf( const GfQuatf &real, const GfQuatf &dual )
76 : _real( real ), _dual( dual ) {
77 }
78
80 GfDualQuatf( const GfQuatf &rotation, const GfVec3f &translation )
81 : _real( rotation ) {
82 SetTranslation( translation );
83 }
84
86 GF_API
87 explicit GfDualQuatf(const GfDualQuatd &other);
89 GF_API
90 GfDualQuatf(const GfDualQuath &other);
91
93 void SetReal(const GfQuatf &real) {
94 _real = real;
95 }
96
98 void SetDual(const GfQuatf &dual) {
99 _dual = dual;
100 }
101
103 const GfQuatf &GetReal() const {
104 return _real;
105 }
106
108 const GfQuatf &GetDual() const {
109 return _dual;
110 }
111
116 }
117
122 }
123
125 GF_API
126 std::pair<float, float> GetLength() const;
127
131 GF_API
133
138 GF_API
139 std::pair<float, float> Normalize(float eps = GF_MIN_VECTOR_LENGTH);
140
142 GF_API
144
146 GF_API
148
150 GF_API
151 void SetTranslation( const GfVec3f &translation );
152
154 GF_API
156
158 friend inline size_t hash_value(const GfDualQuatf &dq) {
159 return TfHash::Combine(dq.GetReal(), dq.GetDual());
160 }
161
164 bool operator ==(const GfDualQuatf &dq) const {
165 return (GetReal() == dq.GetReal() &&
166 GetDual() == dq.GetDual());
167 }
168
171 bool operator !=(const GfDualQuatf &dq) const {
172 return ! (*this == dq);
173 }
174
177 _real += dq._real;
178 _dual += dq._dual;
179 return *this;
180 }
181
184 _real -= dq._real;
185 _dual -= dq._dual;
186 return *this;
187 }
188
190 GF_API
192
195 _real *= s;
196 _dual *= s;
197 return *this;
198 }
199
202 return (*this) *= 1.0 / s;
203 }
204
207 const GfDualQuatf &dq2) {
208 GfDualQuatf dqt = dq1;
209 return dqt += dq2;
210 }
211
214 const GfDualQuatf &dq2) {
215 GfDualQuatf dqt = dq1;
216 return dqt -= dq2;
217 }
218
221 const GfDualQuatf &dq2) {
222 GfDualQuatf dqt = dq1;
223 return dqt *= dq2;
224 }
225
227 friend GfDualQuatf operator *(const GfDualQuatf &dq, float s) {
228 GfDualQuatf dqt = dq;
229 return dqt *= s;
230 }
231
233 friend GfDualQuatf operator *(float s, const GfDualQuatf &dq) {
234 GfDualQuatf dqt = dq;
235 return dqt *= s;
236 }
237
239 friend GfDualQuatf operator /(const GfDualQuatf &dq, float s) {
240 GfDualQuatf dqt = dq;
241 return dqt /= s;
242 }
243
245 GF_API
246 GfVec3f Transform(const GfVec3f &vec) const;
247
248 private:
249 GfQuatf _real; // for rotation
250 GfQuatf _dual; // for translation
251};
252
253
256GF_API std::ostream &operator<<(std::ostream &out, const GfDualQuatf &dq);
257
258
260inline float
261GfDot(const GfDualQuatf& dq1, const GfDualQuatf& dq2) {
262 return GfDot(dq1.GetReal(), dq2.GetReal()) + GfDot(dq1.GetDual(), dq2.GetDual());
263}
264
265PXR_NAMESPACE_CLOSE_SCOPE
266
267#endif // PXR_BASE_GF_DUALQUATF_H
Declares Gf types.
Basic type: a real part quaternion and a dual part quaternion.
Definition: dualQuatd.h:50
Basic type: a real part quaternion and a dual part quaternion.
Definition: dualQuatf.h:50
const GfQuatf & GetReal() const
Returns the real part of the dual quaternion.
Definition: dualQuatf.h:103
GF_API GfDualQuatf(const GfDualQuatd &other)
Construct from GfDualQuatd.
GF_API GfDualQuatf(const GfDualQuath &other)
Implicitly convert from GfDualQuath.
GfDualQuatf(const GfQuatf &rotation, const GfVec3f &translation)
This constructor initializes from a rotation and a translation components.
Definition: dualQuatf.h:80
void SetReal(const GfQuatf &real)
Sets the real part of the dual quaternion.
Definition: dualQuatf.h:93
friend GfDualQuatf operator/(const GfDualQuatf &dq, float s)
Returns the product of dual quaternion dq and scalar 1 / s.
Definition: dualQuatf.h:239
GF_API GfDualQuatf GetInverse() const
Returns the inverse of this dual quaternion.
GF_API GfVec3f Transform(const GfVec3f &vec) const
Transforms the row vector vec by the dual quaternion.
friend GfDualQuatf operator+(const GfDualQuatf &dq1, const GfDualQuatf &dq2)
Component-wise binary sum operator.
Definition: dualQuatf.h:206
GfDualQuatf & operator/=(float s)
Scales this dual quaternion by 1 / s.
Definition: dualQuatf.h:201
GF_API GfDualQuatf GetConjugate() const
Returns the conjugate of this dual quaternion.
GfDualQuatf(const GfQuatf &real)
Initialize the real part to real quaternion and the imaginary part to zero quaternion.
Definition: dualQuatf.h:70
GfDualQuatf(float realVal)
Initialize the real part to realVal and the imaginary part to zero quaternion.
Definition: dualQuatf.h:65
GF_API std::pair< float, float > Normalize(float eps=GF_MIN_VECTOR_LENGTH)
Normalizes this dual quaternion in place.
const GfQuatf & GetDual() const
Returns the dual part of the dual quaternion.
Definition: dualQuatf.h:108
GfDualQuatf & operator-=(const GfDualQuatf &dq)
Component-wise unary difference operator.
Definition: dualQuatf.h:183
static GfDualQuatf GetZero()
Returns the zero dual quaternion, which has a real part of (0,0,0,0) and a dual part of (0,...
Definition: dualQuatf.h:114
friend size_t hash_value(const GfDualQuatf &dq)
Hash.
Definition: dualQuatf.h:158
GF_API GfDualQuatf & operator*=(const GfDualQuatf &dq)
Post-multiplies dual quaternion dq into this dual quaternion.
GF_API std::pair< float, float > GetLength() const
Returns geometric length of this dual quaternion.
static GfDualQuatf GetIdentity()
Returns the identity dual quaternion, which has a real part of (1,0,0,0) and a dual part of (0,...
Definition: dualQuatf.h:120
friend GfDualQuatf operator-(const GfDualQuatf &dq1, const GfDualQuatf &dq2)
Component-wise binary difference operator.
Definition: dualQuatf.h:213
GF_API GfVec3f GetTranslation() const
Get the translation component of this dual quaternion.
void SetDual(const GfQuatf &dual)
Sets the dual part of the dual quaternion.
Definition: dualQuatf.h:98
bool operator==(const GfDualQuatf &dq) const
Component-wise dual quaternion equality test.
Definition: dualQuatf.h:164
GfDualQuatf()=default
GfDualQuatf value-initializes to zero and performs no default initialization, like float or double.
friend GfDualQuatf operator*(const GfDualQuatf &dq1, const GfDualQuatf &dq2)
Returns the product of dual quaternions dq1 and dq2.
Definition: dualQuatf.h:220
GfDualQuatf(const GfQuatf &real, const GfQuatf &dual)
This constructor initializes the real and dual parts.
Definition: dualQuatf.h:75
GF_API GfDualQuatf GetNormalized(float eps=GF_MIN_VECTOR_LENGTH) const
Returns a normalized (unit-length) version of this dual quaternion.
GF_API void SetTranslation(const GfVec3f &translation)
Set the translation component of this dual quaternion.
bool operator!=(const GfDualQuatf &dq) const
Component-wise dual quaternion inequality test.
Definition: dualQuatf.h:171
GfDualQuatf & operator+=(const GfDualQuatf &dq)
Component-wise unary sum operator.
Definition: dualQuatf.h:176
Basic type: a real part quaternion and a dual part quaternion.
Definition: dualQuath.h:51
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
Definition: quatf.h:43
static GfQuatf GetZero()
Return the zero quaternion, with real coefficient 0 and an imaginary coefficients all zero.
Definition: quatf.h:82
static GfQuatf GetIdentity()
Return the identity quaternion, with real coefficient 1 and an imaginary coefficients all zero.
Definition: quatf.h:86
Basic type for a vector of 3 float components.
Definition: vec3f.h:46
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
Definition: hash.h:487
float GfDot(const GfDualQuatf &dq1, const GfDualQuatf &dq2)
Return the dot (inner) product of two dual quaternions.
Definition: dualQuatf.h:261
#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:17
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:35