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_Vector3.h"
25 #include "UT_Vector4.h"
26 #include "UT_VectorTypes.h"
27 
28 #include <SYS/SYS_Inline.h>
29 #include <SYS/SYS_Math.h>
30 #include <SYS/SYS_Types.h>
31 #include <iosfwd>
32 #include <limits>
33 #include <stddef.h>
34 
35 class UT_IStream;
36 class UT_JSONParser;
37 class UT_JSONValue;
38 class UT_JSONWriter;
39 class UT_XformOrder;
40 
41 // Forward declaration
42 template <typename T> class UT_API UT_QuaternionT;
43 
44 /// Perform component-wise SYSlerp of two quaternions
45 template <typename T>
46 inline UT_QuaternionT<T>
47 SYSlerp(const UT_QuaternionT<T> &q1, const UT_QuaternionT<T> &q2, T t);
48 
49 /// Quaternion class
50 template <typename T>
52 {
53 public:
54 
55  typedef T value_type;
56  static const int tuple_size = 4;
57 
58  UT_QuaternionT(T qx=0, T qy=0,
59  T qz=0, T qw=0)
60  {
61  vec[0] = qx; vec[1] = qy;
62  vec[2] = qz; vec[3] = qw;
63  }
64  UT_QuaternionT(const fpreal32 v[tuple_size])
65  {
66  vec[0] = v[0]; vec[1] = v[1];
67  vec[2] = v[2]; vec[3] = v[3];
68  }
69  UT_QuaternionT(const fpreal64 v[tuple_size])
70  {
71  vec[0] = v[0]; vec[1] = v[1];
72  vec[2] = v[2]; vec[3] = v[3];
73  }
75  {
76  vec[0] = v[0]; vec[1] = v[1];
77  vec[2] = v[2]; vec[3] = v[3];
78  }
79  /// Arbitrary UT_FixedVector of the same size
80  template <typename S>
82  {
83  vec[0] = v[0]; vec[1] = v[1];
84  vec[2] = v[2]; vec[3] = v[3];
85  }
86  inline UT_QuaternionT(T angle,
87  const UT_Vector3T<T> &axis,
88  int donormalize=1);
90  const UT_XformOrder &order)
91  {
92  updateFromEuler(rot, order);
93  }
94 
96 
97  SYS_FORCE_INLINE UT_QuaternionT(const ThisType &that) = default;
98  SYS_FORCE_INLINE UT_QuaternionT(ThisType &&that) = default;
99  SYS_FORCE_INLINE ThisType &operator=(const ThisType &that) = default;
100  SYS_FORCE_INLINE ThisType &operator=(ThisType &&that) = default;
101 
102  template <typename S>
104  { vec[0] = v.x(); vec[1] = v.y(); vec[2] = v.z(); vec[3] = v.w(); }
105  template <typename S>
107  { vec[0] = v.x(); vec[1] = v.y(); vec[2] = v.z(); vec[3] = v.w(); return *this; }
108 
110  inline UT_QuaternionT<T> &operator*=(T scalar);
111  inline UT_QuaternionT<T> &operator/=(const UT_QuaternionT<T> &quat);
112  inline UT_QuaternionT<T> &operator/=(T scalar);
113  inline UT_QuaternionT<T> &operator+=(const UT_QuaternionT<T> &quat);
114  inline bool operator==(const UT_QuaternionT<T> &quat) const;
115  inline bool operator!=(const UT_QuaternionT<T> &quat) const;
116  T operator()(int idx) const
117  { return vec[idx]; }
118  T &operator()(int idx)
119  { return vec[idx]; }
120  T operator[](int idx) const
121  { return vec[idx]; }
122  T &operator[](int idx)
123  { return vec[idx]; }
124 
125  /// Does a comparison with a tolerance. This also returns true if
126  /// quat.negated() is equal to us, unlike operator==().
127  inline bool isEqual(const UT_QuaternionT<T> &quat,
128  T tol = T(SYS_FTOLERANCE)) const;
129 
130  // The rotation this quaternion represents as a matrix
131  void getRotationMatrix(UT_Matrix3 &mat) const;
132  void getRotationMatrix(UT_DMatrix3 &mat) const;
133  void getInverseRotationMatrix(UT_Matrix3 &mat) const;
134  void getInverseRotationMatrix(UT_DMatrix3 &mat) const;
135 
136  void getTransformMatrix(UT_Matrix4 &mat) const;
137  void getTransformMatrix(UT_DMatrix4 &mat) const;
138 
139  /// Interpolates between this quat (t==0) and the target (t==1)
140  UT_QuaternionT<T> interpolate(const UT_QuaternionT<T> &target,
141  T t, T b = 0.0f) const;
142  /// Interpolates between the n quaternions in q, with weights w,
143  /// to within tolerance tol.
144  /// NOTE: The q's must be normalized, and the weights may need to sum to 1.
145  void interpolate(const UT_QuaternionT<T> *q, const T *w, exint n, T tol = T(1e-6));
146 
147  /// Do component-wise lerp between this quat (t=0) and the target (t=1).
148  void lerp(const UT_QuaternionT<T> &target, T t)
149  {
150  vec[0] = SYSlerp(vec[0], target.vec[0], t);
151  vec[1] = SYSlerp(vec[1], target.vec[1], t);
152  vec[2] = SYSlerp(vec[2], target.vec[2], t);
153  vec[3] = SYSlerp(vec[3], target.vec[3], t);
154  }
155  /// Do component-wise lerp between this src (t=0) and dst (t=1).
157  const UT_QuaternionT<T> &dst,
158  T t)
159  {
160  vec[0] = SYSlerp(src.vec[0], dst.vec[0], t);
161  vec[1] = SYSlerp(src.vec[1], dst.vec[1], t);
162  vec[2] = SYSlerp(src.vec[2], dst.vec[2], t);
163  vec[3] = SYSlerp(src.vec[3], dst.vec[3], t);
164  }
165 
166  void assign(T qx, T qy,
167  T qz, T qw)
168  {
169  vec[0] = qx; vec[1] = qy;
170  vec[2] = qz; vec[3] = qw;
171  }
172  void identity()
173  {
174  vec[0] = vec[1] = vec[2] = 0.0f;
175  vec[3] = 1.0f;
176  }
177  void conjugate()
178  {
179  vec[0] = -vec[0];
180  vec[1] = -vec[1];
181  vec[2] = -vec[2];
182  }
183  void negate()
184  {
185  vec[0] = -vec[0];
186  vec[1] = -vec[1];
187  vec[2] = -vec[2];
188  vec[3] = -vec[3];
189  }
190  T normal() const
191  {
192  return vec[0] * vec[0] +
193  vec[1] * vec[1] +
194  vec[2] * vec[2] +
195  vec[3] * vec[3];
196  }
197  void normalize()
198  {
199  T dn = normal();
200  if (dn > std::numeric_limits<T>::min()
201  && dn != 1.0)
202  {
203  dn = SYSsqrt(dn);
204  *this /= dn;
205  }
206  }
207  T length() const
208  {
209  return SYSsqrt(normal());
210  }
211  void invert()
212  {
213  T n = normal();
214  if (n > std::numeric_limits<T>::min())
215  {
216  n = 1.0 / n;
217  conjugate();
218  vec[0] *= n;
219  vec[1] *= n;
220  vec[2] *= n;
221  vec[3] *= n;
222  }
223  }
224 
225  UT_QuaternionT<T> exp() const;
226  UT_QuaternionT<T> ln() const;
227  inline UT_QuaternionT<T> log() const
228  {
229  return ln();
230  }
231 
232  // Form the quaternion which takes v1 and rotates it to v2.
233  // v1 and v2 are assumed normalized
234  void updateFromVectors(const UT_Vector3T<T> &v1,
235  const UT_Vector3T<T> &v2);
236 
237  /// Form the quaternion from the rotation component of an
238  /// arbitrary 3x3 matrix.
239  void updateFromArbitraryMatrix(const UT_Matrix3 &);
240  void updateFromArbitraryMatrix(const UT_Matrix3D &);
241 
242  /// Form the quaternion from a rotation matrix
243  /// WARNING: This will produce incorrect results if given
244  /// a non-rotation matrix! Use updateFromArbitraryMatrix
245  /// if you may have a non-rotation matrix.
246  void updateFromRotationMatrix(const UT_Matrix3 &);
247  void updateFromRotationMatrix(const UT_Matrix3D &);
248 
249  // Form the quaternion from an angle/axis
250  void updateFromAngleAxis(T angle,
251  const UT_Vector3T<T> &axis,
252  int normalize=1);
253 
254  void getAngleAxis(T &angle,
255  UT_Vector3T<T> &axis) const;
256 
257  void updateFromLogMap(const UT_Vector3T<T> &v);
258  void getLogMap(UT_Vector3T<T> &v) const;
259 
260  // Form the quaternion from euler rotation angles (given in radians)
261  void updateFromEuler(const UT_Vector3T<T> &rot,
262  const UT_XformOrder &order);
263 
264  // Given the angular velocity omega, compute our derivative into q_prime
265  void computeDerivative(const UT_Vector3T<T> &omega,
266  UT_QuaternionT<T> &q_prime);
267 
268  // Returns the angular velocity required to move from the rotation of
269  // this quaternion to the destination quaternion in a given time.
270  UT_Vector3T<T> computeAngVel(const UT_QuaternionT<T> &dest,
271  T time) const;
272 
273  // Integrates this quaternion by the given angular velocity and time
274  // step. There are two appraoches to doing this. For small
275  // angular velocity/timesteps, one can compute the derivative
276  // implied by the angular velocity, apply linearly, and renormalize.
277  // Alternatively, one can construct the proper quaternion for the given
278  // angular velocity and rotate by that. Which method is controlled
279  // by the accurate flag.
280  void integrate(const UT_Vector3T<T> &angvel,
281  T timestep,
282  bool accurate = true);
283 
284  // Returns the rx/ry/rz euler rotation representation of the quaternion.
285  // The returned rotations are in radians.
286  UT_Vector3T<T> computeRotations(const UT_XformOrder &) const;
287 
288  /// Rotates a vector by this quaternion
289  /// Requires that this is normalized.
290  inline UT_Vector3T<T> rotate(const UT_Vector3T<T> &) const;
291 
292  /// rotates a vector by the inverse of this quaternion.
293  /// Requires that this is normalized.
294  inline UT_Vector3T<T> rotateInverse(const UT_Vector3T<T> &) const;
295 
296  // Multiply this quarternion's "real world" Euler angles by the given
297  // scalar s. That is, if this quaternion is
298  // [ cos(a), n1 sin(a), n2 sin(a), n3 sin(a) ] it is replaced by
299  // [ cos(a*s), n1 sin(a*s), n2 sin(a*s), n3 sin(a*s) ]
300  void multAngle( T s );
301 
302  T &x() { return vec[0]; }
303  T &y() { return vec[1]; }
304  T &z() { return vec[2]; }
305  T &w() { return vec[3]; }
306 
307  T x() const { return vec[0]; }
308  T y() const { return vec[1]; }
309  T z() const { return vec[2]; }
310  T w() const { return vec[3]; }
311 
312  void save(std::ostream &os, int binary=0) const;
313  bool load(UT_IStream &is);
314 
315  /// @{
316  /// Methods to serialize to a JSON stream. The vector is stored as an
317  /// array of 4 reals.
318  bool save(UT_JSONWriter &w) const;
319  bool save(UT_JSONValue &v) const;
320  bool load(UT_JSONParser &p);
321  /// @}
322 
323  const T *data(void) const { return &vec[0]; }
324  T *data(void) { return &vec[0]; }
325 
326  static int entries() { return tuple_size; }
327 
328  /// Compute a hash
329  unsigned hash() const { return SYSvector_hash(data(), tuple_size); }
330 
331 protected:
332  void initialize(T qx = 0, T qy = 0,
333  T qz = 0, T qw = 0)
334  {
335  vec[0] = qx; vec[1] = qy;
336  vec[2] = qz; vec[3] = qw;
337  }
338 private:
339  // I/O friends:
340  friend std::ostream &operator<<(std::ostream &os, const UT_QuaternionT<T> &v)
341  {
342  v.save(os);
343  return os;
344  }
345  T vec[tuple_size];
346 };
347 
348 template <typename T>
349 UT_API size_t format(char *buf, size_t buf_size, const UT_QuaternionT<T> &q);
350 
351 template <typename T>
352 inline
354  int donormalize)
355 {
356  updateFromAngleAxis(angle, axis, donormalize);
357 }
358 
359 template <typename T>
360 inline bool
362 {
363  return (vec[0] == quat.vec[0] &&
364  vec[1] == quat.vec[1] &&
365  vec[2] == quat.vec[2] &&
366  vec[3] == quat.vec[3]);
367 }
368 
369 template <typename T>
370 inline bool
372 {
373  return !(*this == quat);
374 }
375 
376 template <typename T>
377 inline bool
379 {
380  // Two quaternions are equal if all values are equal, or if all values
381  // are equal magnitude but opposite sign. Both sets of values represent
382  // the same overall rotation.
383  return ((SYSisEqual(vec[0], quat.vec[0], tol) &&
384  SYSisEqual(vec[1], quat.vec[1], tol) &&
385  SYSisEqual(vec[2], quat.vec[2], tol) &&
386  SYSisEqual(vec[3], quat.vec[3], tol)) ||
387  (SYSisEqual(-vec[0], quat.vec[0], tol) &&
388  SYSisEqual(-vec[1], quat.vec[1], tol) &&
389  SYSisEqual(-vec[2], quat.vec[2], tol) &&
390  SYSisEqual(-vec[3], quat.vec[3], tol)));
391 }
392 
393 template <typename T>
394 inline UT_QuaternionT<T>
396 {
397  UT_QuaternionT<T> product = q1;
398 
399  product *= q2;
400 
401  return UT_QuaternionT<T>(product);
402 }
403 
404 template <typename T>
405 inline UT_QuaternionT<T>
407 {
408  return UT_QuaternionT<T>(q1.x() + q2.x(),
409  q1.y() + q2.y(),
410  q1.z() + q2.z(),
411  q1.w() + q2.w());
412 }
413 
414 template <typename T>
415 inline UT_QuaternionT<T> &
417 {
418  vec[0] += quat.vec[0];
419  vec[1] += quat.vec[1];
420  vec[2] += quat.vec[2];
421  vec[3] += quat.vec[3];
422 
423  return *this;
424 }
425 
426 template <typename T>
427 inline UT_QuaternionT<T>
429 {
430  return UT_QuaternionT<T>(q1.x() - q2.x(),
431  q1.y() - q2.y(),
432  q1.z() - q2.z(),
433  q1.w() - q2.w());
434 }
435 
436 template <typename T>
437 inline UT_QuaternionT<T>
439 {
440  return UT_QuaternionT<T>(-q.x(),
441  -q.y(),
442  -q.z(),
443  -q.w());
444 }
445 
446 template <typename T>
447 inline UT_QuaternionT<T>
448 operator*(const UT_QuaternionT<T> &q, T scalar)
449 {
450  return UT_QuaternionT<T>(q.x() * scalar,
451  q.y() * scalar,
452  q.z() * scalar,
453  q.w() * scalar);
454 }
455 
456 template <typename T>
457 inline UT_QuaternionT<T>
458 operator*(T scalar, const UT_QuaternionT<T> &q)
459 {
460  return UT_QuaternionT<T>(q.x() * scalar,
461  q.y() * scalar,
462  q.z() * scalar,
463  q.w() * scalar);
464 }
465 
466 template <typename T>
467 inline UT_QuaternionT<T> &
469 {
470  UT_Vector3T<T> v1(vec[0], vec[1], vec[2]);
471  UT_Vector3T<T> v2(q.vec[0], q.vec[1], q.vec[2]);
473  T s1 = vec[3], s2 = q.vec[3];
474 
475  vec[3] = s1*s2 - v1.dot(v2);
476  v3 = s1*v2 + s2*v1 + cross(v1, v2);
477  vec[0] = v3[0];
478  vec[1] = v3[1];
479  vec[2] = v3[2];
480 
481  return *this;
482 }
483 
484 template <typename T>
485 inline UT_QuaternionT<T> &
487 {
488  vec[0] *= scalar;
489  vec[1] *= scalar;
490  vec[2] *= scalar;
491  vec[3] *= scalar;
492 
493  return *this;
494 }
495 
496 template <typename T>
497 inline UT_QuaternionT<T>
499 {
500  UT_QuaternionT<T> a1 = a;
501  UT_QuaternionT<T> b1 = b;
502 
503  b1.invert();
504  a1 *= b1;
505 
506  return UT_QuaternionT<T>(a1);
507 }
508 
509 template <typename T>
510 inline UT_QuaternionT<T>
511 operator/(const UT_QuaternionT<T> &q, T scalar)
512 {
513  T d = 1.0/scalar;
514  return UT_QuaternionT<T>(q.x()*d, q.y()*d, q.z()*d, q.w()*d);
515 }
516 
517 template <typename T>
518 inline UT_QuaternionT<T> &
520 {
521  UT_QuaternionT<T> q = quat;
522 
523  q.invert();
524  operator*=(q);
525 
526  return *this;
527 }
528 
529 template <typename T>
530 inline UT_QuaternionT<T> &
532 {
533  T d = 1.0F/scalar;
534 
535  vec[0] *= d;
536  vec[1] *= d;
537  vec[2] *= d;
538  vec[3] *= d;
539 
540  return *this;
541 }
542 
543 template <typename T>
544 inline UT_Vector3T<T>
546 {
547  UT_QuaternionT<T> q = (*this) *
548  UT_QuaternionT<T>(v.x(), v.y(), v.z(), 0.0f) *
549  UT_QuaternionT<T>(-vec[0], -vec[1], -vec[2], vec[3]);
550  return UT_Vector3T<T>(q.x(), q.y(), q.z());
551 }
552 
553 template <typename T>
554 inline UT_Vector3T<T>
556 {
557  UT_QuaternionT<T> q = UT_QuaternionT<T>(-vec[0], -vec[1], -vec[2], vec[3]) *
558  UT_QuaternionT<T>(v.x(), v.y(), v.z(), 0.0f) *
559  (*this);
560  return UT_Vector3T<T>(q.x(), q.y(), q.z());
561 }
562 
563 template <typename T>
564 inline T
565 dot( const UT_QuaternionT<T> &q1, const UT_QuaternionT<T> &q2 )
566 {
567  return q1.x()*q2.x() + q1.y()*q2.y() + q1.z()*q2.z() + q1.w()*q2.w();
568 }
569 
570 template <typename T>
571 inline size_t
573 {
574  return val.hash();
575 }
576 
582 
583 template<typename T>
585 {
587  typedef T DataType;
588  static const exint TupleSize = 4;
589  static const bool isVectorType = true;
590 };
591 
592 ///////////////////////////////////////////////////////////////////////////////
593 //
594 // Implementations
595 //
596 
597 template <typename T>
598 inline UT_QuaternionT<T>
599 SYSlerp(const UT_QuaternionT<T> &q1, const UT_QuaternionT<T> &q2, T t)
600 {
601  return UT_QuaternionT<T>( SYSlerp(q1.x(), q2.x(), t)
602  , SYSlerp(q1.y(), q2.y(), t)
603  , SYSlerp(q1.z(), q2.z(), t)
604  , SYSlerp(q1.w(), q2.w(), t)
605  );
606 }
607 
608 #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:609
T length() const
UT_QuaternionT< T > & operator/=(const UT_QuaternionT< T > &quat)
UT_QuaternionT(const UT_Vector3T< T > &rot, const UT_XformOrder &order)
Definition: UT_Quaternion.h:89
UT_QuaternionT< fpreal16 > UT_QuaternionH
UT_QuaternionT< T > & operator=(const UT_QuaternionT< S > &v)
png_voidp s1
Definition: png.h:2193
T z() const
UT_QuaternionT< fpreal > UT_QuaternionR
GT_API const UT_StringHolder time
const GLdouble * v
Definition: glcorearb.h:836
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:625
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
GA_API const UT_StringHolder rot
T & operator()(int idx)
void assign(T qx, T qy, T qz, T qw)
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:75
#define UT_API
Definition: UT_API.h:13
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
static const exint TupleSize
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:817
SYS_FORCE_INLINE T & x(void)
Definition: UT_Vector3.h:498
3D Vector class.
GLfloat GLfloat GLfloat GLfloat v3
Definition: glcorearb.h:818
4D Vector class.
Definition: UT_Vector4.h:155
static int entries()
size_t hash_value(const UT_QuaternionT< T > &val)
UT_QuaternionT< T > operator/(const UT_QuaternionT< T > &a, const UT_QuaternionT< T > &b)
SYS_FORCE_INLINE T & z(void)
Definition: UT_Vector3.h:502
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)
GLdouble n
Definition: glcorearb.h:2007
GLfloat f
Definition: glcorearb.h:1925
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:681
UT_QuaternionT< T > ThisType
Definition: UT_Quaternion.h:95
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:635
T x() const
int64 exint
Definition: SYS_Types.h:116
UT_QuaternionT< fpreal64 > UT_QuaternionD
double fpreal64
Definition: SYS_Types.h:192
UT_QuaternionT(T qx=0, T qy=0, T qz=0, T qw=0)
Definition: UT_Quaternion.h:58
static const bool isVectorType
const T * data(void) const
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
SYS_API double exp(double x)
Definition: SYS_FPUMath.h:97
T angle(const Vec2< T > &v1, const Vec2< T > &v2)
Definition: Vec2.h:472
GLenum target
Definition: glcorearb.h:1666
UT_QuaternionT< T > & operator+=(const UT_QuaternionT< T > &quat)
T operator()(int idx) const
GLboolean * data
Definition: glcorearb.h:130
GridType::Ptr normalize(const GridType &grid, bool threaded, InterruptT *interrupt)
Normalize the vectors of the given vector-valued grid.
const Vec2< S > & operator*=(Vec2< S > &v, const Matrix33< T > &m)
Definition: ImathMatrix.h:3322
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
UT_QuaternionT(const UT_Vector4T< T > &v)
Definition: UT_Quaternion.h:74
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)
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)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2539
bool isEqual(const UT_QuaternionT< T > &quat, T tol=T(SYS_FTOLERANCE)) const
SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, S >::Type dot(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const
class UT_API UT_QuaternionT
Definition: UT_Quaternion.h:42
UT_QuaternionT< T > log() const
GLenum GLenum dst
Definition: glcorearb.h:1792
SYS_FORCE_INLINE T & y(void)
Definition: UT_Vector3.h:500
SYS_FORCE_INLINE UT_QuaternionT(const UT_FixedVector< S, tuple_size > &v)
Arbitrary UT_FixedVector of the same size.
Definition: UT_Quaternion.h:81
Quaternion class.
Definition: UT_Quaternion.h:51
png_voidp png_voidp s2
Definition: png.h:2193
UT_QuaternionT(const fpreal64 v[tuple_size])
Definition: UT_Quaternion.h:69
T y() const
UT_QuaternionT< fpreal32 > UT_Quaternion
bool operator!=(const UT_QuaternionT< T > &quat) const
T w() const
T * data(void)
GLfloat GLfloat v1
Definition: glcorearb.h:816
GLuint GLfloat * val
Definition: glcorearb.h:1607
T operator[](int idx) const
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:75
UT_QuaternionT(const fpreal32 v[tuple_size])
Definition: UT_Quaternion.h:64
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:203
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
bool operator!=(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:165
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)
const std::enable_if<!VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:129
unsigned hash() const
Compute a hash.
float fpreal32
Definition: SYS_Types.h:191
SIM_DerVector3 cross(const SIM_DerVector3 &lhs, const SIM_DerVector3 &rhs)
GLenum src
Definition: glcorearb.h:1792