HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Vector3.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 3.
10  *
11  * WARNING:
12  * This class should NOT contain any virtual methods, nor should it
13  * define more member data. The size of UT_Vector3 must always be
14  * 12 bytes (3 floats).
15  */
16 
17 #pragma once
18 
19 #ifndef __UT_Vector3_h__
20 #define __UT_Vector3_h__
21 
22 #include "UT_API.h"
23 #include "UT_Assert.h"
24 #include "UT_FixedVector.h"
25 #include "UT_VectorTypes.h"
26 #include "UT_Vector2.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 
33 class UT_IStream;
34 class UT_JSONWriter;
35 class UT_JSONValue;
36 class UT_JSONParser;
37 
38 // Free floating functions:
39 
40 // Right-multiply operators (M*v) have been removed. They had previously
41 // been defined to return v*M, which was too counterintuitive. Once HDK
42 // etc. users have a chance to update their code (post 7.0) we could
43 // reintroduce a right-multiply operator that does a colVecMult.
44 
45 template <typename T, typename S>
47 template <typename T, typename S>
49 template <typename T>
51 template <typename T>
53 template <typename T, typename S>
54 inline UT_Vector3T<T> operator+(const UT_Vector3T<T> &v, S scalar);
55 template <typename T, typename S>
56 inline UT_Vector3T<T> operator-(const UT_Vector3T<T> &v, S scalar);
57 template <typename T, typename S>
58 inline UT_Vector3T<T> operator*(const UT_Vector3T<T> &v, S scalar);
59 template <typename T, typename S>
60 inline UT_Vector3T<T> operator/(const UT_Vector3T<T> &v, S scalar);
61 template <typename T, typename S>
62 inline UT_Vector3T<T> operator+(S scalar, const UT_Vector3T<T> &v);
63 template <typename T, typename S>
64 inline UT_Vector3T<T> operator-(S scalar, const UT_Vector3T<T> &v);
65 template <typename T, typename S>
66 inline UT_Vector3T<T> operator*(S scalar, const UT_Vector3T<T> &v);
67 template <typename T, typename S>
68 inline UT_Vector3T<T> operator/(S scalar, const UT_Vector3T<T> &v);
69 
70 /// The dot and cross products between two vectors (see operator*() too)
71 // @{
72 template <typename T>
73 inline T dot(const UT_Vector3T<T> &v1, const UT_Vector3T<T> &v2);
74 template <typename T>
75 inline UT_Vector3T<T> cross(const UT_Vector3T<T> &v1, const UT_Vector3T<T> &v2);
76 // @}
77 
78 /// The angle between two vectors in radians
79 // @{
80 template <typename T>
82 // @}
83 
84 /// Componentwise min and maximum
85 template <typename T>
87 template <typename T>
89 
90 /// Componentwise linear interpolation
91 template <typename T,typename S>
92 inline UT_Vector3T<T> SYSlerp(const UT_Vector3T<T> &v1, const UT_Vector3T<T> &v2, S t);
93 
94 /// Componentwise inverse linear interpolation
95 template <typename T>
97 
98 /// Bilinear interpolation
99 template <typename T,typename S>
100 inline UT_Vector3T<T> SYSbilerp(const UT_Vector3T<T> &u0v0, const UT_Vector3T<T> &u1v0,
101  const UT_Vector3T<T> &u0v1, const UT_Vector3T<T> &u1v1,
102  S u, S v)
103 { return SYSlerp(SYSlerp(u0v0, u0v1, v), SYSlerp(u1v0, u1v1, v), u); }
104 
105 /// Barycentric interpolation
106 template <typename T, typename S>
108  const UT_Vector3T<T> &v1, const UT_Vector3T<T> &v2, S u, S v)
109 { return v0 * (1 - u - v) + v1 * u + v2 *v; }
110 
111 
112 /// Trilinear hat function over kernel widths in s.
113 template <typename T>
114 inline T SYStrihat(const UT_Vector3T<T> &v, const UT_Vector3T<T> &s);
115 
116 /// Gradient of trilinear hat function over kernel widths in s.
117 template <typename T>
119 
120 /// The orthogonal projection of a vector u onto a vector v
121 template <typename T>
122 inline UT_Vector3T<T> project(const UT_Vector3T<T> &u, const UT_Vector3T<T> &v);
123 
124 // TODO: make UT_Vector4 versions of these:
125 
126 /// Compute the distance between two points
127 template <typename T>
128 inline T distance3d(const UT_Vector3T<T> &p1, const UT_Vector3T<T> &p2);
129 /// Compute the distance squared
130 template <typename T>
131 inline T distance2(const UT_Vector3T<T> &p1, const UT_Vector3T<T> &p2);
132 template <typename T>
133 inline T segmentPointDist2(const UT_Vector3T<T> &pos,
134  const UT_Vector3T<T> &pt1,
135  const UT_Vector3T<T> &pt2 );
136 
137 /// Intersect the lines p1 + v1 * t1 and p2 + v2 * t2.
138 /// t1 and t2 are set so that the lines intersect when
139 /// projected to the plane defined by the two lines.
140 /// This function returns a value which indicates how close
141 /// to being parallel the lines are. Closer to zero means
142 /// more parallel. This is done so that the user of this
143 /// function can decide what epsilon they want to use.
144 template <typename T>
145 UT_API double intersectLines(const UT_Vector3T<T> &p1,
146  const UT_Vector3T<T> &v1,
147  const UT_Vector3T<T> &p2,
148  const UT_Vector3T<T> &v2,
149  T &t1, T &t2);
150 
151 /// Returns true if the segments from p0 to p1 and from a to b intersect, and
152 /// t will contain the parametric value of the intersection on the segment a-b.
153 /// Otherwise returns false. Parallel segments will return false. T is
154 /// guaranteed to be between 0.0 and 1.0 if this function returns true.
155 template <typename T>
157  const UT_Vector3T<T> &p1,
158  const UT_Vector3T<T> &a,
159  const UT_Vector3T<T> &b, T &t);
160 
161 /// Returns the U coordinates of the closest points on each of the two
162 /// parallel line segments
163 template <typename T>
165  const UT_Vector3T<T> &p1,
166  const UT_Vector3T<T> &a,
167  const UT_Vector3T<T> &b);
168 /// Returns the U coordinates of the closest points on each of the two
169 /// line segments
170 template <typename T>
172  const UT_Vector3T<T> &p1,
173  const UT_Vector3T<T> &a,
174  const UT_Vector3T<T> &b);
175 /// Returns the U coordinate of the point on line segment p0->p1
176 /// that is closest to a.
177 template <typename T>
179  const UT_Vector3T<T> &p0,
180  const UT_Vector3T<T> &p1,
181  const UT_Vector3T<T> &a);
182 
183 /// Returns the squared distance between two line segments: p0-p1 and a-b
184 template <typename T>
185 inline T segmentDistance2(const UT_Vector3T<T> &p0,
186  const UT_Vector3T<T> &p1,
187  const UT_Vector3T<T> &a,
188  const UT_Vector3T<T> &b);
189 /// Returns the distance between two line segments: p0-p1 and a-b
190 template <typename T>
191 inline T segmentDistance(const UT_Vector3T<T> &p0,
192  const UT_Vector3T<T> &p1,
193  const UT_Vector3T<T> &a,
194  const UT_Vector3T<T> &b);
195 /// 3D Vector class.
196 template <typename T>
197 class UT_API UT_Vector3T : public UT_FixedVector<T,3,true>
198 {
199 public:
201 
202  // These "using" statements are needed for operator=, operator*=, and
203  // distance, so that the ones in UT_FixedVector aren't hidden by the
204  // additional ones here.
205  using Base::operator=;
206  using Base::operator*=;
207  using Base::distance;
208 
209  // These "using" statements are needed for GCC and Clang, because
210  // otherwise, they ignore all members of UT_FixedVector when
211  // checking validity of code in functions in this class.
212  using Base::vec;
213  using Base::data;
214  using Base::normalize;
215  using Base::length2;
216  typedef T value_type;
217  static const int tuple_size = 3;
218 
219  /// Default constructor.
220  /// No data is initialized! Use it for extra speed.
221  SYS_FORCE_INLINE UT_Vector3T() = default;
222 
223  SYS_FORCE_INLINE UT_Vector3T(const UT_Vector3T<T> &that) = default;
224  SYS_FORCE_INLINE UT_Vector3T(UT_Vector3T<T> &&that) = default;
225 
227  {
228  vec[0] = v;
229  vec[1] = v;
230  vec[2] = v;
231  }
232 
234  {
235  vec[0] = vx;
236  vec[1] = vy;
237  vec[2] = vz;
238  }
240  : Base(v)
241  {}
243  : Base(v)
244  {}
246  : Base(v)
247  {}
248  SYS_FORCE_INLINE UT_Vector3T(const int32 v[tuple_size])
249  : Base(v)
250  {}
251  SYS_FORCE_INLINE UT_Vector3T(const int64 v[tuple_size])
252  : Base(v)
253  {}
254 
255  SYS_FORCE_INLINE explicit UT_Vector3T(const UT_Vector2T<T> &v);
256  SYS_FORCE_INLINE explicit UT_Vector3T(const UT_Vector4T<T> &v);
257 
258  /// Our own type of any given value_type.
259  template <typename S>
261  : Base(v)
262  {}
263 
264  /// Arbitrary UT_FixedVector of the same size
265  template <typename S,bool S_INSTANTIATED>
267  : Base(v)
268  {}
269 
272 
273  template <typename S>
275  { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; return *this; }
276 
277  /// Assignment operator that truncates a V4 to a V3.
278  /// TODO: remove this. This should require an explicit UT_Vector3()
279  /// construction, since it's unsafe.
280  SYS_DEPRECATED_HDK_REPLACE(16.0,explicit UT_Vector3 constructor to avoid implicit conversion from UT_Vector4)
282 
283  /// It's unclear why this is needed, given UT_FixedVector::operator-(),
284  /// but the compiler seems not to accept not having it.
286  {
287  return UT_Vector3T<T>(-vec[0], -vec[1], -vec[2]);
288  }
289 
290  void clampZero(T tol = T(0.00001f))
291  {
292  if (vec[0] >= -tol && vec[0] <= tol) vec[0] = 0;
293  if (vec[1] >= -tol && vec[1] <= tol) vec[1] = 0;
294  if (vec[2] >= -tol && vec[2] <= tol) vec[2] = 0;
295  }
296 
299  {
300  vec[0] *= v.vec[0];
301  vec[1] *= v.vec[1];
302  vec[2] *= v.vec[2];
303  }
304 
305  /// If you need a multiplication operator that left multiplies the vector
306  /// by a matrix (M * v), use the following colVecMult() functions. If
307  /// you'd rather not use operator*=() for right-multiplications (v * M),
308  /// use the following rowVecMult() functions. The methods that take a 4x4
309  /// matrix first extend this vector to 4D by adding an element equal to 1.0.
310  /// @internal These are implemented in UT_Matrix3.h and UT_Matrix4.h
311  // @{
320  // @}
321 
322 
323  /// This multiply will not extend the vector by adding a fourth element.
324  /// Instead, it converts the Matrix4 to a Matrix3. This means that
325  /// the translate component of the matrix is not applied to the vector
326  /// @internal These are implemented in UT_Matrix4.h
327  // @{
332  // @}
333 
334 
335 
336  /// The *=, multiply, multiply3 and multiplyT routines are provided for
337  /// legacy reasons. They all assume that *this is a row vector. Generally,
338  /// the rowVecMult and colVecMult methods are preferred, since they're
339  /// more explicit about the row vector assumption.
340  // @{
341  template <typename S>
343  template <typename S>
345 
346  template <typename S>
347  SYS_FORCE_INLINE void multiply3(const UT_Matrix4T<S> &mat);
348  // @}
349 
350  /// This multiply will multiply the (row) vector by the transpose of the
351  /// matrix instead of the matrix itself. This is faster than
352  /// transposing the matrix, then multiplying (as well there's potentially
353  /// less storage requirements).
354  // @{
355  template <typename S>
356  SYS_FORCE_INLINE void multiplyT(const UT_Matrix3T<S> &mat);
357  template <typename S>
358  SYS_FORCE_INLINE void multiply3T(const UT_Matrix4T<S> &mat);
359  // @}
360 
361  /// The following methods implement multiplies (row) vector by a matrix,
362  /// however, the resulting vector is specified by the dest parameter
363  /// These operations are safe even if "dest" is the same as "this".
364  // @{
365  template <typename S>
366  SYS_FORCE_INLINE void multiply3(UT_Vector3T<T> &dest,
367  const UT_Matrix4T<S> &mat) const;
368  template <typename S>
369  SYS_FORCE_INLINE void multiplyT(UT_Vector3T<T> &dest,
370  const UT_Matrix3T<S> &mat) const;
371  template <typename S>
372  SYS_FORCE_INLINE void multiply3T(UT_Vector3T<T> &dest,
373  const UT_Matrix4T<S> &mat) const;
374  template <typename S>
375  SYS_FORCE_INLINE void multiply(UT_Vector3T<T> &dest,
376  const UT_Matrix4T<S> &mat) const;
377  template <typename S>
378  SYS_FORCE_INLINE void multiply(UT_Vector3T<T> &dest,
379  const UT_Matrix3T<S> &mat) const;
380  // @}
381 
383  {
384  operator=(::cross(*this, v));
385  }
386 
388  {
389  vec[0] += (va.vec[2]+vb.vec[2])*(vb.vec[1]-va.vec[1]);
390  vec[1] += (va.vec[0]+vb.vec[0])*(vb.vec[2]-va.vec[2]);
391  vec[2] += (va.vec[1]+vb.vec[1])*(vb.vec[0]-va.vec[0]);
392  }
393 
394  /// Finds an arbitrary perpendicular to v, and sets this to it.
395  void arbitraryPerp(const UT_Vector3T<T> &v);
396  /// Makes this orthogonal to the given vector. If they are colinear,
397  /// does an arbitrary perp
398  void makeOrthonormal(const UT_Vector3T<T> &v);
399 
400  /// These allow you to find out what indices to use for different axes
401  // @{
402  int findMinAbsAxis() const
403  {
404  T ax = SYSabs(x()), ay = SYSabs(y());
405  if (ax < ay)
406  return (SYSabs(z()) < ax) ? 2 : 0;
407  else
408  return (SYSabs(z()) < ay) ? 2 : 1;
409  }
410  int findMaxAbsAxis() const
411  {
412  T ax = SYSabs(x()), ay = SYSabs(y());
413  if (ax >= ay)
414  return (SYSabs(z()) >= ax) ? 2 : 0;
415  else
416  return (SYSabs(z()) >= ay) ? 2 : 1;
417  }
418  // @}
419 
420  /// Given this vector as the z-axis, get a frame of reference such that the
421  /// X and Y vectors are orthonormal to the vector. This vector should be
422  /// normalized.
424  {
425  if (SYSabs(x()) < 0.6F) Y = UT_Vector3T<T>(1, 0, 0);
426  else if (SYSabs(z()) < 0.6F) Y = UT_Vector3T<T>(0, 1, 0);
427  else Y = UT_Vector3T<T>(0, 0, 1);
428  X = ::cross(Y, *this);
429  X.normalize();
430  Y = ::cross(*this, X);
431  }
432 
433  /// Calculates the orthogonal projection of a vector u on the *this vector
434  UT_Vector3T<T> project(const UT_Vector3T<T> &u) const;
435 
436  /// Create a matrix of projection onto this vector: the matrix transforms
437  /// a vector v into its projection on the direction of (*this) vector,
438  /// ie. dot(*this, v) * this->normalize();
439  /// If we need to be normalized, set norm to non-false.
440  template <typename S>
441  UT_Matrix3T<S> project(bool norm=true);
442 
443  /// Vector p (representing a point in 3-space) and vector v define
444  /// a line. This member returns the projection of "this" onto the
445  /// line (the point on the line that is closest to this point).
446  UT_Vector3T<T> projection(const UT_Vector3T<T> &p,
447  const UT_Vector3T<T> &v) const;
448 
449  /// Projects this onto the line segement [a,b]. The returned point
450  /// will lie between a and b.
451  UT_Vector3T<T> projectOnSegment(const UT_Vector3T<T> &va,
452  const UT_Vector3T<T> &vb) const;
453  /// Projects this onto the line segment [a, b]. The fpreal t is set
454  /// to the parametric position of intersection, a being 0 and b being 1.
455  UT_Vector3T<T> projectOnSegment(const UT_Vector3T<T> &va, const UT_Vector3T<T> &vb,
456  T &t) const;
457 
458  /// Create a matrix of symmetry around this vector: the matrix transforms
459  /// a vector v into its symmetry around (*this), ie. two times the
460  /// projection of v onto (*this) minus v.
461  /// If we need to be normalized, set norm to non-false.
462  UT_Matrix3 symmetry(bool norm=true);
463 
464  /// This method stores in (*this) the intersection between two 3D lines,
465  /// p1+t*v1 and p2+u*v2. If the two lines do not actually intersect, we
466  /// shift the 2nd line along the perpendicular on both lines (along the
467  /// line of min distance) and return the shifted intersection point; this
468  /// point thus lies on the 1st line.
469  /// If we find an intersection point (shifted or not) we return 0; if
470  /// the two lines are parallel we return -1; and if they intersect
471  /// behind our back we return -2. When we return -2 there still is a
472  /// valid intersection point in (*this).
473  int lineIntersect(const UT_Vector3T<T> &p1, const UT_Vector3T<T> &v1,
474  const UT_Vector3T<T> &p2, const UT_Vector3T<T> &v2);
475 
476  /// Compute the intersection of vector p2+t*v2 and the line segment between
477  /// points pa and pb. If the two lines do not intersect we shift the
478  /// (p2, v2) line along the line of min distance and return the point
479  /// where it intersects the segment. If we find an intersection point
480  /// along the stretch between pa and pb, we return 0. If the lines are
481  /// parallel we return -1. If they intersect before pa we return -2, and
482  /// if after pb, we return -3. The intersection point is valid with
483  /// return codes 0,-2,-3.
484  int segLineIntersect(const UT_Vector3T<T> &pa, const UT_Vector3T<T> &pb,
485  const UT_Vector3T<T> &p2, const UT_Vector3T<T> &v2);
486 
487  /// Determines whether or not the points p0, p1 and "this" are collinear.
488  /// If they are t contains the parametric value of where "this" is found
489  /// on the segment from p0 to p1 and returns true. Otherwise returns
490  /// false. If p0 and p1 are equal, t is set to
491  /// std::numeric_limits<T>::max() and true is returned.
492  bool areCollinear(const UT_Vector3T<T> &p0, const UT_Vector3T<T> &p1,
493  T *t = 0, T tol = 1e-5) const;
494 
495  /// Compute (homogeneous) barycentric co-ordinates of this point
496  /// relative to the triangle defined by t0, t1 and t2. (The point is
497  /// projected into the triangle's plane.)
498  UT_Vector3T<T> getBary(const UT_Vector3T<T> &t0, const UT_Vector3T<T> &t1,
499  const UT_Vector3T<T> &t2, bool *degen = NULL) const;
500 
501 
502  /// Compute the signed distance from us to a line.
503  T distance(const UT_Vector3T<T> &p1, const UT_Vector3T<T> &v1) const;
504  /// Compute the signed distance between two lines.
505  T distance(const UT_Vector3T<T> &p1, const UT_Vector3T<T> &v1,
506  const UT_Vector3T<T> &p2, const UT_Vector3T<T> &v2) const;
507 
508  /// Return the components of the vector. The () operator does NOT check
509  /// for the boundary condition.
510  /// @{
511  SYS_FORCE_INLINE T &x() { return vec[0]; }
512  SYS_FORCE_INLINE T x() const { return vec[0]; }
513  SYS_FORCE_INLINE T &y() { return vec[1]; }
514  SYS_FORCE_INLINE T y() const { return vec[1]; }
515  SYS_FORCE_INLINE T &z() { return vec[2]; }
516  SYS_FORCE_INLINE T z() const { return vec[2]; }
517  SYS_FORCE_INLINE T &r() { return vec[0]; }
518  SYS_FORCE_INLINE T r() const { return vec[0]; }
519  SYS_FORCE_INLINE T &g() { return vec[1]; }
520  SYS_FORCE_INLINE T g() const { return vec[1]; }
521  SYS_FORCE_INLINE T &b() { return vec[2]; }
522  SYS_FORCE_INLINE T b() const { return vec[2]; }
524  {
525  UT_ASSERT_P(i < tuple_size);
526  return vec[i];
527  }
528  SYS_FORCE_INLINE T operator()(unsigned i) const
529  {
530  UT_ASSERT_P(i < tuple_size);
531  return vec[i];
532  }
533  /// @}
534 
535  /// Compute a hash
536  unsigned hash() const { return SYSvector_hash(data(), tuple_size); }
537 
538  // TODO: eliminate these methods. They're redundant, given good inline
539  // constructors.
540  /// Set the values of the vector components
541  void assign(T xx = 0.0f, T yy = 0.0f, T zz = 0.0f)
542  {
543  vec[0] = xx; vec[1] = yy; vec[2] = zz;
544  }
545  /// Set the values of the vector components
546  void assign(const T *v)
547  {
548  vec[0]=v[0]; vec[1]=v[1]; vec[2]=v[2];
549  }
550 
551  /// Express the point in homogeneous coordinates or vice-versa
552  // @{
553  void homogenize()
554  {
555  vec[0] *= vec[2];
556  vec[1] *= vec[2];
557  }
559  {
560  if (vec[2] != 0)
561  {
562  T denom = 1.0f / vec[2];
563  vec[0] *= denom;
564  vec[1] *= denom;
565  }
566  }
567  // @}
568 
569  /// assuming that "this" is a rotation (in radians, of course), the
570  /// equivalent set of rotations which are closest to the "base" rotation
571  /// are found. The equivalent rotations are the same as the original
572  /// rotations +2*n*PI
573  void roundAngles(const UT_Vector3T<T> &base);
574 
575  /// conversion between degrees and radians
576  // @{
577  void degToRad();
578  void radToDeg();
579  // @}
580 
581  /// It seems that given any rotation matrix and transform order,
582  /// there are two distinct triples of rotations that will result in
583  /// the same overall rotation. This method will find the closest of
584  /// the two after finding the closest using the above method.
585  void roundAngles(const UT_Vector3T<T> &b, const UT_XformOrder &o);
586 
587  /// Return the dual of the vector
588  /// The dual is a matrix which acts like the cross product when
589  /// multiplied by other vectors.
590  /// The following are equivalent:
591  /// a.getDual(A); c = colVecMult(A, b)
592  /// c = cross(a, b)
593  template <typename S>
594  void getDual(UT_Matrix3T<S> &dual) const;
595 
596  /// Protected I/O methods
597  // @{
598  void save(std::ostream &os, bool binary = false) const;
599  bool load(UT_IStream &is);
600  // @}
601 
602  /// @{
603  /// Methods to serialize to a JSON stream. The vector is stored as an
604  /// array of 3 reals.
605  bool save(UT_JSONWriter &w) const;
606  bool save(UT_JSONValue &v) const;
607  bool load(UT_JSONParser &p);
608  /// @}
609 
610  /// @{
611  /// Method to return the angle (in radians) between this and another vector
613  {
614  return ::UTangleBetween(*this, v);
615  }
616  /// @}
617 
618  /// Returns the vector size
619  static int entries() { return tuple_size; }
620 
621 private:
622  /// I/O friends
623  // @{
624  friend std::ostream &operator<<(std::ostream &os, const UT_Vector3T<T> &v)
625  {
626  v.save(os);
627  return os;
628  }
629  // @}
630 };
631 
632 // Required for constructor
633 #include "UT_Vector2.h"
634 #include "UT_Vector4.h"
635 
636 template <typename T>
638 {
639  vec[0] = v.x();
640  vec[1] = v.y();
641  vec[2] = T(0);
642 }
643 template <typename T>
645 {
646  vec[0] = v.x();
647  vec[1] = v.y();
648  vec[2] = v.z();
649 }
650 
651 // Free floating functions:
652 template <typename T>
653 inline
655 {
656  return UT_Vector3T<T>(v1.x()+v2.x(), v1.y()+v2.y(), v1.z()+v2.z());
657 }
658 
659 template <typename T>
660 inline
662 {
663  return UT_Vector3T<T>(v1.x()-v2.x(), v1.y()-v2.y(), v1.z()-v2.z());
664 }
665 
666 template <typename T, typename S>
667 inline
669 {
670  return UT_Vector3T<T>(v.x()+scalar, v.y()+scalar, v.z()+scalar);
671 }
672 
673 template <typename T>
674 inline
676 {
677  return UT_Vector3T<T>(v1.x()*v2.x(), v1.y()*v2.y(), v1.z()*v2.z());
678 }
679 
680 template <typename T>
681 inline
683 {
684  return UT_Vector3T<T>(v1.x()/v2.x(), v1.y()/v2.y(), v1.z()/v2.z());
685 }
686 
687 template <typename T, typename S>
688 inline
690 {
691  return UT_Vector3T<T>(v.x()+scalar, v.y()+scalar, v.z()+scalar);
692 }
693 
694 template <typename T, typename S>
695 inline
697 {
698  return UT_Vector3T<T>(v.x()-scalar, v.y()-scalar, v.z()-scalar);
699 }
700 
701 template <typename T, typename S>
702 inline
704 {
705  return UT_Vector3T<T>(scalar-v.x(), scalar-v.y(), scalar-v.z());
706 }
707 
708 template <typename T, typename S>
709 inline
711 {
712  return UT_Vector3T<T>(v.x()*scalar, v.y()*scalar, v.z()*scalar);
713 }
714 
715 template <typename T, typename S>
716 inline
718 {
719  return UT_Vector3T<T>(v.x()*scalar, v.y()*scalar, v.z()*scalar);
720 }
721 
722 template <typename T, typename S>
723 inline
725 {
727  {
728  // This has to be T because S may be int for "v = v/2" code
729  // For the same reason we must cast the 1
730  T inv = ((T)1) / scalar;
731  return UT_Vector3T<T>(v.x()*inv, v.y()*inv, v.z()*inv);
732  }
733  return UT_Vector3T<T>(v.x()/scalar, v.y()/scalar, v.z()/scalar);
734 }
735 
736 template <typename T, typename S>
737 inline
739 {
740  return UT_Vector3T<T>(scalar/v.x(), scalar/v.y(), scalar/v.z());
741 }
742 
743 template <typename T>
744 inline
746 {
747  return v1.x()*v2.x() + v1.y()*v2.y() + v1.z()*v2.z();
748 }
749 
750 template <typename T>
751 inline
753 {
754  // compute the cross product:
755  return UT_Vector3T<T>(
756  v1.y()*v2.z() - v1.z()*v2.y(),
757  v1.z()*v2.x() - v1.x()*v2.z(),
758  v1.x()*v2.y() - v1.y()*v2.x()
759  );
760 }
761 
762 template <typename T>
763 inline
765 {
766  UT_Vector3T<fpreal64> v1crossv2 = cross(v1, v2);
767  fpreal v1dotv2 = dot(v1, v2);
768  return SYSatan2(v1crossv2.length(), v1dotv2);
769 }
770 
771 template <typename T>
772 inline
774 {
775  return UT_Vector3T<T>(SYSabs(v.x()), SYSabs(v.y()), SYSabs(v.z()));
776 }
777 
778 template <typename T>
779 inline
781 {
782  return UT_Vector3T<T>(
783  SYSmin(v1.x(), v2.x()),
784  SYSmin(v1.y(), v2.y()),
785  SYSmin(v1.z(), v2.z())
786  );
787 }
788 
789 template <typename T>
790 inline
792 {
793  return UT_Vector3T<T>(
794  SYSmax(v1.x(), v2.x()),
795  SYSmax(v1.y(), v2.y()),
796  SYSmax(v1.z(), v2.z())
797  );
798 }
799 
800 template <typename T,typename S>
801 inline
803 {
804  return UT_Vector3T<T>(
805  SYSlerp(v1.x(), v2.x(), t),
806  SYSlerp(v1.y(), v2.y(), t),
807  SYSlerp(v1.z(), v2.z(), t));
808 }
809 
810 template <typename T>
811 inline
813  const UT_Vector3T<T> &v2,
814  const UT_Vector3T<T> &t)
815 {
816  return UT_Vector3T<T>(
817  SYSlerp(v1.x(), v2.x(), t.x()),
818  SYSlerp(v1.y(), v2.y(), t.y()),
819  SYSlerp(v1.z(), v2.z(), t.z()));
820 }
821 
822 template <typename T>
823 inline
825  const UT_Vector3T<T> &v1,
826  const UT_Vector3T<T> &v2)
827 {
828  return UT_Vector3T<T>(
829  SYSinvlerp(a.x(), v1.x(), v2.x()),
830  SYSinvlerp(a.y(), v1.y(), v2.y()),
831  SYSinvlerp(a.z(), v1.z(), v2.z()));
832 }
833 
834 template <typename T>
835 inline
837  const UT_Vector3T<T> &min,
838  const UT_Vector3T<T> &max)
839 {
840  return UT_Vector3T<T>(
841  SYSclamp(v.x(), min.x(), max.x()),
842  SYSclamp(v.y(), min.y(), max.y()),
843  SYSclamp(v.z(), min.z(), max.z()));
844 }
845 
846 template <typename T>
847 inline
849 {
850  return SYSequalZero(v.x()) && SYSequalZero(v.y()) && SYSequalZero(v.z());
851 }
852 
853 template <typename T>
854 inline
856 {
857  return SYSisFinite(v.x()) && SYSisFinite(v.y()) && SYSisFinite(v.z());
858 }
859 
860 template <typename T>
861 inline
863 {
864  return UT_Vector3T<T>(SYSrecip(v[0]), SYSrecip(v[1]), SYSrecip(v[2]));
865 }
866 
867 template <typename T>
868 inline
870 {
871  return SYShat(v.x(), s.x()) * SYShat(v.y(), s.y()) * SYShat(v.z(), s.z());
872 }
873 
874 template <typename T>
875 inline
877 {
878  const T xhat = SYShat(v.x(), s.x());
879  const T yhat = SYShat(v.y(), s.y());
880  const T zhat = SYShat(v.z(), s.z());
881  return UT_Vector3T<T>(SYSdhat(v.x(), s.x()) * yhat * zhat,
882  xhat * SYSdhat(v.y(), s.y()) * zhat,
883  xhat * yhat * SYSdhat(v.z(), s.z()));
884 }
885 
886 template <typename T>
887 inline
889 {
890  return dot(u, v) / v.length2() * v;
891 }
892 
893 template <typename T>
894 inline
896 {
897  return (v1 - v2).length();
898 }
899 template <typename T>
900 inline
902 {
903  return (v1 - v2).length2();
904 }
905 
906 // calculate distance squared of pos to the line segment defined by pt1 to pt2
907 template <typename T>
908 inline
910  const UT_Vector3T<T> &pt1, const UT_Vector3T<T> &pt2 )
911 {
912  UT_Vector3T<T> vec;
913  T proj_t;
914  T veclen2;
915 
916  vec = pt2 - pt1;
917  proj_t = vec.dot( pos - pt1 );
918  veclen2 = vec.length2();
919 
920  if( proj_t <= (T)0.0 )
921  {
922  // in bottom cap region, calculate distance from pt1
923  vec = pos - pt1;
924  }
925  else if( proj_t >= veclen2 )
926  {
927  // in top cap region, calculate distance from pt2
928  vec = pos - pt2;
929  }
930  else
931  {
932  // middle region, calculate distance from projected pt
933  proj_t /= veclen2;
934  vec = (pt1 + (proj_t * vec)) - pos;
935  }
936 
937  return dot(vec, vec);
938 }
939 
940 // TODO: review the effiency of the following routine, there is a faster
941 // way to get just the distance.
942 template <typename T>
943 inline
945  const UT_Vector3T<T> &q0, const UT_Vector3T<T> &q1)
946 {
947  UT_Vector2 t = segmentClosest(p0, p1, q0, q1);
948  UT_Vector3 a = p0 + (p1 - p0) * t[0];
949  UT_Vector3 b = q0 + (q1 - q0) * t[1];
950  return distance2(a, b);
951 }
952 
953 template <typename T>
954 inline
956  const UT_Vector3T<T> &q0, const UT_Vector3T<T> &q1)
957 {
958  return SYSsqrt(segmentDistance2(p0, p1, q0, q1));
959 }
960 
961 /// Given a 3D position, input, and a 3D parallelpiped with corner p0 and
962 /// directions du, dv, and dw, finds the 0 or 1 locations in the parameter
963 /// space of that parallelpiped that correspond with the input position.
964 /// Only a parameter location approximately between 0 and 1
965 /// is accepted. The return value is the number of accepted parameter locations,
966 /// i.e. 0 or 1.
967 template <typename T>
969  const UT_Vector3T<T> &p0,
970  const UT_Vector3T<T> &du, const UT_Vector3T<T> &dv, const UT_Vector3T<T> &dw,
971  UT_Vector3T<T> &output)
972 {
973  const UT_Vector3T<T> orig = input - p0;
974 
975  const UT_Matrix3T<T> matrix(
976  du.x(), dv.x(), dw.x(),
977  du.y(), dv.y(), dw.y(),
978  du.z(), dv.z(), dw.z()
979  );
980 
981  bool failed = matrix.solve(orig.x(), orig.y(), orig.z(), output);
982  return !failed &&
983  SYSisGreaterOrEqual(output.x(), 0) && SYSisLessOrEqual(output.x(), 1) &&
984  SYSisGreaterOrEqual(output.y(), 0) && SYSisLessOrEqual(output.y(), 1) &&
985  SYSisGreaterOrEqual(output.z(), 0) && SYSisLessOrEqual(output.z(), 1);
986 }
987 
988 template <typename T>
989 inline size_t hash_value(const UT_Vector3T<T> &val)
990 {
991  return val.hash();
992 }
993 
994 // Overload for custom formatting of UT_Vector3T<T> with UTformat.
995 template<typename T>
996 UT_API size_t format(char *buffer, size_t buffer_size, const UT_Vector3T<T> &v);
997 
998 
999 template<typename T>
1001 {
1003  typedef T DataType;
1004  static const exint TupleSize = 3;
1005  static const bool isVectorType = true;
1006 };
1007 
1008 #endif
UT_Vector3T< T > rowVecMult(const UT_Vector3T< T > &v, const UT_Matrix3T< S > &m)
Definition: UT_Matrix3.h:1455
GLdouble s
Definition: glew.h:1390
SYS_FORCE_INLINE UT_Vector3T(const UT_Vector3T< S > &v)
Our own type of any given value_type.
Definition: UT_Vector3.h:260
UT_Vector3T< T > SYSlerp(const UT_Vector3T< T > &v1, const UT_Vector3T< T > &v2, S t)
Componentwise linear interpolation.
Definition: UT_Vector3.h:802
SYS_FORCE_INLINE constexpr const T * data() const noexcept
UT_API double intersectLines(const UT_Vector3T< T > &p1, const UT_Vector3T< T > &v1, const UT_Vector3T< T > &p2, const UT_Vector3T< T > &v2, T &t1, T &t2)
vint4 max(const vint4 &a, const vint4 &b)
Definition: simd.h:4703
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:582
GLenum GLenum GLenum input
Definition: glew.h:13879
T dot(const UT_Vector3T< T > &v1, const UT_Vector3T< T > &v2)
The dot and cross products between two vectors (see operator*() too)
Definition: UT_Vector3.h:745
SYS_FORCE_INLINE void operator*=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that)
int findMaxAbsAxis() const
These allow you to find out what indices to use for different axes.
Definition: UT_Vector3.h:410
UT_Vector3T< T > SYSrecip(const UT_Vector3T< T > &v)
Definition: UT_Vector3.h:862
int int32
Definition: SYS_Types.h:39
UT_Vector3T< T > SYSbilerp(const UT_Vector3T< T > &u0v0, const UT_Vector3T< T > &u1v0, const UT_Vector3T< T > &u0v1, const UT_Vector3T< T > &u1v1, S u, S v)
Bilinear interpolation.
Definition: UT_Vector3.h:100
T distance2(const UT_Vector3T< T > &p1, const UT_Vector3T< T > &p2)
Compute the distance squared.
Definition: UT_Vector3.h:901
T distance3d(const UT_Vector3T< T > &p1, const UT_Vector3T< T > &p2)
Compute the distance between two points.
Definition: UT_Vector3.h:895
int UTinverseTrilerpFlat(const UT_Vector3T< T > &input, const UT_Vector3T< T > &p0, const UT_Vector3T< T > &du, const UT_Vector3T< T > &dv, const UT_Vector3T< T > &dw, UT_Vector3T< T > &output)
Definition: UT_Vector3.h:968
UT_Vector3T< T > SYSabs(const UT_Vector3T< T > &v)
Definition: UT_Vector3.h:773
SYS_FORCE_INLINE ThisType & operator=(const ThisType &that)=default
SYS_FORCE_INLINE T operator()(unsigned i) const
Definition: UT_Vector3.h:528
void assign(const T *v)
Set the values of the vector components.
Definition: UT_Vector3.h:546
GLuint const GLfloat * val
Definition: glew.h:2794
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:598
#define SYS_DEPRECATED_HDK_REPLACE(__V__, __R__)
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:9477
fpreal64 UTangleBetween(const UT_Vector3T< T > &v1, const UT_Vector3T< T > &v2)
The angle between two vectors in radians.
Definition: UT_Vector3.h:764
int64 exint
Definition: SYS_Types.h:125
UT_Vector3T< T > SYSmin(const UT_Vector3T< T > &v1, const UT_Vector3T< T > &v2)
Componentwise min and maximum.
Definition: UT_Vector3.h:780
SYS_FORCE_INLINE T & g()
Definition: UT_Vector3.h:519
T segmentDistance(const UT_Vector3T< T > &p0, const UT_Vector3T< T > &p1, const UT_Vector3T< T > &a, const UT_Vector3T< T > &b)
Returns the distance between two line segments: p0-p1 and a-b.
Definition: UT_Vector3.h:955
UT_Vector3T< T > operator/(const UT_Vector3T< T > &v, S scalar)
Definition: UT_Vector3.h:724
unsigned hash() const
Compute a hash.
Definition: UT_Vector3.h:536
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:76
#define UT_API
Definition: UT_API.h:13
const GLdouble * m
Definition: glew.h:9124
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:34
const GLdouble * v
Definition: glew.h:1391
static const exint TupleSize
SYS_FORCE_INLINE T & r()
Definition: UT_Vector3.h:517
UT_Vector3T< T > SYStrihatgrad(const UT_Vector3T< T > &v, const UT_Vector3T< T > &s)
Gradient of trilinear hat function over kernel widths in s.
Definition: UT_Vector3.h:876
T SYStrihat(const UT_Vector3T< T > &v, const UT_Vector3T< T > &s)
Trilinear hat function over kernel widths in s.
Definition: UT_Vector3.h:869
3D Vector class.
4D Vector class.
Definition: UT_Vector4.h:166
2D Vector class.
Definition: UT_Vector2.h:149
float fpreal32
Definition: SYS_Types.h:200
T segmentPointDist2(const UT_Vector3T< T > &pos, const UT_Vector3T< T > &pt1, const UT_Vector3T< T > &pt2)
Definition: UT_Vector3.h:909
GLdouble GLdouble z
Definition: glew.h:1559
double fpreal64
Definition: SYS_Types.h:201
SYS_FORCE_INLINE T z() const
Definition: UT_Vector3.h:516
void getFrameOfReference(UT_Vector3T< T > &X, UT_Vector3T< T > &Y) const
Definition: UT_Vector3.h:423
SYS_FORCE_INLINE T & b()
Definition: UT_Vector3.h:521
SYS_FORCE_INLINE T & operator()(unsigned i)
Definition: UT_Vector3.h:523
GLfloat GLfloat GLfloat v2
Definition: glew.h:1856
SYS_FORCE_INLINE UT_Vector3T(const fpreal32 v[tuple_size])
Definition: UT_Vector3.h:242
SYS_FORCE_INLINE T & y()
Definition: UT_Vector3.h:513
SYS_FORCE_INLINE T y() const
Definition: UT_Vector3.h:514
GLclampf f
Definition: glew.h:3499
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
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:608
UT_API UT_Vector2T< T > segmentClosest(const UT_Vector3T< T > &p0, const UT_Vector3T< T > &p1, const UT_Vector3T< T > &a, const UT_Vector3T< T > &b)
void clampZero(T tol=T(0.00001f))
Definition: UT_Vector3.h:290
GLuint buffer
Definition: glew.h:1680
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:134
const GLuint GLenum const void * binary
Definition: glew.h:3502
size_t hash_value(const UT_Vector3T< T > &val)
Definition: UT_Vector3.h:989
static const bool isVectorType
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
SYS_FORCE_INLINE T & z()
Definition: UT_Vector3.h:515
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
SYS_FORCE_INLINE UT_Vector3T(const int64 v[tuple_size])
Definition: UT_Vector3.h:251
UT_Vector3T< T > SYSclamp(const UT_Vector3T< T > &v, const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
Definition: UT_Vector3.h:836
static int entries()
Returns the vector size.
Definition: UT_Vector3.h:619
GLsizei GLsizei GLfloat distance
Definition: glew.h:13640
SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, T >::Type length2() const noexcept
UT_Vector3T< T > SYSmax(const UT_Vector3T< T > &v1, const UT_Vector3T< T > &v2)
Definition: UT_Vector3.h:791
UT_Vector3T< T > SYSbarycentric(const UT_Vector3T< T > &v0, const UT_Vector3T< T > &v1, const UT_Vector3T< T > &v2, S u, S v)
Barycentric interpolation.
Definition: UT_Vector3.h:107
class UT_API UT_Vector3T
long long int64
Definition: SYS_Types.h:116
UT_API UT_Vector2T< T > segmentClosestParallel(const UT_Vector3T< T > &p0, const UT_Vector3T< T > &p1, const UT_Vector3T< T > &a, const UT_Vector3T< T > &b)
T segmentDistance2(const UT_Vector3T< T > &p0, const UT_Vector3T< T > &p1, const UT_Vector3T< T > &a, const UT_Vector3T< T > &b)
Returns the squared distance between two line segments: p0-p1 and a-b.
Definition: UT_Vector3.h:944
SYS_FORCE_INLINE UT_Vector3T(T v)
Definition: UT_Vector3.h:226
GridType::Ptr normalize(const GridType &grid, bool threaded, InterruptT *interrupt)
Normalize the vectors of the given vector-valued grid.
UT_Vector3T< T > colVecMult3(const UT_Matrix4T< S > &m, const UT_Vector3T< T > &v)
Definition: UT_Matrix4.h:1841
SYS_FORCE_INLINE UT_StorageNum< typename UT_StorageBetter< T, S >::Type >::MathFloat distance(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const
SYS_FORCE_INLINE UT_Vector3T(const fpreal64 v[tuple_size])
Definition: UT_Vector3.h:245
bool SYSisFinite(const UT_Vector3T< T > &v)
Definition: UT_Vector3.h:855
void dehomogenize()
Express the point in homogeneous coordinates or vice-versa.
Definition: UT_Vector3.h:558
SYS_FORCE_INLINE UT_Vector3T< T > operator-() const
Definition: UT_Vector3.h:285
UT_FixedVector< T, 3, true > Base
Definition: UT_Vector3.h:200
bool SYSequalZero(const UT_Vector3T< T > &v)
Definition: UT_Vector3.h:848
SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, S >::Type dot(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const
SYS_FORCE_INLINE UT_Vector3T(const int32 v[tuple_size])
Definition: UT_Vector3.h:248
GLdouble GLdouble GLdouble b
Definition: glew.h:9122
void assign(T xx=0.0f, T yy=0.0f, T zz=0.0f)
Set the values of the vector components.
Definition: UT_Vector3.h:541
GLfloat GLfloat p
Definition: glew.h:16321
SYS_FORCE_INLINE UT_Vector3T< T > & operator=(const UT_Vector3T< S > &v)
Definition: UT_Vector3.h:274
void homogenize()
Express the point in homogeneous coordinates or vice-versa.
Definition: UT_Vector3.h:553
SYS_FORCE_INLINE T g() const
Definition: UT_Vector3.h:520
UT_Vector3T< T > SYSinvlerp(const UT_Vector3T< T > &a, const UT_Vector3T< T > &v1, const UT_Vector3T< T > &v2)
Componentwise inverse linear interpolation.
Definition: UT_Vector3.h:824
UT_API bool intersectSegments(const UT_Vector3T< T > &p0, const UT_Vector3T< T > &p1, const UT_Vector3T< T > &a, const UT_Vector3T< T > &b, T &t)
UT_Vector3T< T > rowVecMult3(const UT_Vector3T< T > &v, const UT_Matrix4T< S > &m)
Definition: UT_Matrix4.h:1819
SYS_FORCE_INLINE UT_Vector3T(T vx, T vy, T vz)
Definition: UT_Vector3.h:233
fpreal64 fpreal
Definition: SYS_Types.h:277
UT_FixedVector< T, 3 > FixedVectorType
Definition: UT_Vector3.h:1002
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Definition: glew.h:12681
UT_Vector3T< T > colVecMult(const UT_Matrix3T< S > &m, const UT_Vector3T< T > &v)
Definition: UT_Matrix3.h:1473
UT_Vector3T< T > cross(const UT_Vector3T< T > &v1, const UT_Vector3T< T > &v2)
The dot and cross products between two vectors (see operator*() too)
Definition: UT_Vector3.h:752
GLfloat v0
Definition: glew.h:1848
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:77
SYS_FORCE_INLINE T & x()
Definition: UT_Vector3.h:511
SYS_FORCE_INLINE Storage::MathFloat normalize()
SYS_FORCE_INLINE T b() const
Definition: UT_Vector3.h:522
SYS_FORCE_INLINE UT_Vector3T()=default
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition: glew.h:12681
UT_Vector3T< T > project(const UT_Vector3T< T > &u, const UT_Vector3T< T > &v)
The orthogonal projection of a vector u onto a vector v.
Definition: UT_Vector3.h:888
SYS_FORCE_INLINE UT_Vector3T(const UT_FixedVector< S, tuple_size, S_INSTANTIATED > &v)
Arbitrary UT_FixedVector of the same size.
Definition: UT_Vector3.h:266
vint4 min(const vint4 &a, const vint4 &b)
Definition: simd.h:4694
SYS_FORCE_INLINE void normal(const UT_Vector3T< T > &va, const UT_Vector3T< T > &vb)
Definition: UT_Vector3.h:387
SYS_FORCE_INLINE void multiplyComponents(const UT_Vector3T< T > &v)
Definition: UT_Vector3.h:298
SYS_FORCE_INLINE Storage::MathFloat length() const
SYS_FORCE_INLINE UT_Vector3T(const fpreal16 v[tuple_size])
Definition: UT_Vector3.h:239
GLdouble GLdouble t
Definition: glew.h:1398
SYS_FORCE_INLINE T r() const
Definition: UT_Vector3.h:518
GLfloat GLfloat v1
Definition: glew.h:1852
GLuint GLenum matrix
Definition: glew.h:14742
SYS_FORCE_INLINE T x() const
Definition: UT_Vector3.h:512
UT_API size_t format(char *buffer, size_t buffer_size, const UT_Vector3T< T > &v)
fpreal64 angleTo(const UT_Vector3T< T > &v) const
Definition: UT_Vector3.h:612
SYS_FORCE_INLINE void cross(const UT_Vector3T< T > &v)
Definition: UT_Vector3.h:382
int findMinAbsAxis() const
These allow you to find out what indices to use for different axes.
Definition: UT_Vector3.h:402