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 
167  typedef T value_type;
168  static constexpr int tuple_size = 2;
169 
170  /// Default constructor.
171  /// No data is initialized! Use it for extra speed.
172  SYS_FORCE_INLINE UT_Vector2T() = default;
173 
174  SYS_FORCE_INLINE UT_Vector2T(const UT_Vector2T<T> &that) = default;
175  SYS_FORCE_INLINE UT_Vector2T(UT_Vector2T<T> &&that) = default;
176 
177  constexpr explicit SYS_FORCE_INLINE UT_Vector2T(T v) :
178  Base(Base::CT::CF, v, v)
179  {}
180  constexpr SYS_FORCE_INLINE UT_Vector2T(const T vx, const T vy) :
181  Base(Base::CT::CF, vx, vy)
182  {}
183  constexpr explicit SYS_FORCE_INLINE UT_Vector2T(const fpreal16 v[tuple_size])
184  : Base(v)
185  {}
186  constexpr explicit SYS_FORCE_INLINE UT_Vector2T(const fpreal32 v[tuple_size])
187  : Base(v)
188  {}
189  constexpr explicit SYS_FORCE_INLINE UT_Vector2T(const fpreal64 v[tuple_size])
190  : Base(v)
191  {}
192  constexpr explicit SYS_FORCE_INLINE UT_Vector2T(const int32 v[tuple_size])
193  : Base(v)
194  {}
195  constexpr explicit SYS_FORCE_INLINE UT_Vector2T(const int64 v[tuple_size])
196  : Base(v)
197  {}
198  explicit UT_Vector2T(const UT_Vector3T<T> &v);
199  explicit UT_Vector2T(const UT_Vector4T<T> &v);
200 
201  /// Our own type of any given value_type.
202  template <typename S>
204  : Base(v)
205  {}
206 
207  /// Arbitrary UT_FixedVector of the same size
208  template <typename S,bool S_INSTANTIATED>
210  : Base(v)
211  {}
212 
215 
216  template <typename S>
218  { vec[0] = v.x(); vec[1] = v.y(); return *this; }
219 
220  // TODO: remove these. They should require an explicit UT_Vector2()
221  // construction, since they're unsafe.
222 
223  /// Assignment operator that truncates a V3 to a V2.
225  /// Assignment operator that truncates a V4 to a V2.
227 
228  /// It's unclear why this is needed, given UT_FixedVector::operator-(),
229  /// but the compiler seems not to accept not having it.
231  {
232  return UT_Vector2T<T>(-vec[0], -vec[1]);
233  }
235  {
236  vec[0] *= v.vec[0];
237  vec[1] *= v.vec[1];
238  }
239 
240  /// Given an oriented line from e1 passing through e2, determine on which
241  /// side of the line the point p lies. Alternatively, determine in which
242  /// half plane, positive or negative, the point lies. If the segment
243  /// degenerates to a point, then the point is always on it.
244  // (Moret and Shapiro 1991)
245  T whichSide(const UT_Vector2T<T> &e1, const UT_Vector2T<T> &e2) const
246  {
247  return (vec[0] - e1.vec[0]) * (e2.vec[1] - e1.vec[1]) -
248  (vec[1] - e1.vec[1]) * (e2.vec[0] - e1.vec[0]);
249  }
250 
251  template <typename S>
253  { return operator=(*this * mat); }
254 
255  /// These allow you to find out what indices to use for different axes
256  // @{
257  int findMinAbsAxis() const
258  {
259  if (SYSabs(x()) < SYSabs(y()))
260  return 0;
261  else
262  return 1;
263  }
264  int findMaxAbsAxis() const
265  {
266  if (SYSabs(x()) >= SYSabs(y()))
267  return 0;
268  else
269  return 1;
270  }
271  // @}
272 
273  /// Calculates the orthogonal projection of a vector u on the *this vector
274  UT_Vector2T<T> project(const UT_Vector2T<T> &u) const;
275 
276 
277  /// Vector p (representing a point in 2-space) and vector v define
278  /// a line. This member returns the projection of "this" onto the
279  /// line (the point on the line that is closest to this point).
280  UT_Vector2T<T> projection(const UT_Vector2T<T> &p, const UT_Vector2T<T> &v) const;
281 
282  /// Compute (homogeneous) barycentric co-ordinates of this point
283  /// relative to the triangle defined by t0, t1 and t2. (The point is
284  /// projected into the triangle's plane.)
285  UT_Vector3T<T> getBary(const UT_Vector2T<T> &t0, const UT_Vector2T<T> &t1,
286  const UT_Vector2T<T> &t2, bool *degen = NULL) const;
287 
288 
289  /// Return the components of the vector. The () operator does NOT check
290  /// for the boundary condition.
291  // @{
292  T &x() { return vec[0]; }
293  T x() const { return vec[0]; }
294  T &y() { return vec[1]; }
295  T y() const { return vec[1]; }
296  T &operator()(unsigned i)
297  {
298  UT_ASSERT_P(i < tuple_size);
299  return vec[i];
300  }
301  T operator()(unsigned i) const
302  {
303  UT_ASSERT_P(i < tuple_size);
304  return vec[i];
305  }
306  // @}
307 
308  /// Compute a hash
309  unsigned hash() const { return SYSvector_hash(data(), tuple_size); }
310 
311  // TODO: eliminate these methods. They're redundant, given good inline
312  // constructors.
313  /// Set the values of the vector components
314  void assign(T xx = 0.0f, T yy = 0.0f)
315  {
316  vec[0] = xx; vec[1] = yy;
317  }
318  /// Set the values of the vector components
319  void assign(const T *v) {vec[0]=v[0]; vec[1]=v[1];}
320 
321  /// Express the point in homogeneous coordinates or vice-versa
322  // @{
323  void homogenize () { vec[0] *= vec[1]; }
324  void dehomogenize() { if (vec[1] != 0) vec[0] /= vec[1]; }
325  // @}
326 
327  /// Protected I/O methods
328  // @{
329  void save(std::ostream &os, int binary = 0) const;
330  bool load(UT_IStream &is);
331  // @}
332 
333  /// @{
334  /// Methods to serialize to a JSON stream. The vector is stored as an
335  /// array of 2 reals.
336  bool save(UT_JSONWriter &w) const;
337  bool save(UT_JSONValue &v) const;
338  bool load(UT_JSONParser &p);
339  /// @}
340 
341  /// Returns the vector size
342  static int entries() { return tuple_size; }
343 
344 private:
345  /// I/O friends
346  // @{
347  friend std::ostream &operator<<(std::ostream &os, const UT_Vector2T<T> &v)
348  {
349  v.save(os);
350  return os;
351  }
352  // @}
353 };
354 
355 #include "UT_Matrix2.h"
356 
357 // Free floating functions:
358 template <typename T>
360 {
361  return UT_Vector2T<T>(v1.x()+v2.x(), v1.y()+v2.y());
362 }
363 template <typename T>
365 {
366  return UT_Vector2T<T>(v1.x()-v2.x(), v1.y()-v2.y());
367 }
368 template <typename T>
370 {
371  return UT_Vector2T<T>(v1.x()*v2.x(), v1.y()*v2.y());
372 }
373 template <typename T>
375 {
376  return UT_Vector2T<T>(v1.x()/v2.x(), v1.y()/v2.y());
377 }
378 template <typename T>
379 inline bool operator<(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2)
380 {
381  return ((v1.x() < v2.x()) || (v1.x() == v2.x() && v1.y() < v2.y()));
382 }
383 template <typename T>
384 inline bool operator<=(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2)
385 {
386  return (v1 < v2) || (v1 == v2);
387 }
388 template <typename T>
389 inline bool operator>(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2)
390 {
391  return v2 < v1;
392 }
393 template <typename T>
394 inline bool operator>=(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2)
395 {
396  return v2 <= v1;
397 }
398 template <typename T, typename S>
399 inline UT_Vector2T<T> operator+(const UT_Vector2T<T> &v, S scalar)
400 {
401  return UT_Vector2T<T>(v.x()+scalar, v.y()+scalar);
402 }
403 template <typename T, typename S>
404 inline UT_Vector2T<T> operator+(S scalar, const UT_Vector2T<T> &v)
405 {
406  return UT_Vector2T<T>(v.x()+scalar, v.y()+scalar);
407 }
408 template <typename T, typename S>
409 inline UT_Vector2T<T> operator-(const UT_Vector2T<T> &v, S scalar)
410 {
411  return UT_Vector2T<T>(v.x()-scalar, v.y()-scalar);
412 }
413 template <typename T, typename S>
414 inline UT_Vector2T<T> operator-(S scalar, const UT_Vector2T<T> &v)
415 {
416  return UT_Vector2T<T>(scalar-v.x(), scalar-v.y());
417 }
418 template <typename T, typename S>
419 inline UT_Vector2T<T> operator*(const UT_Vector2T<T> &v, S scalar)
420 {
421  return UT_Vector2T<T>(v.x()*scalar, v.y()*scalar);
422 }
423 template <typename T, typename S>
424 inline UT_Vector2T<T> operator*(S scalar, const UT_Vector2T<T> &v)
425 {
426  return UT_Vector2T<T>(v.x()*scalar, v.y()*scalar);
427 }
428 template <typename T, typename S>
429 inline UT_Vector2T<T> operator/(const UT_Vector2T<T> &v, S scalar)
430 {
431  return UT_Vector2T<T>(v.x()/scalar, v.y()/scalar);
432 }
433 template <typename T, typename S>
434 inline UT_Vector2T<T> operator/(S scalar, const UT_Vector2T<T> &v)
435 {
436  return UT_Vector2T<T>(scalar/v.x(), scalar/v.y());
437 }
438 template <typename T>
439 inline T dot(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2)
440 {
441  return v1.x()*v2.x() + v1.y()*v2.y();
442 }
443 template <typename T>
444 inline T cross(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2)
445 {
446  return v1.x() * v2.y() - v1.y() * v2.x();
447 }
448 template <typename T>
449 inline
451 {
452  return UT_Vector2T<T>(SYSabs(v.x()), SYSabs(v.y()));
453 }
454 
455 
456 template <typename T>
457 inline
459 {
460  return UT_Vector2T<T>(
461  SYSmin(v1.x(), v2.x()),
462  SYSmin(v1.y(), v2.y())
463  );
464 }
465 
466 template <typename T>
467 inline
469 {
470  return UT_Vector2T<T>(
471  SYSmax(v1.x(), v2.x()),
472  SYSmax(v1.y(), v2.y())
473  );
474 }
475 
476 template <typename T,typename S>
477 inline
479 {
480  return UT_Vector2T<T>(
481  SYSlerp(v1.x(), v2.x(), t),
482  SYSlerp(v1.y(), v2.y(), t));
483 }
484 
485 template <typename T>
486 inline
488  const UT_Vector2T<T> &v1,
489  const UT_Vector2T<T> &v2)
490 {
491  return UT_Vector2T<T>(
492  SYSinvlerp(a.x(), v1.x(), v2.x()),
493  SYSinvlerp(a.y(), v1.y(), v2.y()));
494 }
495 
496 template <typename T>
498 {
499  return dot(u, v) / v.length2() * v;
500 }
501 template <typename T, typename S>
503 {
504  return UT_Vector2T<T>(v.x()*m(0,0) + v.y()*m(1,0),
505  v.x()*m(0,1) + v.y()*m(1,1));
506 }
507 template <>
509 {
510  const v4uf l(v.x(), v.x(), v.y(), v.y());
511  const v4uf r(m.data());
512  const v4uf p = l * r;
513 
514  return UT_Vector2T<float>(p[0] + p[2], p[1] + p[3]);
515 }
516 template <typename T, typename S>
518 {
519  return UT_Vector2T<T>(m(0,0)*v.x() + m(0,1)*v.y(),
520  m(1,0)*v.x() + m(1,1)*v.y());
521 }
522 template <>
524 {
525  const v4uf l(m.data());
526  const v4uf r(v.x(), v.y(), v.x(), v.y());
527  const v4uf p = l * r;
528  return UT_Vector2T<float>(p[0] + p[1], p[2] + p[3]);
529 }
530 template <typename T, typename S>
532 {
533  return rowVecMult(v, m);
534 }
535 template <typename T>
537 {
538  return (v1 - v2).length();
539 }
540 
541 template <typename T>
542 inline size_t hash_value(const UT_Vector2T<T> &val)
543 {
544  return val.hash();
545 }
546 
547 // Overload for custom formatting of UT_Vector2T<T> with UTformat.
548 template<typename T>
549 UT_API size_t format(char *buffer, size_t buffer_size, const UT_Vector2T<T> &v);
550 
551 
552 template<typename T>
554 {
556  typedef T DataType;
557  static const exint TupleSize = 2;
558  static const bool isVectorType = true;
559 };
560 
561 #endif
constexpr SYS_FORCE_INLINE UT_Vector2T(const T vx, const T vy)
Definition: UT_Vector2.h:180
Mat3< typename promote< S, T >::type > operator*(S scalar, const Mat3< T > &m)
Multiply each element of the given matrix by scalar and return the result.
Definition: Mat3.h:575
UT_Vector2T< T > SYSabs(const UT_Vector2T< T > &v)
Definition: UT_Vector2.h:450
class UT_API UT_Vector2T
constexpr SYS_FORCE_INLINE UT_Vector2T(T v)
Definition: UT_Vector2.h:177
int int32
Definition: SYS_Types.h:39
constexpr SYS_FORCE_INLINE UT_Vector2T(const fpreal16 v[tuple_size])
Definition: UT_Vector2.h:183
UT_FixedVector< T, 2 > FixedVectorType
Definition: UT_Vector2.h:555
T & operator()(unsigned i)
Definition: UT_Vector2.h:296
UT_Vector2T< T > rowVecMult(const UT_Vector2T< T > &v, const UT_Matrix2T< S > &m)
Definition: UT_Vector2.h:502
static int entries()
Returns the vector size.
Definition: UT_Vector2.h:342
int findMinAbsAxis() const
These allow you to find out what indices to use for different axes.
Definition: UT_Vector2.h:257
T whichSide(const UT_Vector2T< T > &e1, const UT_Vector2T< T > &e2) const
Definition: UT_Vector2.h:245
T x() const
Definition: UT_Vector2.h:293
Mat3< typename promote< T0, T1 >::type > operator+(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Add corresponding elements of m0 and m1 and return the result.
Definition: Mat3.h:591
UT_Vector2T< T > operator/(const UT_Vector2T< T > &v, S scalar)
Definition: UT_Vector2.h:429
constexpr SYS_FORCE_INLINE UT_Vector2T(const int32 v[tuple_size])
Definition: UT_Vector2.h:192
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
GLenum GLenum GLenum input
Definition: glew.h:14162
int64 exint
Definition: SYS_Types.h:125
constexpr SYS_FORCE_INLINE UT_Vector2T(const int64 v[tuple_size])
Definition: UT_Vector2.h:195
void assign(const T *v)
Set the values of the vector components.
Definition: UT_Vector2.h:319
T y() const
Definition: UT_Vector2.h:295
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:88
#define UT_API
Definition: UT_API.h:14
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Definition: glew.h:12900
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:35
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
GLdouble GLdouble t
Definition: glew.h:1403
GLuint buffer
Definition: glcorearb.h:659
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:444
GLdouble l
Definition: glew.h:9164
UT_Vector2T< T > & operator*=(const UT_Matrix2T< S > &mat)
Definition: UT_Vector2.h:252
GLint GLenum GLint x
Definition: glcorearb.h:408
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
double fpreal64
Definition: SYS_Types.h:201
UT_Vector2T< T > SYSlerp(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2, S t)
Componentwise linear interpolation.
Definition: UT_Vector2.h:478
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:264
Mat3< typename promote< T0, T1 >::type > operator-(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Subtract corresponding elements of m0 and m1 and return the result.
Definition: Mat3.h:601
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:817
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:170
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:309
const GLdouble * v
Definition: glcorearb.h:836
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:497
constexpr SYS_FORCE_INLINE UT_Vector2T(const fpreal64 v[tuple_size])
Definition: UT_Vector2.h:189
static const bool isVectorType
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
T dot(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
The dot product.
Definition: UT_Vector2.h:439
bool operator>=(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Definition: UT_Vector2.h:394
Definition: VM_SIMD.h:188
long long int64
Definition: SYS_Types.h:116
GLfloat GLfloat p
Definition: glew.h:16656
constexpr SYS_FORCE_INLINE UT_FixedVector & operator=(const UT_FixedVector &that)=default
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:487
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
GLfloat v0
Definition: glcorearb.h:815
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:389
SYS_FORCE_INLINE UT_Vector2T< T > operator-() const
Definition: UT_Vector2.h:230
constexpr SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, T >::Type length2() const noexcept
constexpr SYS_FORCE_INLINE UT_Vector2T(const fpreal32 v[tuple_size])
Definition: UT_Vector2.h:186
GLboolean * data
Definition: glcorearb.h:130
void multiplyComponents(const UT_Vector2T< T > &v)
Definition: UT_Vector2.h:234
GLuint GLfloat * val
Definition: glcorearb.h:1607
UT_Vector2T< T > SYSmax(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Definition: UT_Vector2.h:468
constexpr SYS_FORCE_INLINE const T * data() const noexcept
size_t hash_value(const UT_Vector2T< T > &val)
Definition: UT_Vector2.h:542
T operator()(unsigned i) const
Definition: UT_Vector2.h:301
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition: glew.h:12900
const GLdouble * m
Definition: glew.h:9166
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:77
GLfloat f
Definition: glcorearb.h:1925
SYS_FORCE_INLINE UT_Vector2T< T > & operator=(const UT_Vector2T< S > &v)
Definition: UT_Vector2.h:217
void assign(T xx=0.0f, T yy=0.0f)
Set the values of the vector components.
Definition: UT_Vector2.h:314
UT_Vector2T< T > SYSmin(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Componentwise min and maximum.
Definition: UT_Vector2.h:458
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:209
GLfloat GLfloat v1
Definition: glcorearb.h:816
const T * data() const
Return the raw matrix data.
Definition: UT_Matrix2.h:422
GLboolean r
Definition: glcorearb.h:1221
UT_Vector2T< T > colVecMult(const UT_Matrix2T< S > &m, const UT_Vector2T< T > &v)
Definition: UT_Vector2.h:517
GLint y
Definition: glcorearb.h:102
void dehomogenize()
Express the point in homogeneous coordinates or vice-versa.
Definition: UT_Vector2.h:324
SYS_FORCE_INLINE UT_Vector2T(const UT_Vector2T< S > &v)
Our own type of any given value_type.
Definition: UT_Vector2.h:203
T distance2d(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Definition: UT_Vector2.h:536
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:323