HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_Vector4.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: Utility Library (C++)
7  *
8  * COMMENTS:
9  * This class handles fpreal vectors of dimension 4.
10  *
11  * WARNING:
12  * This class should NOT contain any virtual methods, nor should it
13  * define more member data. The size of UT_Vector4 must always be
14  * 16 bytes (4 floats).
15  *
16  */
17 
18 #pragma once
19 
20 #ifndef __UT_Vector4_h__
21 #define __UT_Vector4_h__
22 
23 #include "UT_API.h"
24 #include "UT_Assert.h"
25 #include "UT_FixedVector.h"
26 #include "UT_VectorTypes.h"
27 #include <SYS/SYS_Deprecated.h>
28 #include <SYS/SYS_Inline.h>
29 #include <SYS/SYS_Math.h>
30 #include <iosfwd>
31 #include <limits>
32 #include <vector>
33 
34 class UT_IStream;
35 class UT_JSONWriter;
36 class UT_JSONValue;
37 class UT_JSONParser;
38 
39 // Free floating functions:
40 
41 // Right-multiply operators (M*v) have been removed. They had previously
42 // been defined to return v*M, which was too counterintuitive. Once HDK
43 // etc. users have a chance to update their code (post 7.0) we could
44 // reintroduce a right-multiply operator that does a colVecMult.
45 
46 template <typename T, typename S>
47 inline UT_Vector4T<T> operator*(const UT_Vector4T<T> &v, const UT_Matrix4T<S> &m);
48 template <typename T>
50 template <typename T>
52 template <typename T, typename S>
53 inline UT_Vector4T<T> operator+(const UT_Vector4T<T> &v, S scalar);
54 template <typename T, typename S>
55 inline UT_Vector4T<T> operator-(const UT_Vector4T<T> &v, S scalar);
56 template <typename T, typename S>
57 inline UT_Vector4T<T> operator*(const UT_Vector4T<T> &v, S scalar);
58 template <typename T, typename S>
59 inline UT_Vector4T<T> operator/(const UT_Vector4T<T> &v, S scalar);
60 template <typename T, typename S>
61 inline UT_Vector4T<T> operator+(S scalar, const UT_Vector4T<T> &v);
62 template <typename T, typename S>
63 inline UT_Vector4T<T> operator-(S scalar, const UT_Vector4T<T> &v);
64 template <typename T, typename S>
65 inline UT_Vector4T<T> operator*(S scalar, const UT_Vector4T<T> &v);
66 template <typename T, typename S>
67 inline UT_Vector4T<T> operator/(S scalar, const UT_Vector4T<T> &v);
68 
69 /// Although the cross product is undefined for 4D vectors, we believe it's
70 /// useful in practice to define a function that takes two 4D vectors and
71 /// computes the cross-product of their first 3 components
72 template <typename T>
74 template <typename T>
76 template <typename T>
78 
79 /// The dot product between two vectors
80 // @{
81 template <typename T>
82 inline T dot(const UT_Vector4T<T> &v1, const UT_Vector4T<T> &v2);
83 template <typename T>
84 inline T dot(const UT_Vector4T<T> &v1, const UT_Vector3T<T> &v2);
85 template <typename T>
86 inline T dot(const UT_Vector3T<T> &v1, const UT_Vector4T<T> &v2);
87 // @}
88 
89 /// Componentwise min and maximum
90 template <typename T>
91 inline UT_Vector4T<T> SYSmin (const UT_Vector4T<T> &v1, const UT_Vector4T<T> &v2);
92 template <typename T>
93 inline UT_Vector4T<T> SYSmax (const UT_Vector4T<T> &v1, const UT_Vector4T<T> &v2);
94 
95 /// Componentwise linear interpolation
96 template <typename T,typename S>
97 inline UT_Vector4T<T> SYSlerp(const UT_Vector4T<T> &v1, const UT_Vector4T<T> &v2, S t);
98 template <typename T,typename S>
99 inline UT_Vector4T<T> SYSbilerp(const UT_Vector4T<T> &u0v0, const UT_Vector4T<T> &u1v0,
100  const UT_Vector4T<T> &u0v1, const UT_Vector4T<T> &u1v1,
101  S u, S v)
102 { return SYSlerp(SYSlerp(u0v0, u0v1, v), SYSlerp(u1v0, u1v1, v), u); }
103 
104 
105 /// Multiplication of a row or column vector by a matrix (ie. right vs. left
106 /// multiplication respectively). The operator*() declared above is an alias
107 /// for rowVecMult().
108 // @{
109 //
110 // Notes on optimisation of matrix/vector multiplies:
111 // - multiply(dest, mat) functions have been deprecated in favour of
112 // rowVecMult/colVecMult routines, which produce temporaries. For these to
113 // offer comparable performance, the compiler has to optimize away the
114 // temporary, but most modern compilers can do this. Performance tests with
115 // gcc3.3 indicate that this is a realistic expectation for modern
116 // compilers.
117 // - since matrix/vector multiplies cannot be done without temporary data,
118 // the "primary" functions are the global matrix/vector
119 // rowVecMult/colVecMult routines, rather than the member functions.
120 // - inlining is explicitly requested only for functions involving the
121 // native types (UT_Vector4 and UT_Matrix4)
122 template <typename T, typename S>
124 template <typename T, typename S>
126 
127 template <typename T, typename S>
129 template <typename T, typename S>
131 // @}
132 
133 /// Compute the distance between two points
134 // @{
135 template <typename T>
136 inline T distance4(const UT_Vector4T<T> &p1, const UT_Vector4T<T> &p2);
137 template <typename T>
138 inline T distance3(const UT_Vector4T<T> &p1, const UT_Vector4T<T> &p2);
139 template <typename T>
140 inline T distance3d(const UT_Vector4T<T> &p1, const UT_Vector4T<T> &p2)
141 { return distance3(p1, p2); }
142 template <typename T>
143 inline T distance3d(const UT_Vector3T<T> &p1, const UT_Vector4T<T> &p2)
144 { return distance3d(p1, UT_Vector3T<T>(p2)); }
145 template <typename T>
146 inline T distance3d(const UT_Vector4T<T> &p1, const UT_Vector3T<T> &p2)
147 { return distance3d(UT_Vector3T<T>(p1), p2); }
148 // @}
149 
150 /// 4D Vector class.
151 template <typename T>
152 class UT_API UT_Vector4T : public UT_FixedVector<T,4,true>
153 {
154 public:
156 
157  // These "using" statements are needed for operator= and operator*=
158  // so that the ones in UT_FixedVector aren't hidden by the additional
159  // ones here.
160  using Base::operator=;
161  using Base::operator*=;
162 
163  // These "using" statements are needed for GCC and Clang, because
164  // otherwise, they ignore all members of UT_FixedVector when
165  // checking validity of code in functions in this class.
166 private:
167  using Base::vec;
168 public:
169  using Base::data;
170  typedef T value_type;
171  static const int tuple_size = 4;
172 
173  /// Default constructor.
174  /// No data is initialized! Use it for extra speed.
175  SYS_FORCE_INLINE UT_Vector4T() = default;
176 
177  SYS_FORCE_INLINE UT_Vector4T(const UT_Vector4T<T> &that) = default;
178  SYS_FORCE_INLINE UT_Vector4T(UT_Vector4T<T> &&that) = default;
179 
180  SYS_FORCE_INLINE UT_Vector4T(T vx, T vy, T vz, T vw = 1.0f)
181  {
182  vec[0] = vx;
183  vec[1] = vy;
184  vec[2] = vz;
185  vec[3] = vw;
186  }
188  : Base(v)
189  {}
191  : Base(v)
192  {}
193  SYS_FORCE_INLINE UT_Vector4T(const int32 v[tuple_size])
194  : Base(v)
195  {}
196  SYS_FORCE_INLINE UT_Vector4T(const int64 v[tuple_size])
197  : Base(v)
198  {}
200  explicit UT_Vector4T(const UT_Vector3T<T> &v, T w = 1.f);
201 
202  /// Our own type of any given value_type.
203  template <typename S>
205  : Base(v)
206  {}
207 
208  /// Arbitrary UT_FixedVector of the same size
209  template <typename S,bool S_INSTANTIATED>
211  : Base(v)
212  {}
213 
216 
217  template <typename S>
219  { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; vec[3] = v[3];
220  return *this; }
221 
222 
223  // TODO: We could remove this. It's not as error-prone as some other
224  // conversions, but it might still be better to force the user to do
225  // an explicit cast i.e., v4 = UT_Vector4(v3)
226 
227  /// Assignment operator that creates a V4 from a V3 by adding a '1'
228  /// element.
229  SYS_DEPRECATED_HDK_REPLACE(16.0,explicit UT_Vector4 constructor to avoid implicit conversion from UT_Vector3)
231 
232  int equalZero3(T tol = 0.00001f) const
233  {
234  return (vec[0] >= -tol && vec[0] <= tol) &&
235  (vec[1] >= -tol && vec[1] <= tol) &&
236  (vec[2] >= -tol && vec[2] <= tol);
237  }
238 
239  void clampZero(T tol = 0.00001f)
240  {
241  if (vec[0] >= -tol && vec[0] <= tol) vec[0] = 0;
242  if (vec[1] >= -tol && vec[1] <= tol) vec[1] = 0;
243  if (vec[2] >= -tol && vec[2] <= tol) vec[2] = 0;
244  if (vec[3] >= -tol && vec[3] <= tol) vec[3] = 0;
245  }
246 
247  void clampZero3(T tol = 0.00001f)
248  {
249  if (vec[0] >= -tol && vec[0] <= tol) vec[0] = 0;
250  if (vec[1] >= -tol && vec[1] <= tol) vec[1] = 0;
251  if (vec[2] >= -tol && vec[2] <= tol) vec[2] = 0;
252  }
253 
254  void negate3()
255  { vec[0]= -vec[0]; vec[1]= -vec[1]; vec[2]= -vec[2]; }
256 
258  {
259  vec[0] *= v.vec[0];
260  vec[1] *= v.vec[1];
261  vec[2] *= v.vec[2];
262  vec[3] *= v.vec[3];
263  }
264 
265  using Base::isEqual;
266 
267  SYS_DEPRECATED_HDK_REPLACE(16.0,explicit conversion to UT_Vector3 followed by isEqual)
268  inline int isEqual(const UT_Vector3T<T> &vect, T tol = 0.00001f) const;
269 
270  /// If you need a multiplication operator that left multiplies the vector
271  /// by a matrix (M * v), use the following colVecMult() functions. If
272  /// you'd rather not use operator*=() for right-multiplications (v * M),
273  /// use the following rowVecMult() functions.
274  // @{
275  template <typename S>
276  inline void rowVecMult(const UT_Matrix4T<S> &m)
277  { operator=(::rowVecMult(*this, m)); }
278  template <typename S>
279  inline void colVecMult(const UT_Matrix4T<S> &m)
280  { operator=(::colVecMult(m, *this)); }
281  // @}
282 
283  /// This multiply will ignore the 4th component both in the vector an in
284  /// the matrix. This helps when you want to avoid affecting the 'w'
285  /// component. This in turns annihilates the translation components (row 4)
286  /// in mat, so be careful.
287  // @{
288  template <typename S>
290  { operator=(::rowVecMult3(*this, m)); }
291  // @}
292 
293  // The *= and multiply3 routines are provided for
294  // legacy reasons. They all assume that *this is a row vector. Generally,
295  // the rowVecMult and colVecMult methods are preferred, since they're
296  // more explicit about the row vector assumption.
297  // @{
298  template <typename S>
299  inline
301  { rowVecMult(mat); return *this; }
302 
303  template <typename S>
304  inline void multiply3(const UT_Matrix4T<S> &mat)
305  { rowVecMult3(mat); }
306  template <typename S>
307  inline void multiply3(UT_Vector4T<T> &dest, const UT_Matrix4T<S> &mat) const
308  { dest = ::rowVecMult3(*this, mat); }
309  // @}
310 
311  /// These allow you to find out what indices to use for different axes
312  // @{
313  int findMinAbsAxis() const
314  {
315  if (SYSabs(x()) < SYSabs(y()))
316  if (SYSabs(z()) < SYSabs(x()))
317  if (SYSabs(w()) < SYSabs(z()))
318  return 3;
319  else
320  return 2;
321  else
322  if (SYSabs(w()) < SYSabs(x()))
323  return 3;
324  else
325  return 0;
326  else
327  if (SYSabs(z()) < SYSabs(y()))
328  if (SYSabs(w()) < SYSabs(z()))
329  return 3;
330  else
331  return 2;
332  else
333  if (SYSabs(w()) < SYSabs(y()))
334  return 3;
335  else
336  return 1;
337  }
338  int findMaxAbsAxis() const
339  {
340  if (SYSabs(x()) >= SYSabs(y()))
341  if (SYSabs(z()) >= SYSabs(x()))
342  if (SYSabs(w()) >= SYSabs(z()))
343  return 3;
344  else
345  return 2;
346  else
347  if (SYSabs(w()) >= SYSabs(x()))
348  return 3;
349  else
350  return 0;
351  else
352  if (SYSabs(z()) >= SYSabs(y()))
353  if (SYSabs(w()) >= SYSabs(z()))
354  return 3;
355  else
356  return 2;
357  else
358  if (SYSabs(w()) >= SYSabs(y()))
359  return 3;
360  else
361  return 1;
362  }
363  // @}
364 
365  /// Return the components of the vector. The () operator does NOT check
366  /// for the boundary condition.
367  // @{
368  inline T &x(void) { return vec[0]; }
369  inline T x(void) const { return vec[0]; }
370  inline T &y(void) { return vec[1]; }
371  inline T y(void) const { return vec[1]; }
372  inline T &z(void) { return vec[2]; }
373  inline T z(void) const { return vec[2]; }
374  inline T &w(void) { return vec[3]; }
375  inline T w(void) const { return vec[3]; }
376  inline T &operator()(unsigned i)
377  {
378  UT_ASSERT_P(i < tuple_size);
379  return vec[i];
380  }
381  inline T operator()(unsigned i) const
382  {
383  UT_ASSERT_P(i < tuple_size);
384  return vec[i];
385  }
386  std::vector<T> asStdVector() const;
387  // @}
388 
389  /// Compute a hash
390  unsigned hash() const { return SYSvector_hash(data(), tuple_size); }
391 
392  // TODO: eliminate these methods. They're redundant, given good inline
393  // constructors.
394  /// Set the values of the vector components
395  void assign(T xx = 0.0f, T yy = 0.0f, T zz = 0.0f,
396  T ww = 1.0f)
397  {
398  vec[0] = xx; vec[1] = yy; vec[2] = zz; vec[3] = ww;
399  }
400  /// Set the values of the vector components
401  void assign(const T *v, int size = tuple_size)
402  {
403  vec[0] = v[0];
404  vec[1] = v[1];
405  vec[2] = v[2];
406  if (size == tuple_size) vec[3] = v[3];
407  }
408 
409  /// Express the point in homogeneous coordinates or vice-versa
410  // @{
411  void homogenize(void)
412  {
413  vec[0] *= vec[3];
414  vec[1] *= vec[3];
415  vec[2] *= vec[3];
416  }
417  void dehomogenize(void)
418  {
419  if (vec[3] != 0)
420  {
421  T denom = 1.0f / vec[3];
422  vec[0] *= denom;
423  vec[1] *= denom;
424  vec[2] *= denom;
425  }
426  }
427  // @}
428 
429  void save(std::ostream &os, int binary=0) const;
430  bool load(UT_IStream &is);
431 
432  /// @{
433  /// Methods to serialize to a JSON stream. The vector is stored as an
434  /// array of 4 reals.
435  bool save(UT_JSONWriter &w) const;
436  bool save(UT_JSONValue &v) const;
437  bool load(UT_JSONParser &p);
438  /// @}
439 
440  /// Returns the vector size
441  static int entries() { return tuple_size; }
442 
443 private:
444  /// I/O friends
445  // @{
446  friend std::ostream &operator<<(std::ostream &os, const UT_Vector4T<T> &v)
447  {
448  v.save(os);
449  return os;
450  }
451  // @}
452 
453  /// The negate operator is not provided, because of potentially
454  /// unintuitive behaviour: you very rarely actually want to negate the
455  /// w component.
456  UT_Vector4T<T> operator-() const
457  {
458  UT_ASSERT(0);
459  UT_Vector4T a(*this);
460  a.negate();
461  return a;
462  }
463 };
464 
465 #include "UT_Vector3.h"
466 
467 template <typename T>
469 {
470  vec[0] = v.x();
471  vec[1] = v.y();
472  vec[2] = v.z();
473  vec[3] = vw;
474 }
475 
476 template <typename T>
477 inline int
478 UT_Vector4T<T>::isEqual(const UT_Vector3T<T> &vect, T tol) const
479 {
480  return ((vec[0]>=vect.x()-tol) && (vec[0]<=vect.x()+tol) &&
481  (vec[1]>=vect.y()-tol) && (vec[1]<=vect.y()+tol) &&
482  (vec[2]>=vect.z()-tol) && (vec[2]<=vect.z()+tol));
483 }
484 
485 // Free floating functions:
486 template <typename T>
488 {
489  return UT_Vector4T<T>(v1.x()+v2.x(), v1.y()+v2.y(),
490  v1.z()+v2.z(), v1.w()+v2.w());
491 }
492 template <typename T>
494 {
495  return UT_Vector3T<T>(v1.x()+v2.x(), v1.y()+v2.y(),
496  v1.z()+v2.z());
497 }
498 template <typename T>
500 {
501  return UT_Vector3T<T>(v1.x()+v2.x(), v1.y()+v2.y(),
502  v1.z()+v2.z());
503 }
504 template <typename T>
506 {
507  return UT_Vector4T<T>(v1.x()-v2.x(), v1.y()-v2.y(),
508  v1.z()-v2.z(), v1.w()-v2.w());
509 }
510 template <typename T>
512 {
513  return UT_Vector3T<T>(v1.x()-v2.x(), v1.y()-v2.y(),
514  v1.z()-v2.z());
515 }
516 template <typename T>
518 {
519  return UT_Vector3T<T>(v1.x()-v2.x(), v1.y()-v2.y(),
520  v1.z()-v2.z());
521 }
522 template <typename T>
524 {
525  return UT_Vector4T<T>(v1.x()*v2.x(), v1.y()*v2.y(), v1.z()*v2.z(), v1.w()*v2.w());
526 }
527 
528 template <typename T>
530 {
531  return UT_Vector4T<T>(v1.x()/v2.x(), v1.y()/v2.y(), v1.z()/v2.z(), v1.w()/v2.w());
532 }
533 
534 template <typename T, typename S>
535 inline UT_Vector4T<T> operator+(const UT_Vector4T<T> &v, S scalar)
536 {
537  return UT_Vector4T<T>(v.x()+scalar, v.y()+scalar, v.z()+scalar, v.w()+scalar);
538 }
539 template <typename T, typename S>
540 inline UT_Vector4T<T> operator+(S scalar, const UT_Vector4T<T> &v)
541 {
542  return UT_Vector4T<T>(v.x()+scalar, v.y()+scalar, v.z()+scalar, v.w()+scalar);
543 }
544 template <typename T, typename S>
545 inline UT_Vector4T<T> operator-(const UT_Vector4T<T> &v, S scalar)
546 {
547  return UT_Vector4T<T>(v.x()-scalar, v.y()-scalar, v.z()-scalar, v.w()-scalar);
548 }
549 template <typename T, typename S>
550 inline UT_Vector4T<T> operator-(S scalar, const UT_Vector4T<T> &v)
551 {
552  return UT_Vector4T<T>(scalar-v.x(), scalar-v.y(), scalar-v.z(), v.w()-scalar);
553 }
554 template <typename T, typename S>
555 inline UT_Vector4T<T> operator*(const UT_Vector4T<T> &v, S scalar)
556 {
557  return UT_Vector4T<T>(v.x()*scalar, v.y()*scalar, v.z()*scalar, v.w()*scalar);
558 }
559 template <typename T, typename S>
560 inline UT_Vector4T<T> operator*(S scalar, const UT_Vector4T<T> &v)
561 {
562  return UT_Vector4T<T>(v.x()*scalar, v.y()*scalar, v.z()*scalar, v.w()*scalar);
563 }
564 template <typename T, typename S>
565 inline UT_Vector4T<T> operator/(const UT_Vector4T<T> &v, S scalar)
566 {
567  // This has to be T because S may be int for "v = v/2" code
568  // For the same reason we must cast the 1
569  T inv = ((T)1) / scalar;
570  return UT_Vector4T<T>(v.x()*inv, v.y()*inv, v.z()*inv, v.w()*inv);
571 }
572 template <typename T, typename S>
573 inline UT_Vector4T<T> operator/(S scalar, const UT_Vector4T<T> &v)
574 {
575  return UT_Vector4T<T>(scalar/v.x(), scalar/v.y(), scalar/v.z(), scalar/v.w());
576 }
577 template <typename T>
578 inline T dot(const UT_Vector4T<T> &v1, const UT_Vector4T<T> &v2)
579 {
580  return v1.x()*v2.x() + v1.y()*v2.y() + v1.z()*v2.z() + v1.w()*v2.w();
581 }
582 template <typename T>
583 inline T dot(const UT_Vector4T<T> &v1, const UT_Vector3T<T> &v2)
584 {
585  return v1.x()*v2.x() + v1.y()*v2.y() + v1.z()*v2.z();
586 }
587 template <typename T>
588 inline T dot(const UT_Vector3T<T> &v1, const UT_Vector4T<T> &v2)
589 {
590  return v1.x()*v2.x() + v1.y()*v2.y() + v1.z()*v2.z();
591 }
592 template <typename T>
593 inline
595 {
596  return UT_Vector4T<T>(
597  SYSmin(v1.x(), v2.x()),
598  SYSmin(v1.y(), v2.y()),
599  SYSmin(v1.z(), v2.z()),
600  SYSmin(v1.w(), v2.w())
601  );
602 }
603 
604 template <typename T>
605 inline
607 {
608  return UT_Vector4T<T>(
609  SYSmax(v1.x(), v2.x()),
610  SYSmax(v1.y(), v2.y()),
611  SYSmax(v1.z(), v2.z()),
612  SYSmax(v1.w(), v2.w())
613  );
614 }
615 
616 template <typename T,typename S>
617 inline
619 {
620  return UT_Vector4T<T>(
621  SYSlerp(v1.x(), v2.x(), t),
622  SYSlerp(v1.y(), v2.y(), t),
623  SYSlerp(v1.z(), v2.z(), t),
624  SYSlerp(v1.w(), v2.w(), t));
625 }
626 
627 
628 template <typename T, typename S>
630 {
631  return rowVecMult(v, m);
632 }
633 template <typename T>
634 inline T distance(const UT_Vector4T<T> &v1, const UT_Vector4T<T> &v2)
635 {
636  T x = v1.x()-v2.x();
637  T y = v1.y()-v2.y();
638  T z = v1.z()-v2.z();
639  T w = v1.w()-v2.w();
640  return SYSsqrt(x*x + y*y + z*z + w*w);
641 }
642 template <typename T>
644 {
645  T x = v1.x()-v2.x();
646  T y = v1.y()-v2.y();
647  T z = v1.z()-v2.z();
648  return SYSsqrt(x*x + y*y + z*z);
649 }
650 
651 template <typename T>
652 inline size_t hash_value(const UT_Vector4T<T> &val)
653 {
654  return val.hash();
655 }
656 
657 // Overload for custom formatting of UT_Vector4T<T> with UTformat.
658 template<typename T>
659 UT_API size_t format(char *buffer, size_t buffer_size, const UT_Vector4T<T> &v);
660 
661 
662 template<typename T>
664 {
666  typedef T DataType;
667  static const exint TupleSize = 4;
668  static const bool isVectorType = true;
669 };
670 
671 #endif
SYS_FORCE_INLINE constexpr const T * data() const noexcept
SYS_FORCE_INLINE UT_FixedVector< T, SIZE > operator-() const
UT_API size_t format(char *buffer, size_t buffer_size, const UT_Vector4T< T > &v)
Mat3< typename promote< S, T >::type > operator*(S scalar, const Mat3< T > &m)
Returns M, where for .
Definition: Mat3.h:615
UT_Vector4T< T > operator/(const UT_Vector4T< T > &v, S scalar)
Definition: UT_Vector4.h:565
class UT_API UT_Vector4T
T & z(void)
Definition: UT_Vector4.h:372
UT_Vector4T< T > SYSlerp(const UT_Vector4T< T > &v1, const UT_Vector4T< T > &v2, S t)
Componentwise linear interpolation.
Definition: UT_Vector4.h:618
UT_Vector4T< T > SYSmin(const UT_Vector4T< T > &v1, const UT_Vector4T< T > &v2)
Componentwise min and maximum.
Definition: UT_Vector4.h:594
unsigned hash() const
Compute a hash.
Definition: UT_Vector4.h:390
T operator()(unsigned i) const
Definition: UT_Vector4.h:381
SYS_FORCE_INLINE UT_Vector4T(const UT_FixedVector< S, tuple_size, S_INSTANTIATED > &v)
Arbitrary UT_FixedVector of the same size.
Definition: UT_Vector4.h:210
void multiplyComponents(const UT_Vector4T< T > &v)
Definition: UT_Vector4.h:257
SYS_FORCE_INLINE ThisType & operator=(const ThisType &that)=default
const GLdouble * v
Definition: glcorearb.h:836
Mat3< typename promote< T0, T1 >::type > operator+(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Returns M, where for .
Definition: Mat3.h:631
SYS_FORCE_INLINE UT_Vector4T(const UT_Vector4T< S > &v)
Our own type of any given value_type.
Definition: UT_Vector4.h:204
#define SYS_DEPRECATED_HDK_REPLACE(__V__, __R__)
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:847
void colVecMult(const UT_Matrix4T< S > &m)
Definition: UT_Vector4.h:279
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
#define SYSabs(a)
Definition: SYS_Math.h:1367
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:72
#define UT_API
Definition: UT_API.h:12
GLint y
Definition: glcorearb.h:102
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
int isEqual(const UT_Vector3T< T > &vect, T tol=0.00001f) const
Definition: UT_Vector4.h:478
static const exint TupleSize
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:817
SYS_FORCE_INLINE T & x(void)
Definition: UT_Vector3.h:581
size_t hash_value(const UT_Vector4T< T > &val)
Definition: UT_Vector4.h:652
3D Vector class.
4D Vector class.
Definition: UT_Vector4.h:152
GLuint buffer
Definition: glcorearb.h:659
png_uint_32 i
Definition: png.h:2877
SYS_FORCE_INLINE UT_Vector4T(const fpreal64 v[tuple_size])
Definition: UT_Vector4.h:190
GLsizeiptr size
Definition: glcorearb.h:663
SYS_FORCE_INLINE UT_Vector4T()=default
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:101
void negate3()
Definition: UT_Vector4.h:254
UT_Vector4T< T > SYSmax(const UT_Vector4T< T > &v1, const UT_Vector4T< T > &v2)
Definition: UT_Vector4.h:606
SYS_FORCE_INLINE T & z(void)
Definition: UT_Vector3.h:585
long long int64
Definition: SYS_Types.h:106
GLfloat f
Definition: glcorearb.h:1925
UT_API UT_Vector4T< T > colVecMult3(const UT_Matrix4T< S > &m, const UT_Vector4T< T > &v)
UT_API UT_Vector4T< T > rowVecMult3(const UT_Vector4T< T > &v, const UT_Matrix4T< S > &m)
void clampZero(T tol=0.00001f)
Definition: UT_Vector4.h:239
Mat3< typename promote< T0, T1 >::type > operator-(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Returns M, where for .
Definition: Mat3.h:641
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:102
T distance(const UT_Vector4T< T > &v1, const UT_Vector4T< T > &v2)
Definition: UT_Vector4.h:634
int64 exint
Definition: SYS_Types.h:115
double fpreal64
Definition: SYS_Types.h:191
static const bool isVectorType
void multiply3(UT_Vector4T< T > &dest, const UT_Matrix4T< S > &mat) const
Definition: UT_Vector4.h:307
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
SYS_FORCE_INLINE UT_Vector4T(const int64 v[tuple_size])
Definition: UT_Vector4.h:196
UT_API UT_Vector3T< T > cross(const UT_Vector4T< T > &v1, const UT_Vector4T< T > &v2)
UT_API UT_Vector4T< T > colVecMult(const UT_Matrix4T< S > &m, const UT_Vector4T< T > &v)
T & operator()(unsigned i)
Definition: UT_Vector4.h:376
GLboolean * data
Definition: glcorearb.h:130
T z(void) const
Definition: UT_Vector4.h:373
int int32
Definition: SYS_Types.h:34
T & y(void)
Definition: UT_Vector4.h:370
int findMinAbsAxis() const
These allow you to find out what indices to use for different axes.
Definition: UT_Vector4.h:313
UT_Vector4T< T > & operator*=(const UT_Matrix4T< S > &mat)
Definition: UT_Vector4.h:300
T distance4(const UT_Vector4T< T > &p1, const UT_Vector4T< T > &p2)
Compute the distance between two points.
SYS_FORCE_INLINE UT_Vector4T< T > & operator=(const UT_Vector4T< S > &v)
Definition: UT_Vector4.h:218
void assign(T xx=0.0f, T yy=0.0f, T zz=0.0f, T ww=1.0f)
Set the values of the vector components.
Definition: UT_Vector4.h:395
SYS_FORCE_INLINE T & y(void)
Definition: UT_Vector3.h:583
int findMaxAbsAxis() const
These allow you to find out what indices to use for different axes.
Definition: UT_Vector4.h:338
UT_Vector4T< T > SYSbilerp(const UT_Vector4T< T > &u0v0, const UT_Vector4T< T > &u1v0, const UT_Vector4T< T > &u0v1, const UT_Vector4T< T > &u1v1, S u, S v)
Definition: UT_Vector4.h:99
UT_FixedVector< T, 4 > FixedVectorType
Definition: UT_Vector4.h:665
void rowVecMult(const UT_Matrix4T< S > &m)
Definition: UT_Vector4.h:276
SYS_FORCE_INLINE bool isEqual(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that, S tol=S(SYS_FTOLERANCE)) const
static int entries()
Returns the vector size.
Definition: UT_Vector4.h:441
T w(void) const
Definition: UT_Vector4.h:375
T y(void) const
Definition: UT_Vector4.h:371
png_infop png_bytep png_size_t buffer_size
Definition: png.h:2124
UT_API UT_Vector4T< T > rowVecMult(const UT_Vector4T< T > &v, const UT_Matrix4T< S > &m)
GLint GLenum GLint x
Definition: glcorearb.h:408
GLfloat GLfloat v1
Definition: glcorearb.h:816
GLuint GLfloat * val
Definition: glcorearb.h:1607
void assign(const T *v, int size=tuple_size)
Set the values of the vector components.
Definition: UT_Vector4.h:401
void homogenize(void)
Express the point in homogeneous coordinates or vice-versa.
Definition: UT_Vector4.h:411
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:75
void multiply3(const UT_Matrix4T< S > &mat)
Definition: UT_Vector4.h:304
T & x(void)
Definition: UT_Vector4.h:368
SYS_FORCE_INLINE UT_Vector4T(const fpreal32 v[tuple_size])
Definition: UT_Vector4.h:187
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
T distance3d(const UT_Vector4T< T > &p1, const UT_Vector4T< T > &p2)
Compute the distance between two points.
Definition: UT_Vector4.h:140
T dot(const UT_Vector4T< T > &v1, const UT_Vector4T< T > &v2)
The dot product between two vectors.
Definition: UT_Vector4.h:578
SYS_FORCE_INLINE UT_Vector4T(const int32 v[tuple_size])
Definition: UT_Vector4.h:193
void clampZero3(T tol=0.00001f)
Definition: UT_Vector4.h:247
T & w(void)
Definition: UT_Vector4.h:374
int equalZero3(T tol=0.00001f) const
Definition: UT_Vector4.h:232
T x(void) const
Definition: UT_Vector4.h:369
SYS_FORCE_INLINE UT_Vector4T(T vx, T vy, T vz, T vw=1.0f)
Definition: UT_Vector4.h:180
void rowVecMult3(const UT_Matrix4T< S > &m)
Definition: UT_Vector4.h:289
float fpreal32
Definition: SYS_Types.h:190
void dehomogenize(void)
Express the point in homogeneous coordinates or vice-versa.
Definition: UT_Vector4.h:417
T distance3(const UT_Vector4T< T > &p1, const UT_Vector4T< T > &p2)
Compute the distance between two points.
Definition: UT_Vector4.h:643
UT_FixedVector< T, 4, true > Base
Definition: UT_Vector4.h:155