This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
64 explicit GfDualQuatf( float realVal ) : _real( realVal ), _dual( 0 ) {}
65
69 explicit GfDualQuatf( const GfQuatf &real )
70 : _real( real ), _dual( 0 ) {
71 }
72
74 GfDualQuatf( const GfQuatf &real, const GfQuatf &dual )
75 : _real( real ), _dual( dual ) {
76 }
77
79 GfDualQuatf( const GfQuatf &rotation, const GfVec3f &translation )
80 : _real( rotation ) {
81 SetTranslation( translation );
82 }
83
85 GF_API
86 explicit GfDualQuatf(const GfDualQuatd &other);
88 GF_API
89 GfDualQuatf(const GfDualQuath &other);
90
92 void SetReal(const GfQuatf &real) {
93 _real = real;
94 }
95
97 void SetDual(const GfQuatf &dual) {
98 _dual = dual;
99 }
100
102 const GfQuatf &GetReal() const {
103 return _real;
104 }
105
107 const GfQuatf &GetDual() const {
108 return _dual;
109 }
110
115 }
116
121 }
122
124 GF_API
125 std::pair<float, float> GetLength() const;
126
130 GF_API
132
137 GF_API
138 std::pair<float, float> Normalize(float eps = GF_MIN_VECTOR_LENGTH);
139
141 GF_API
143
145 GF_API
147
149 GF_API
150 void SetTranslation( const GfVec3f &translation );
151
153 GF_API
155
157 friend inline size_t hash_value(const GfDualQuatf &dq) {
158 return TfHash::Combine(dq.GetReal(), dq.GetDual());
159 }
160
163 bool operator ==(const GfDualQuatf &dq) const {
164 return (GetReal() == dq.GetReal() &&
165 GetDual() == dq.GetDual());
166 }
167
170 bool operator !=(const GfDualQuatf &dq) const {
171 return ! (*this == dq);
172 }
173
176 _real += dq._real;
177 _dual += dq._dual;
178 return *this;
179 }
180
183 _real -= dq._real;
184 _dual -= dq._dual;
185 return *this;
186 }
187
189 GF_API
191
194 _real *= s;
195 _dual *= s;
196 return *this;
197 }
198
201 return (*this) *= 1.0 / s;
202 }
203
206 const GfDualQuatf &dq2) {
207 GfDualQuatf dqt = dq1;
208 return dqt += dq2;
209 }
210
213 const GfDualQuatf &dq2) {
214 GfDualQuatf dqt = dq1;
215 return dqt -= dq2;
216 }
217
220 const GfDualQuatf &dq2) {
221 GfDualQuatf dqt = dq1;
222 return dqt *= dq2;
223 }
224
226 friend GfDualQuatf operator *(const GfDualQuatf &dq, float s) {
227 GfDualQuatf dqt = dq;
228 return dqt *= s;
229 }
230
232 friend GfDualQuatf operator *(float s, const GfDualQuatf &dq) {
233 GfDualQuatf dqt = dq;
234 return dqt *= s;
235 }
236
238 friend GfDualQuatf operator /(const GfDualQuatf &dq, float s) {
239 GfDualQuatf dqt = dq;
240 return dqt /= s;
241 }
242
244 GF_API
245 GfVec3f Transform(const GfVec3f &vec) const;
246
247 private:
248 GfQuatf _real; // for rotation
249 GfQuatf _dual; // for translation
250};
251
252
255GF_API std::ostream &operator<<(std::ostream &out, const GfDualQuatf &dq);
256
257
259inline float
260GfDot(const GfDualQuatf& dq1, const GfDualQuatf& dq2) {
261 return GfDot(dq1.GetReal(), dq2.GetReal()) + GfDot(dq1.GetDual(), dq2.GetDual());
262}
263
264PXR_NAMESPACE_CLOSE_SCOPE
265
266#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:102
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:79
void SetReal(const GfQuatf &real)
Sets the real part of the dual quaternion.
Definition: dualQuatf.h:92
friend GfDualQuatf operator/(const GfDualQuatf &dq, float s)
Returns the product of dual quaternion dq and scalar 1 / s.
Definition: dualQuatf.h:238
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:205
GfDualQuatf & operator/=(float s)
Scales this dual quaternion by 1 / s.
Definition: dualQuatf.h:200
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:69
GfDualQuatf(float realVal)
Initialize the real part to realVal and the imaginary part to zero quaternion.
Definition: dualQuatf.h:64
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:107
GfDualQuatf & operator-=(const GfDualQuatf &dq)
Component-wise unary difference operator.
Definition: dualQuatf.h:182
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:113
friend size_t hash_value(const GfDualQuatf &dq)
Hash.
Definition: dualQuatf.h:157
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:119
friend GfDualQuatf operator-(const GfDualQuatf &dq1, const GfDualQuatf &dq2)
Component-wise binary difference operator.
Definition: dualQuatf.h:212
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:97
bool operator==(const GfDualQuatf &dq) const
Component-wise dual quaternion equality test.
Definition: dualQuatf.h:163
GfDualQuatf()
The default constructor leaves the dual quaternion undefined.
Definition: dualQuatf.h:55
friend GfDualQuatf operator*(const GfDualQuatf &dq1, const GfDualQuatf &dq2)
Returns the product of dual quaternions dq1 and dq2.
Definition: dualQuatf.h:219
GfDualQuatf(const GfQuatf &real, const GfQuatf &dual)
This constructor initializes the real and dual parts.
Definition: dualQuatf.h:74
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:170
GfDualQuatf & operator+=(const GfDualQuatf &dq)
Component-wise unary sum operator.
Definition: dualQuatf.h:175
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:81
static GfQuatf GetIdentity()
Return the identity quaternion, with real coefficient 1 and an imaginary coefficients all zero.
Definition: quatf.h:85
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:475
float GfDot(const GfDualQuatf &dq1, const GfDualQuatf &dq2)
Return the dot (inner) product of two dual quaternions.
Definition: dualQuatf.h:260
#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