HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Vector2.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_Vector2.h (C++)
7  *
8  *
9  * COMMENTS:
10  * This class handles fpreal vectors of dimension 2.
11  *
12  * WARNING:
13  * This class should NOT contain any virtual methods, nor should it
14  * define more member data. The size of UT_VectorF2 must always be
15  * 8 bytes (2 floats).
16  */
17 
18 #pragma once
19 
20 #ifndef __UT_Vector2_h__
21 #define __UT_Vector2_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_Math.h>
28 #include <SYS/SYS_Inline.h>
29 #include <VM/VM_SIMD.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 // Operators that involve a UT_Vector2 object:
41 template <typename T>
43 template <typename T>
45 template <typename T>
46 inline bool operator<(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2);
47 template <typename T>
48 inline bool operator<=(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2);
49 template <typename T>
50 inline bool operator>(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2);
51 template <typename T>
52 inline bool operator>=(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2);
53 template <typename T, typename S>
54 inline UT_Vector2T<T> operator+(const UT_Vector2T<T> &v, S scalar);
55 template <typename T, typename S>
56 inline UT_Vector2T<T> operator-(const UT_Vector2T<T> &v, S scalar);
57 template <typename T, typename S>
58 inline UT_Vector2T<T> operator*(const UT_Vector2T<T> &v, S scalar);
59 template <typename T, typename S>
60 inline UT_Vector2T<T> operator/(const UT_Vector2T<T> &v, S scalar);
61 template <typename T, typename S>
62 inline UT_Vector2T<T> operator+(S scalar, const UT_Vector2T<T> &v);
63 template <typename T, typename S>
64 inline UT_Vector2T<T> operator-(S scalar, const UT_Vector2T<T> &v);
65 template <typename T, typename S>
66 inline UT_Vector2T<T> operator*(S scalar, const UT_Vector2T<T> &v);
67 template <typename T, typename S>
68 inline UT_Vector2T<T> operator/(S scalar, const UT_Vector2T<T> &v);
69 template <typename T, typename S>
71  const UT_Matrix2T<S> &mat);
72 
73 /// The dot product
74 template <typename T>
75 inline T dot (const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2);
76 /// Cross product, which for 2d vectors results in a fpreal.
77 template <typename T>
78 inline T cross (const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2);
79 
80 /// Componentwise min and maximum
81 template <typename T>
82 inline UT_Vector2T<T> SYSmin (const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2);
83 template <typename T>
84 inline UT_Vector2T<T> SYSmax (const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2);
85 /// Componentwise linear interpolation
86 template <typename T,typename S>
87 inline UT_Vector2T<T> SYSlerp(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2, S t);
88 
89 /// Componentwise inverse linear interpolation
90 template <typename T>
92 
93 /// Bilinear interpolation
94 template <typename T,typename S>
95 inline UT_Vector2T<T> SYSbilerp(const UT_Vector2T<T> &u0v0, const UT_Vector2T<T> &u1v0,
96  const UT_Vector2T<T> &u0v1, const UT_Vector2T<T> &u1v1, S u, S v)
97 { return SYSlerp(SYSlerp(u0v0, u0v1, v), SYSlerp(u1v0, u1v1, v), u); }
98 
99 /// Barycentric interpolation
100 template <typename T, typename S>
102  const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2, S u, S v)
103 { return v0 * (1 - u - v) + v1 * u + v2 *v; }
104 
105 /// The orthogonal projection of a vector u onto a vector v
106 template <typename T>
107 inline UT_Vector2T<T> project (const UT_Vector2T<T> &u, const UT_Vector2T<T> &v);
108 
109 /// Multiplication of a row or column vector by a matrix (ie. right vs. left
110 /// multiplication respectively). The operator*() declared above is an alias
111 /// for rowVecMult().
112 // @{
113 //
114 // Notes on optimisation of matrix/vector multiplies:
115 // - multiply(dest, mat) functions have been deprecated in favour of
116 // rowVecMult/colVecMult routines, which produce temporaries. For these to
117 // offer comparable performance, the compiler has to optimize away the
118 // temporary, but most modern compilers can do this. Performance tests with
119 // gcc3.3 indicate that this is a realistic expectation for modern
120 // compilers.
121 // - since matrix/vector multiplies cannot be done without temporary data,
122 // the "primary" functions are the global matrix/vector
123 // rowVecMult/colVecMult routines, rather than the member functions.
124 
125 template <typename T, typename S>
127  const UT_Matrix2T<S> &m);
128 template <typename T, typename S>
130  const UT_Vector2T<T> &v);
131 // @}
132 
133 template <typename T>
134 inline T distance2d(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2);
135 
136 /// Given a 2D position, input, and a 2D quad, (p0, p0+du, p0+du+dv+duv, p0+dv),
137 /// finds the 0, 1, or 2 locations in the parameter space of that quad that correspond
138 /// with the input position. Only parameter locations approximately between 0 and 1
139 /// are accepted. The return value is the number of accepted parameter locations.
140 template <typename T>
142  const UT_Vector2T<T> &p0,
143  const UT_Vector2T<T> &du, const UT_Vector2T<T> &dv,
144  const UT_Vector2T<T> &duv,
145  UT_Vector2T<T> outputs[2]);
146 
147 /// 2D Vector class.
148 template <typename T>
149 class UT_API UT_Vector2T : public UT_FixedVector<T,2,true>
150 {
151 public:
153 
154  // These "using" statements are needed for operator= and operator*=
155  // so that the ones in UT_FixedVector aren't hidden by the additional
156  // ones here.
157  using Base::operator=;
158  using Base::operator*=;
159 
160  // These "using" statements are needed for GCC and Clang, because
161  // otherwise, they ignore all members of UT_FixedVector when
162  // checking validity of code in functions in this class.
163  using Base::vec;
164  using Base::data;
165  using Base::length2;
166  typedef T value_type;
167  static const int tuple_size = 2;
168 
169  /// Default constructor.
170  /// No data is initialized! Use it for extra speed.
171  SYS_FORCE_INLINE UT_Vector2T() = default;
172 
173  SYS_FORCE_INLINE UT_Vector2T(const UT_Vector2T<T> &that) = default;
174  SYS_FORCE_INLINE UT_Vector2T(UT_Vector2T<T> &&that) = default;
175 
177  {
178  vec[0] = v;
179  vec[1] = v;
180  }
181 
183  {
184  vec[0] = vx;
185  vec[1] = vy;
186  }
187  explicit SYS_FORCE_INLINE UT_Vector2T(const fpreal16 v[tuple_size])
188  : Base(v)
189  {}
190  explicit SYS_FORCE_INLINE UT_Vector2T(const fpreal32 v[tuple_size])
191  : Base(v)
192  {}
193  explicit SYS_FORCE_INLINE UT_Vector2T(const fpreal64 v[tuple_size])
194  : Base(v)
195  {}
196  explicit SYS_FORCE_INLINE UT_Vector2T(const int32 v[tuple_size])
197  : Base(v)
198  {}
199  explicit SYS_FORCE_INLINE UT_Vector2T(const int64 v[tuple_size])
200  : Base(v)
201  {}
202  explicit UT_Vector2T(const UT_Vector3T<T> &v);
203  explicit UT_Vector2T(const UT_Vector4T<T> &v);
204 
205  /// Our own type of any given value_type.
206  template <typename S>
208  : Base(v)
209  {}
210 
211  /// Arbitrary UT_FixedVector of the same size
212  template <typename S,bool S_INSTANTIATED>
214  : Base(v)
215  {}
216 
219 
220  template <typename S>
222  { vec[0] = v.x(); vec[1] = v.y(); return *this; }
223 
224  // TODO: remove these. They should require an explicit UT_Vector2()
225  // construction, since they're unsafe.
226 
227  /// Assignment operator that truncates a V3 to a V2.
229  /// Assignment operator that truncates a V4 to a V2.
231 
232  /// It's unclear why this is needed, given UT_FixedVector::operator-(),
233  /// but the compiler seems not to accept not having it.
235  {
236  return UT_Vector2T<T>(-vec[0], -vec[1]);
237  }
239  {
240  vec[0] *= v.vec[0];
241  vec[1] *= v.vec[1];
242  }
243 
244  /// Given an oriented line from e1 passing through e2, determine on which
245  /// side of the line the point p lies. Alternatively, determine in which
246  /// half plane, positive or negative, the point lies. If the segment
247  /// degenerates to a point, then the point is always on it.
248  // (Moret and Shapiro 1991)
249  T whichSide(const UT_Vector2T<T> &e1, const UT_Vector2T<T> &e2) const
250  {
251  return (vec[0] - e1.vec[0]) * (e2.vec[1] - e1.vec[1]) -
252  (vec[1] - e1.vec[1]) * (e2.vec[0] - e1.vec[0]);
253  }
254 
255  template <typename S>
257  { return operator=(*this * mat); }
258 
259  /// These allow you to find out what indices to use for different axes
260  // @{
261  int findMinAbsAxis() const
262  {
263  if (SYSabs(x()) < SYSabs(y()))
264  return 0;
265  else
266  return 1;
267  }
268  int findMaxAbsAxis() const
269  {
270  if (SYSabs(x()) >= SYSabs(y()))
271  return 0;
272  else
273  return 1;
274  }
275  // @}
276 
277  /// Calculates the orthogonal projection of a vector u on the *this vector
278  UT_Vector2T<T> project(const UT_Vector2T<T> &u) const;
279 
280 
281  /// Vector p (representing a point in 2-space) and vector v define
282  /// a line. This member returns the projection of "this" onto the
283  /// line (the point on the line that is closest to this point).
284  UT_Vector2T<T> projection(const UT_Vector2T<T> &p, const UT_Vector2T<T> &v) const;
285 
286  /// Compute (homogeneous) barycentric co-ordinates of this point
287  /// relative to the triangle defined by t0, t1 and t2. (The point is
288  /// projected into the triangle's plane.)
289  UT_Vector3T<T> getBary(const UT_Vector2T<T> &t0, const UT_Vector2T<T> &t1,
290  const UT_Vector2T<T> &t2, bool *degen = NULL) const;
291 
292 
293  /// Return the components of the vector. The () operator does NOT check
294  /// for the boundary condition.
295  // @{
296  T &x() { return vec[0]; }
297  T x() const { return vec[0]; }
298  T &y() { return vec[1]; }
299  T y() const { return vec[1]; }
300  T &operator()(unsigned i)
301  {
302  UT_ASSERT_P(i < tuple_size);
303  return vec[i];
304  }
305  T operator()(unsigned i) const
306  {
307  UT_ASSERT_P(i < tuple_size);
308  return vec[i];
309  }
310  // @}
311 
312  /// Compute a hash
313  unsigned hash() const { return SYSvector_hash(data(), tuple_size); }
314 
315  // TODO: eliminate these methods. They're redundant, given good inline
316  // constructors.
317  /// Set the values of the vector components
318  void assign(T xx = 0.0f, T yy = 0.0f)
319  {
320  vec[0] = xx; vec[1] = yy;
321  }
322  /// Set the values of the vector components
323  void assign(const T *v) {vec[0]=v[0]; vec[1]=v[1];}
324 
325  /// Express the point in homogeneous coordinates or vice-versa
326  // @{
327  void homogenize () { vec[0] *= vec[1]; }
328  void dehomogenize() { if (vec[1] != 0) vec[0] /= vec[1]; }
329  // @}
330 
331  /// Protected I/O methods
332  // @{
333  void save(std::ostream &os, int binary = 0) const;
334  bool load(UT_IStream &is);
335  // @}
336 
337  /// @{
338  /// Methods to serialize to a JSON stream. The vector is stored as an
339  /// array of 2 reals.
340  bool save(UT_JSONWriter &w) const;
341  bool save(UT_JSONValue &v) const;
342  bool load(UT_JSONParser &p);
343  /// @}
344 
345  /// Returns the vector size
346  static int entries() { return tuple_size; }
347 
348 private:
349  /// I/O friends
350  // @{
351  friend std::ostream &operator<<(std::ostream &os, const UT_Vector2T<T> &v)
352  {
353  v.save(os);
354  return os;
355  }
356  // @}
357 };
358 
359 #include "UT_Matrix2.h"
360 
361 // Free floating functions:
362 template <typename T>
364 {
365  return UT_Vector2T<T>(v1.x()+v2.x(), v1.y()+v2.y());
366 }
367 template <typename T>
369 {
370  return UT_Vector2T<T>(v1.x()-v2.x(), v1.y()-v2.y());
371 }
372 template <typename T>
374 {
375  return UT_Vector2T<T>(v1.x()*v2.x(), v1.y()*v2.y());
376 }
377 template <typename T>
379 {
380  return UT_Vector2T<T>(v1.x()/v2.x(), v1.y()/v2.y());
381 }
382 template <typename T>
383 inline bool operator<(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2)
384 {
385  return ((v1.x() < v2.x()) || (v1.x() == v2.x() && v1.y() < v2.y()));
386 }
387 template <typename T>
388 inline bool operator<=(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2)
389 {
390  return (v1 < v2) || (v1 == v2);
391 }
392 template <typename T>
393 inline bool operator>(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2)
394 {
395  return v2 < v1;
396 }
397 template <typename T>
398 inline bool operator>=(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2)
399 {
400  return v2 <= v1;
401 }
402 template <typename T, typename S>
403 inline UT_Vector2T<T> operator+(const UT_Vector2T<T> &v, S scalar)
404 {
405  return UT_Vector2T<T>(v.x()+scalar, v.y()+scalar);
406 }
407 template <typename T, typename S>
408 inline UT_Vector2T<T> operator+(S scalar, const UT_Vector2T<T> &v)
409 {
410  return UT_Vector2T<T>(v.x()+scalar, v.y()+scalar);
411 }
412 template <typename T, typename S>
413 inline UT_Vector2T<T> operator-(const UT_Vector2T<T> &v, S scalar)
414 {
415  return UT_Vector2T<T>(v.x()-scalar, v.y()-scalar);
416 }
417 template <typename T, typename S>
418 inline UT_Vector2T<T> operator-(S scalar, const UT_Vector2T<T> &v)
419 {
420  return UT_Vector2T<T>(scalar-v.x(), scalar-v.y());
421 }
422 template <typename T, typename S>
423 inline UT_Vector2T<T> operator*(const UT_Vector2T<T> &v, S scalar)
424 {
425  return UT_Vector2T<T>(v.x()*scalar, v.y()*scalar);
426 }
427 template <typename T, typename S>
428 inline UT_Vector2T<T> operator*(S scalar, const UT_Vector2T<T> &v)
429 {
430  return UT_Vector2T<T>(v.x()*scalar, v.y()*scalar);
431 }
432 template <typename T, typename S>
433 inline UT_Vector2T<T> operator/(const UT_Vector2T<T> &v, S scalar)
434 {
435  return UT_Vector2T<T>(v.x()/scalar, v.y()/scalar);
436 }
437 template <typename T, typename S>
438 inline UT_Vector2T<T> operator/(S scalar, const UT_Vector2T<T> &v)
439 {
440  return UT_Vector2T<T>(scalar/v.x(), scalar/v.y());
441 }
442 template <typename T>
443 inline T dot(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2)
444 {
445  return v1.x()*v2.x() + v1.y()*v2.y();
446 }
447 template <typename T>
448 inline T cross(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2)
449 {
450  return v1.x() * v2.y() - v1.y() * v2.x();
451 }
452 template <typename T>
453 inline
455 {
456  return UT_Vector2T<T>(SYSabs(v.x()), SYSabs(v.y()));
457 }
458 
459 
460 template <typename T>
461 inline
463 {
464  return UT_Vector2T<T>(
465  SYSmin(v1.x(), v2.x()),
466  SYSmin(v1.y(), v2.y())
467  );
468 }
469 
470 template <typename T>
471 inline
473 {
474  return UT_Vector2T<T>(
475  SYSmax(v1.x(), v2.x()),
476  SYSmax(v1.y(), v2.y())
477  );
478 }
479 
480 template <typename T,typename S>
481 inline
483 {
484  return UT_Vector2T<T>(
485  SYSlerp(v1.x(), v2.x(), t),
486  SYSlerp(v1.y(), v2.y(), t));
487 }
488 
489 template <typename T>
490 inline
492  const UT_Vector2T<T> &v1,
493  const UT_Vector2T<T> &v2)
494 {
495  return UT_Vector2T<T>(
496  SYSinvlerp(a.x(), v1.x(), v2.x()),
497  SYSinvlerp(a.y(), v1.y(), v2.y()));
498 }
499 
500 template <typename T>
502 {
503  return dot(u, v) / v.length2() * v;
504 }
505 template <typename T, typename S>
507 {
508  return UT_Vector2T<T>(v.x()*m(0,0) + v.y()*m(1,0),
509  v.x()*m(0,1) + v.y()*m(1,1));
510 }
511 template <>
513 {
514  const v4uf l(v.x(), v.x(), v.y(), v.y());
515  const v4uf r(m.data());
516  const v4uf p = l * r;
517 
518  return UT_Vector2T<float>(p[0] + p[2], p[1] + p[3]);
519 }
520 template <typename T, typename S>
522 {
523  return UT_Vector2T<T>(m(0,0)*v.x() + m(0,1)*v.y(),
524  m(1,0)*v.x() + m(1,1)*v.y());
525 }
526 template <>
528 {
529  const v4uf l(m.data());
530  const v4uf r(v.x(), v.y(), v.x(), v.y());
531  const v4uf p = l * r;
532  return UT_Vector2T<float>(p[0] + p[1], p[2] + p[3]);
533 }
534 template <typename T, typename S>
536 {
537  return rowVecMult(v, m);
538 }
539 template <typename T>
541 {
542  return (v1 - v2).length();
543 }
544 
545 template <typename T>
546 inline size_t hash_value(const UT_Vector2T<T> &val)
547 {
548  return val.hash();
549 }
550 
551 // Overload for custom formatting of UT_Vector2T<T> with UTformat.
552 template<typename T>
553 UT_API size_t format(char *buffer, size_t buffer_size, const UT_Vector2T<T> &v);
554 
555 
556 template<typename T>
558 {
560  typedef T DataType;
561  static const exint TupleSize = 2;
562  static const bool isVectorType = true;
563 };
564 
565 #endif
SYS_FORCE_INLINE constexpr const T * data() const noexcept
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
UT_Vector2T< T > SYSabs(const UT_Vector2T< T > &v)
Definition: UT_Vector2.h:454
GLenum GLenum GLenum input
Definition: glew.h:13879
SYS_FORCE_INLINE UT_Vector2T(const fpreal16 v[tuple_size])
Definition: UT_Vector2.h:187
class UT_API UT_Vector2T
int int32
Definition: SYS_Types.h:39
SYS_FORCE_INLINE UT_Vector2T(T vx, T vy)
Definition: UT_Vector2.h:182
UT_FixedVector< T, 2 > FixedVectorType
Definition: UT_Vector2.h:559
T & operator()(unsigned i)
Definition: UT_Vector2.h:300
UT_Vector2T< T > rowVecMult(const UT_Vector2T< T > &v, const UT_Matrix2T< S > &m)
Definition: UT_Vector2.h:506
static int entries()
Returns the vector size.
Definition: UT_Vector2.h:346
int findMinAbsAxis() const
These allow you to find out what indices to use for different axes.
Definition: UT_Vector2.h:261
T whichSide(const UT_Vector2T< T > &e1, const UT_Vector2T< T > &e2) const
Definition: UT_Vector2.h:249
T x() const
Definition: UT_Vector2.h:297
SYS_FORCE_INLINE ThisType & operator=(const ThisType &that)=default
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
UT_Vector2T< T > operator/(const UT_Vector2T< T > &v, S scalar)
Definition: UT_Vector2.h:433
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:9477
int64 exint
Definition: SYS_Types.h:125
void assign(const T *v)
Set the values of the vector components.
Definition: UT_Vector2.h:323
T y() const
Definition: UT_Vector2.h:299
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
GLdouble l
Definition: glew.h:9122
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:34
const GLdouble * v
Definition: glew.h:1391
static const exint TupleSize
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 cross(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Cross product, which for 2d vectors results in a fpreal.
Definition: UT_Vector2.h:448
SYS_FORCE_INLINE UT_Vector2T(T v)
Definition: UT_Vector2.h:176
UT_Vector2T< T > & operator*=(const UT_Matrix2T< S > &mat)
Definition: UT_Vector2.h:256
double fpreal64
Definition: SYS_Types.h:201
GLfloat GLfloat GLfloat v2
Definition: glew.h:1856
SYS_FORCE_INLINE UT_Vector2T(const int32 v[tuple_size])
Definition: UT_Vector2.h:196
UT_Vector2T< T > SYSlerp(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2, S t)
Componentwise linear interpolation.
Definition: UT_Vector2.h:482
UT_Vector2T< T > SYSbarycentric(const UT_Vector2T< T > &v0, const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2, S u, S v)
Barycentric interpolation.
Definition: UT_Vector2.h:101
int findMaxAbsAxis() const
These allow you to find out what indices to use for different axes.
Definition: UT_Vector2.h:268
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
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
int UTinverseBilerp(const UT_Vector2T< T > &input, const UT_Vector2T< T > &p0, const UT_Vector2T< T > &du, const UT_Vector2T< T > &dv, const UT_Vector2T< T > &duv, UT_Vector2T< T > outputs[2])
unsigned hash() const
Compute a hash.
Definition: UT_Vector2.h:313
UT_Vector2T< T > project(const UT_Vector2T< T > &u, const UT_Vector2T< T > &v)
The orthogonal projection of a vector u onto a vector v.
Definition: UT_Vector2.h:501
static const bool isVectorType
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
T dot(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
The dot product.
Definition: UT_Vector2.h:443
bool operator>=(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Definition: UT_Vector2.h:398
Definition: VM_SIMD.h:186
SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, T >::Type length2() const noexcept
long long int64
Definition: SYS_Types.h:116
UT_Vector2T< T > SYSinvlerp(const UT_Vector2T< T > &a, const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Componentwise inverse linear interpolation.
Definition: UT_Vector2.h:491
UT_Vector2T< T > SYSbilerp(const UT_Vector2T< T > &u0v0, const UT_Vector2T< T > &u1v0, const UT_Vector2T< T > &u0v1, const UT_Vector2T< T > &u1v1, S u, S v)
Bilinear interpolation.
Definition: UT_Vector2.h:95
UT_API size_t format(char *buffer, size_t buffer_size, const UT_Vector2T< T > &v)
bool operator>(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Definition: UT_Vector2.h:393
SYS_FORCE_INLINE UT_Vector2T< T > operator-() const
Definition: UT_Vector2.h:234
void multiplyComponents(const UT_Vector2T< T > &v)
Definition: UT_Vector2.h:238
SYS_FORCE_INLINE UT_Vector2T(const fpreal32 v[tuple_size])
Definition: UT_Vector2.h:190
GLfloat GLfloat p
Definition: glew.h:16321
UT_Vector2T< T > SYSmax(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Definition: UT_Vector2.h:472
SYS_FORCE_INLINE UT_Vector2T(const int64 v[tuple_size])
Definition: UT_Vector2.h:199
size_t hash_value(const UT_Vector2T< T > &val)
Definition: UT_Vector2.h:546
T operator()(unsigned i) const
Definition: UT_Vector2.h:305
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Definition: glew.h:12681
GLdouble GLdouble GLdouble r
Definition: glew.h:1406
GLfloat v0
Definition: glew.h:1848
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:77
SYS_FORCE_INLINE UT_Vector2T< T > & operator=(const UT_Vector2T< S > &v)
Definition: UT_Vector2.h:221
void assign(T xx=0.0f, T yy=0.0f)
Set the values of the vector components.
Definition: UT_Vector2.h:318
UT_Vector2T< T > SYSmin(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Componentwise min and maximum.
Definition: UT_Vector2.h:462
SYS_FORCE_INLINE UT_Vector2T(const UT_FixedVector< S, tuple_size, S_INSTANTIATED > &v)
Arbitrary UT_FixedVector of the same size.
Definition: UT_Vector2.h:213
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition: glew.h:12681
const T * data() const
Return the raw matrix data.
Definition: UT_Matrix2.h:397
UT_Vector2T< T > colVecMult(const UT_Matrix2T< S > &m, const UT_Vector2T< T > &v)
Definition: UT_Vector2.h:521
SYS_FORCE_INLINE UT_Vector2T(const fpreal64 v[tuple_size])
Definition: UT_Vector2.h:193
GLdouble GLdouble t
Definition: glew.h:1398
GLfloat GLfloat v1
Definition: glew.h:1852
void dehomogenize()
Express the point in homogeneous coordinates or vice-versa.
Definition: UT_Vector2.h:328
SYS_FORCE_INLINE UT_Vector2T(const UT_Vector2T< S > &v)
Our own type of any given value_type.
Definition: UT_Vector2.h:207
T distance2d(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Definition: UT_Vector2.h:540
UT_FixedVector< T, 2, true > Base
Definition: UT_Vector2.h:152
void homogenize()
Express the point in homogeneous coordinates or vice-versa.
Definition: UT_Vector2.h:327