HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Quaternion.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT library (C++)
7  *
8  * COMMENTS: This class implements quaternions.
9  *
10  * WARNING:
11  * This class should NOT contain any virtual methods, nor should it
12  * define more member data. The size of UT_QuaternionF must always be
13  * 16 bytes (4 floats).
14  *
15  */
16 
17 #pragma once
18 
19 #ifndef __UT_Quaternion_h__
20 #define __UT_Quaternion_h__
21 
22 #include "UT_API.h"
23 #include "UT_FixedVector.h"
24 #include "UT_FixedVectorTraits.h"
25 #include "UT_Vector3.h"
26 #include "UT_Vector4.h"
27 #include "UT_VectorTypes.h"
28 
29 #include <SYS/SYS_Inline.h>
30 #include <SYS/SYS_Math.h>
31 #include <SYS/SYS_Types.h>
32 #include <iosfwd>
33 #include <limits>
34 #include <stddef.h>
35 
36 class UT_IStream;
37 class UT_JSONParser;
38 class UT_JSONValue;
39 class UT_JSONWriter;
40 class UT_XformOrder;
41 
42 // Forward declaration
43 template <typename T> class UT_API UT_QuaternionT;
44 
45 /// Perform component-wise SYSlerp of two quaternions
46 template <typename T>
47 inline UT_QuaternionT<T>
48 SYSlerp(const UT_QuaternionT<T> &q1, const UT_QuaternionT<T> &q2, T t);
49 
50 /// Quaternion class
51 template <typename T>
53 {
54 public:
55 
56  typedef T value_type;
57  static constexpr int tuple_size = 4;
58 
59  UT_QuaternionT(T qx=0, T qy=0,
60  T qz=0, T qw=0)
61  {
62  vec[0] = qx; vec[1] = qy;
63  vec[2] = qz; vec[3] = qw;
64  }
65  UT_QuaternionT(const fpreal32 v[tuple_size])
66  {
67  vec[0] = v[0]; vec[1] = v[1];
68  vec[2] = v[2]; vec[3] = v[3];
69  }
70  UT_QuaternionT(const fpreal64 v[tuple_size])
71  {
72  vec[0] = v[0]; vec[1] = v[1];
73  vec[2] = v[2]; vec[3] = v[3];
74  }
76  {
77  vec[0] = v[0]; vec[1] = v[1];
78  vec[2] = v[2]; vec[3] = v[3];
79  }
80  /// Arbitrary UT_FixedVector of the same size
81  template <typename S>
83  {
84  vec[0] = v[0]; vec[1] = v[1];
85  vec[2] = v[2]; vec[3] = v[3];
86  }
87  inline UT_QuaternionT(T angle,
88  const UT_Vector3T<T> &axis,
89  int donormalize=1);
91  const UT_XformOrder &order)
92  {
93  updateFromEuler(rot, order);
94  }
95 
97 
98  SYS_FORCE_INLINE UT_QuaternionT(const ThisType &that) = default;
99  SYS_FORCE_INLINE UT_QuaternionT(ThisType &&that) = default;
100  SYS_FORCE_INLINE ThisType &operator=(const ThisType &that) = default;
101  SYS_FORCE_INLINE ThisType &operator=(ThisType &&that) = default;
102 
103  template <typename S>
105  { vec[0] = v.x(); vec[1] = v.y(); vec[2] = v.z(); vec[3] = v.w(); }
106  template <typename S>
108  { vec[0] = v.x(); vec[1] = v.y(); vec[2] = v.z(); vec[3] = v.w(); return *this; }
109 
111  inline UT_QuaternionT<T> &operator*=(T scalar);
112  inline UT_QuaternionT<T> &operator/=(const UT_QuaternionT<T> &quat);
113  inline UT_QuaternionT<T> &operator/=(T scalar);
114  inline UT_QuaternionT<T> &operator+=(const UT_QuaternionT<T> &quat);
115  inline bool operator==(const UT_QuaternionT<T> &quat) const;
116  inline bool operator!=(const UT_QuaternionT<T> &quat) const;
117  T operator()(int idx) const
118  { return vec[idx]; }
119  T &operator()(int idx)
120  { return vec[idx]; }
121  T operator[](int idx) const
122  { return vec[idx]; }
123  T &operator[](int idx)
124  { return vec[idx]; }
125 
126  /// Does a comparison with a tolerance. This also returns true if
127  /// quat.negated() is equal to us, unlike operator==().
128  inline bool isEqual(const UT_QuaternionT<T> &quat,
129  T tol = T(SYS_FTOLERANCE)) const;
130 
131  // The rotation this quaternion represents as a matrix
132  void getRotationMatrix(UT_Matrix3 &mat) const;
133  void getRotationMatrix(UT_DMatrix3 &mat) const;
134  void getInverseRotationMatrix(UT_Matrix3 &mat) const;
135  void getInverseRotationMatrix(UT_DMatrix3 &mat) const;
136 
137  void getTransformMatrix(UT_Matrix4 &mat) const;
138  void getTransformMatrix(UT_DMatrix4 &mat) const;
139 
140  /// Interpolates between this quat (t==0) and the target (t==1)
141  UT_QuaternionT<T> interpolate(const UT_QuaternionT<T> &target,
142  T t, T b = 0.0f) const;
143  /// Interpolates between the n quaternions in q, with weights w,
144  /// to within tolerance tol.
145  /// NOTE: The q's must be normalized, and the weights may need to sum to 1.
146  void interpolate(const UT_QuaternionT<T> *q, const T *w, exint n, T tol = T(1e-6));
147 
148  /// Do component-wise lerp between this quat (t=0) and the target (t=1).
150  {
151  vec[0] = SYSlerp(vec[0], target.vec[0], t);
152  vec[1] = SYSlerp(vec[1], target.vec[1], t);
153  vec[2] = SYSlerp(vec[2], target.vec[2], t);
154  vec[3] = SYSlerp(vec[3], target.vec[3], t);
155  }
156  /// Do component-wise lerp between this src (t=0) and dst (t=1).
158  const UT_QuaternionT<T> &dst,
159  T t)
160  {
161  vec[0] = SYSlerp(src.vec[0], dst.vec[0], t);
162  vec[1] = SYSlerp(src.vec[1], dst.vec[1], t);
163  vec[2] = SYSlerp(src.vec[2], dst.vec[2], t);
164  vec[3] = SYSlerp(src.vec[3], dst.vec[3], t);
165  }
166 
167  void assign(T qx, T qy,
168  T qz, T qw)
169  {
170  vec[0] = qx; vec[1] = qy;
171  vec[2] = qz; vec[3] = qw;
172  }
173  void identity()
174  {
175  vec[0] = vec[1] = vec[2] = 0.0f;
176  vec[3] = 1.0f;
177  }
178  void conjugate()
179  {
180  vec[0] = -vec[0];
181  vec[1] = -vec[1];
182  vec[2] = -vec[2];
183  }
184  void negate()
185  {
186  vec[0] = -vec[0];
187  vec[1] = -vec[1];
188  vec[2] = -vec[2];
189  vec[3] = -vec[3];
190  }
191  T normal() const
192  {
193  return vec[0] * vec[0] +
194  vec[1] * vec[1] +
195  vec[2] * vec[2] +
196  vec[3] * vec[3];
197  }
198  void normalize()
199  {
200  T dn = normal();
201  if (dn > std::numeric_limits<T>::min()
202  && dn != 1.0)
203  {
204  dn = SYSsqrt(dn);
205  *this /= dn;
206  }
207  }
208  T length() const
209  {
210  return SYSsqrt(normal());
211  }
212  void invert()
213  {
214  T n = normal();
215  if (n > std::numeric_limits<T>::min())
216  {
217  n = 1.0 / n;
218  conjugate();
219  vec[0] *= n;
220  vec[1] *= n;
221  vec[2] *= n;
222  vec[3] *= n;
223  }
224  }
225 
226  UT_QuaternionT<T> exp() const;
227  UT_QuaternionT<T> ln() const;
228  inline UT_QuaternionT<T> log() const
229  {
230  return ln();
231  }
232 
233  // Form the quaternion which takes v1 and rotates it to v2.
234  // v1 and v2 are assumed normalized
235  void updateFromVectors(const UT_Vector3T<T> &v1,
236  const UT_Vector3T<T> &v2);
237 
238  /// Form the quaternion from the rotation component of an
239  /// arbitrary 3x3 matrix.
240  void updateFromArbitraryMatrix(const UT_Matrix3 &);
241  void updateFromArbitraryMatrix(const UT_Matrix3D &);
242 
243  /// Form the quaternion from a rotation matrix
244  /// WARNING: This will produce incorrect results if given
245  /// a non-rotation matrix! Use updateFromArbitraryMatrix
246  /// if you may have a non-rotation matrix.
247  void updateFromRotationMatrix(const UT_Matrix3 &);
248  void updateFromRotationMatrix(const UT_Matrix3D &);
249 
250  // Form the quaternion from an angle/axis
251  void updateFromAngleAxis(T angle,
252  const UT_Vector3T<T> &axis,
253  int normalize=1);
254 
255  void getAngleAxis(T &angle,
256  UT_Vector3T<T> &axis) const;
257 
258  void updateFromLogMap(const UT_Vector3T<T> &v);
259  void getLogMap(UT_Vector3T<T> &v) const;
260 
261  // Form the quaternion from euler rotation angles (given in radians)
262  void updateFromEuler(const UT_Vector3T<T> &rot,
263  const UT_XformOrder &order);
264 
265  // Given the angular velocity omega, compute our derivative into q_prime
266  void computeDerivative(const UT_Vector3T<T> &omega,
267  UT_QuaternionT<T> &q_prime);
268 
269  // Returns the angular velocity required to move from the rotation of
270  // this quaternion to the destination quaternion in a given time.
271  UT_Vector3T<T> computeAngVel(const UT_QuaternionT<T> &dest,
272  T time) const;
273 
274  // Integrates this quaternion by the given angular velocity and time
275  // step. There are two appraoches to doing this. For small
276  // angular velocity/timesteps, one can compute the derivative
277  // implied by the angular velocity, apply linearly, and renormalize.
278  // Alternatively, one can construct the proper quaternion for the given
279  // angular velocity and rotate by that. Which method is controlled
280  // by the accurate flag.
281  void integrate(const UT_Vector3T<T> &angvel,
282  T timestep,
283  bool accurate = true);
284 
285  // Returns the rx/ry/rz euler rotation representation of the quaternion.
286  // The returned rotations are in radians.
287  UT_Vector3T<T> computeRotations(const UT_XformOrder &) const;
288 
289  /// Rotates a vector by this quaternion
290  /// Requires that this is normalized.
291  inline UT_Vector3T<T> rotate(const UT_Vector3T<T> &) const;
292 
293  /// rotates a vector by the inverse of this quaternion.
294  /// Requires that this is normalized.
295  inline UT_Vector3T<T> rotateInverse(const UT_Vector3T<T> &) const;
296 
297  // Multiply this quarternion's "real world" Euler angles by the given
298  // scalar s. That is, if this quaternion is
299  // [ cos(a), n1 sin(a), n2 sin(a), n3 sin(a) ] it is replaced by
300  // [ cos(a*s), n1 sin(a*s), n2 sin(a*s), n3 sin(a*s) ]
301  void multAngle( T s );
302 
303  T &x() { return vec[0]; }
304  T &y() { return vec[1]; }
305  T &z() { return vec[2]; }
306  T &w() { return vec[3]; }
307 
308  T x() const { return vec[0]; }
309  T y() const { return vec[1]; }
310  T z() const { return vec[2]; }
311  T w() const { return vec[3]; }
312 
313  void save(std::ostream &os, int binary=0) const;
314  bool load(UT_IStream &is);
315 
316  /// @{
317  /// Methods to serialize to a JSON stream. The vector is stored as an
318  /// array of 4 reals.
319  bool save(UT_JSONWriter &w) const;
320  bool save(UT_JSONValue &v) const;
321  bool load(UT_JSONParser &p);
322  /// @}
323 
324  const T *data() const { return &vec[0]; }
325  T *data() { return &vec[0]; }
326 
327  static int entries() { return tuple_size; }
328 
329  /// Compute a hash
330  unsigned hash() const { return SYSvector_hash(data(), tuple_size); }
331 
332 protected:
333  void initialize(T qx = 0, T qy = 0,
334  T qz = 0, T qw = 0)
335  {
336  vec[0] = qx; vec[1] = qy;
337  vec[2] = qz; vec[3] = qw;
338  }
339 private:
340  // I/O friends:
341  friend std::ostream &operator<<(std::ostream &os, const UT_QuaternionT<T> &v)
342  {
343  v.save(os);
344  return os;
345  }
346  T vec[tuple_size];
347 };
348 
349 template <typename T>
350 UT_API size_t format(char *buf, size_t buf_size, const UT_QuaternionT<T> &q);
351 
352 template <typename T>
353 inline
355  int donormalize)
356 {
357  updateFromAngleAxis(angle, axis, donormalize);
358 }
359 
360 template <typename T>
361 inline bool
363 {
364  return (vec[0] == quat.vec[0] &&
365  vec[1] == quat.vec[1] &&
366  vec[2] == quat.vec[2] &&
367  vec[3] == quat.vec[3]);
368 }
369 
370 template <typename T>
371 inline bool
373 {
374  return !(*this == quat);
375 }
376 
377 template <typename T>
378 inline bool
380 {
381  // Two quaternions are equal if all values are equal, or if all values
382  // are equal magnitude but opposite sign. Both sets of values represent
383  // the same overall rotation.
384  return ((SYSisEqual(vec[0], quat.vec[0], tol) &&
385  SYSisEqual(vec[1], quat.vec[1], tol) &&
386  SYSisEqual(vec[2], quat.vec[2], tol) &&
387  SYSisEqual(vec[3], quat.vec[3], tol)) ||
388  (SYSisEqual(-vec[0], quat.vec[0], tol) &&
389  SYSisEqual(-vec[1], quat.vec[1], tol) &&
390  SYSisEqual(-vec[2], quat.vec[2], tol) &&
391  SYSisEqual(-vec[3], quat.vec[3], tol)));
392 }
393 
394 template <typename T>
395 inline UT_QuaternionT<T>
397 {
398  UT_QuaternionT<T> product = q1;
399 
400  product *= q2;
401 
402  return UT_QuaternionT<T>(product);
403 }
404 
405 template <typename T>
406 inline UT_QuaternionT<T>
408 {
409  return UT_QuaternionT<T>(q1.x() + q2.x(),
410  q1.y() + q2.y(),
411  q1.z() + q2.z(),
412  q1.w() + q2.w());
413 }
414 
415 template <typename T>
416 inline UT_QuaternionT<T> &
418 {
419  vec[0] += quat.vec[0];
420  vec[1] += quat.vec[1];
421  vec[2] += quat.vec[2];
422  vec[3] += quat.vec[3];
423 
424  return *this;
425 }
426 
427 template <typename T>
428 inline UT_QuaternionT<T>
430 {
431  return UT_QuaternionT<T>(q1.x() - q2.x(),
432  q1.y() - q2.y(),
433  q1.z() - q2.z(),
434  q1.w() - q2.w());
435 }
436 
437 template <typename T>
438 inline UT_QuaternionT<T>
440 {
441  return UT_QuaternionT<T>(-q.x(),
442  -q.y(),
443  -q.z(),
444  -q.w());
445 }
446 
447 template <typename T>
448 inline UT_QuaternionT<T>
449 operator*(const UT_QuaternionT<T> &q, T scalar)
450 {
451  return UT_QuaternionT<T>(q.x() * scalar,
452  q.y() * scalar,
453  q.z() * scalar,
454  q.w() * scalar);
455 }
456 
457 template <typename T>
458 inline UT_QuaternionT<T>
459 operator*(T scalar, const UT_QuaternionT<T> &q)
460 {
461  return UT_QuaternionT<T>(q.x() * scalar,
462  q.y() * scalar,
463  q.z() * scalar,
464  q.w() * scalar);
465 }
466 
467 template <typename T>
468 inline UT_QuaternionT<T> &
470 {
471  UT_Vector3T<T> v1(vec[0], vec[1], vec[2]);
472  UT_Vector3T<T> v2(q.vec[0], q.vec[1], q.vec[2]);
474  T s1 = vec[3], s2 = q.vec[3];
475 
476  vec[3] = s1*s2 - v1.dot(v2);
477  v3 = s1*v2 + s2*v1 + cross(v1, v2);
478  vec[0] = v3[0];
479  vec[1] = v3[1];
480  vec[2] = v3[2];
481 
482  return *this;
483 }
484 
485 template <typename T>
486 inline UT_QuaternionT<T> &
488 {
489  vec[0] *= scalar;
490  vec[1] *= scalar;
491  vec[2] *= scalar;
492  vec[3] *= scalar;
493 
494  return *this;
495 }
496 
497 template <typename T>
498 inline UT_QuaternionT<T>
500 {
501  UT_QuaternionT<T> a1 = a;
502  UT_QuaternionT<T> b1 = b;
503 
504  b1.invert();
505  a1 *= b1;
506 
507  return UT_QuaternionT<T>(a1);
508 }
509 
510 template <typename T>
511 inline UT_QuaternionT<T>
512 operator/(const UT_QuaternionT<T> &q, T scalar)
513 {
514  T d = 1.0/scalar;
515  return UT_QuaternionT<T>(q.x()*d, q.y()*d, q.z()*d, q.w()*d);
516 }
517 
518 template <typename T>
519 inline UT_QuaternionT<T> &
521 {
522  UT_QuaternionT<T> q = quat;
523 
524  q.invert();
525  operator*=(q);
526 
527  return *this;
528 }
529 
530 template <typename T>
531 inline UT_QuaternionT<T> &
533 {
534  T d = 1.0F/scalar;
535 
536  vec[0] *= d;
537  vec[1] *= d;
538  vec[2] *= d;
539  vec[3] *= d;
540 
541  return *this;
542 }
543 
544 template <typename T>
545 inline UT_Vector3T<T>
547 {
548  UT_QuaternionT<T> q = (*this) *
549  UT_QuaternionT<T>(v.x(), v.y(), v.z(), 0.0f) *
550  UT_QuaternionT<T>(-vec[0], -vec[1], -vec[2], vec[3]);
551  return UT_Vector3T<T>(q.x(), q.y(), q.z());
552 }
553 
554 template <typename T>
555 inline UT_Vector3T<T>
557 {
558  UT_QuaternionT<T> q = UT_QuaternionT<T>(-vec[0], -vec[1], -vec[2], vec[3]) *
559  UT_QuaternionT<T>(v.x(), v.y(), v.z(), 0.0f) *
560  (*this);
561  return UT_Vector3T<T>(q.x(), q.y(), q.z());
562 }
563 
564 template <typename T>
565 inline T
566 dot( const UT_QuaternionT<T> &q1, const UT_QuaternionT<T> &q2 )
567 {
568  return q1.x()*q2.x() + q1.y()*q2.y() + q1.z()*q2.z() + q1.w()*q2.w();
569 }
570 
571 template <typename T>
572 inline size_t
574 {
575  return val.hash();
576 }
577 
583 
584 template< typename T, exint D >
585 class UT_FixedVector;
586 
587 template<typename T>
589 {
591  typedef T DataType;
592  static const exint TupleSize = 4;
593  static const bool isVectorType = true;
594 };
595 
596 ///////////////////////////////////////////////////////////////////////////////
597 //
598 // Implementations
599 //
600 
601 template <typename T>
602 inline UT_QuaternionT<T>
604 {
605  return UT_QuaternionT<T>( SYSlerp(q1.x(), q2.x(), t)
606  , SYSlerp(q1.y(), q2.y(), t)
607  , SYSlerp(q1.z(), q2.z(), t)
608  , SYSlerp(q1.w(), q2.w(), t)
609  );
610 }
611 
612 #endif
T & operator[](int idx)
Mat3< typename promote< S, T >::type > operator*(S scalar, const Mat3< T > &m)
Multiply each element of the given matrix by scalar and return the result.
Definition: Mat3.h:575
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
T length() const
constexpr SYS_FORCE_INLINE T dot(const UT_Vector3T &b) const noexcept
Definition: UT_Vector3.h:519
UT_QuaternionT< T > & operator/=(const UT_QuaternionT< T > &quat)
UT_QuaternionT(const UT_Vector3T< T > &rot, const UT_XformOrder &order)
Definition: UT_Quaternion.h:90
OIIO_FORCEINLINE const vint4 & operator/=(vint4 &a, const vint4 &b)
Definition: simd.h:4438
UT_QuaternionT< fpreal16 > UT_QuaternionH
GLuint GLdouble GLdouble GLint GLint order
Definition: glew.h:3460
UT_QuaternionT< T > & operator=(const UT_QuaternionT< S > &v)
T z() const
UT_QuaternionT< fpreal > UT_QuaternionR
GT_API const UT_StringHolder time
Transformation order of scales, rotates, and translates.
Definition: UT_XformOrder.h:23
Mat3< typename promote< T0, T1 >::type > operator+(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Add corresponding elements of m0 and m1 and return the result.
Definition: Mat3.h:591
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
GA_API const UT_StringHolder rot
T & operator()(int idx)
void assign(T qx, T qy, T qz, T qw)
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector3.h:657
int64 exint
Definition: SYS_Types.h:125
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:88
#define UT_API
Definition: UT_API.h:14
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:35
static const exint TupleSize
GLenum src
Definition: glcorearb.h:1793
3D Vector class.
4D Vector class.
Definition: UT_Vector4.h:172
static int entries()
float fpreal32
Definition: SYS_Types.h:200
GLdouble GLdouble t
Definition: glew.h:1403
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
Definition: glew.h:12900
size_t hash_value(const UT_QuaternionT< T > &val)
GLenum target
Definition: glcorearb.h:1667
UT_QuaternionT< T > operator/(const UT_QuaternionT< T > &a, const UT_QuaternionT< T > &b)
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
double fpreal64
Definition: SYS_Types.h:201
GLdouble GLdouble GLdouble GLdouble q
Definition: glew.h:1419
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
UT_API size_t format(char *buf, size_t buf_size, const UT_QuaternionT< T > &q)
UT_QuaternionT< fpreal32 > UT_QuaternionF
Vec3< T > & operator*=(Vec3< T > &_v, const Mat3< MT > &_m)
Multiply _v by _m and replace _v with the resulting vector.
Definition: Mat3.h:647
UT_QuaternionT< T > ThisType
Definition: UT_Quaternion.h:96
UT_Vector3T< T > rotateInverse(const UT_Vector3T< T > &) const
Mat3< typename promote< T0, T1 >::type > operator-(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Subtract corresponding elements of m0 and m1 and return the result.
Definition: Mat3.h:601
OIIO_FORCEINLINE const vint4 & operator+=(vint4 &a, const vint4 &b)
Definition: simd.h:4369
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:818
T x() const
UT_QuaternionT< fpreal64 > UT_QuaternionD
const GLdouble * v
Definition: glcorearb.h:837
UT_QuaternionT(T qx=0, T qy=0, T qz=0, T qw=0)
Definition: UT_Quaternion.h:59
static const bool isVectorType
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
GLfloat GLfloat p
Definition: glew.h:16656
UT_QuaternionT< T > & operator+=(const UT_QuaternionT< T > &quat)
T operator()(int idx) const
GLfloat GLfloat GLfloat GLfloat v3
Definition: glcorearb.h:819
const T * data() const
UT_QuaternionT(const UT_Vector4T< T > &v)
Definition: UT_Quaternion.h:75
void lerp(const UT_QuaternionT< T > &src, const UT_QuaternionT< T > &dst, T t)
Do component-wise lerp between this src (t=0) and dst (t=1).
T dot(const UT_QuaternionT< T > &q1, const UT_QuaternionT< T > &q2)
ImageBuf OIIO_API rotate(const ImageBuf &src, float angle, string_view filtername=string_view(), float filterwidth=0.0f, bool recompute_roi=false, ROI roi={}, int nthreads=0)
IMATH_HOSTDEVICE const Vec2< S > & operator*=(Vec2< S > &v, const Matrix22< T > &m) IMATH_NOEXCEPT
Vector-matrix multiplication: v *= m.
Definition: ImathMatrix.h:4660
UT_QuaternionT< T > SYSlerp(const UT_QuaternionT< T > &q1, const UT_QuaternionT< T > &q2, T t)
Perform component-wise SYSlerp of two quaternions.
UT_QuaternionT< T > & operator*=(const UT_QuaternionT< T > &q)
GLdouble n
Definition: glcorearb.h:2008
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
bool isEqual(const UT_QuaternionT< T > &quat, T tol=T(SYS_FTOLERANCE)) const
GLboolean * data
Definition: glcorearb.h:131
class UT_API UT_QuaternionT
Definition: UT_Quaternion.h:43
GLuint GLfloat * val
Definition: glcorearb.h:1608
UT_QuaternionT< T > log() const
SYS_FORCE_INLINE UT_QuaternionT(const UT_FixedVector< S, tuple_size > &v)
Arbitrary UT_FixedVector of the same size.
Definition: UT_Quaternion.h:82
Quaternion class.
Definition: UT_Quaternion.h:52
UT_QuaternionT(const fpreal64 v[tuple_size])
Definition: UT_Quaternion.h:70
T y() const
UT_QuaternionT< fpreal32 > UT_Quaternion
bool operator!=(const UT_QuaternionT< T > &quat) const
T w() const
T operator[](int idx) const
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:77
GLfloat f
Definition: glcorearb.h:1926
UT_QuaternionT(const fpreal32 v[tuple_size])
Definition: UT_Quaternion.h:65
void lerp(const UT_QuaternionT< T > &target, T t)
Do component-wise lerp between this quat (t=0) and the target (t=1).
#define SYS_FTOLERANCE
Definition: SYS_Types.h:208
GLdouble angle
Definition: glew.h:9177
bool operator!=(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:165
GLfloat GLfloat v1
Definition: glcorearb.h:817
T normal() const
bool operator==(const UT_QuaternionT< T > &quat) const
UT_Vector3T< T > rotate(const UT_Vector3T< T > &) const
void initialize(T qx=0, T qy=0, T qz=0, T qw=0)
GLenum GLenum dst
Definition: glcorearb.h:1793
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector3.h:655
GLdouble s
Definition: glew.h:1395
unsigned hash() const
Compute a hash.
SIM_DerVector3 cross(const SIM_DerVector3 &lhs, const SIM_DerVector3 &rhs)
constexpr T normalize(UT_FixedVector< T, D > &a) noexcept
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector3.h:653