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 /// Bilinear interpolation
90 template <typename T,typename S>
91 inline UT_Vector2T<T> SYSbilerp(const UT_Vector2T<T> &u0v0, const UT_Vector2T<T> &u1v0,
92  const UT_Vector2T<T> &u0v1, const UT_Vector2T<T> &u1v1, S u, S v)
93 { return SYSlerp(SYSlerp(u0v0, u0v1, v), SYSlerp(u1v0, u1v1, v), u); }
94 
95 /// Barycentric interpolation
96 template <typename T, typename S>
98  const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2, S u, S v)
99 { return v0 * (1 - u - v) + v1 * u + v2 *v; }
100 
101 /// The orthogonal projection of a vector u onto a vector v
102 template <typename T>
103 inline UT_Vector2T<T> project (const UT_Vector2T<T> &u, const UT_Vector2T<T> &v);
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 
121 template <typename T, typename S>
123  const UT_Matrix2T<S> &m);
124 template <typename T, typename S>
126  const UT_Vector2T<T> &v);
127 // @}
128 
129 template <typename T>
130 inline T distance2d(const UT_Vector2T<T> &v1, const UT_Vector2T<T> &v2);
131 
132 /// Given a 2D position, input, and a 2D quad, (p0, p0+du, p0+du+dv+duv, p0+dv),
133 /// finds the 0, 1, or 2 locations in the parameter space of that quad that correspond
134 /// with the input position. Only parameter locations approximately between 0 and 1
135 /// are accepted. The return value is the number of accepted parameter locations.
136 template <typename T>
138  const UT_Vector2T<T> &p0,
139  const UT_Vector2T<T> &du, const UT_Vector2T<T> &dv,
140  const UT_Vector2T<T> &duv,
141  UT_Vector2T<T> outputs[2]);
142 
143 /// 2D Vector class.
144 template <typename T>
145 class UT_API UT_Vector2T : public UT_FixedVector<T,2,true>
146 {
147 public:
149 
150  // These "using" statements are needed for operator= and operator*=
151  // so that the ones in UT_FixedVector aren't hidden by the additional
152  // ones here.
153  using Base::operator=;
154  using Base::operator*=;
155 
156  // These "using" statements are needed for GCC and Clang, because
157  // otherwise, they ignore all members of UT_FixedVector when
158  // checking validity of code in functions in this class.
159  using Base::vec;
160  using Base::data;
161  using Base::length2;
162  typedef T value_type;
163  static const int tuple_size = 2;
164 
165  /// Default constructor.
166  /// No data is initialized! Use it for extra speed.
167  SYS_FORCE_INLINE UT_Vector2T() = default;
168 
169  SYS_FORCE_INLINE UT_Vector2T(const UT_Vector2T<T> &that) = default;
170  SYS_FORCE_INLINE UT_Vector2T(UT_Vector2T<T> &&that) = default;
171 
173  {
174  vec[0] = v;
175  vec[1] = v;
176  }
177 
179  {
180  vec[0] = vx;
181  vec[1] = vy;
182  }
183  explicit SYS_FORCE_INLINE UT_Vector2T(const fpreal16 v[tuple_size])
184  : Base(v)
185  {}
186  explicit SYS_FORCE_INLINE UT_Vector2T(const fpreal32 v[tuple_size])
187  : Base(v)
188  {}
189  explicit SYS_FORCE_INLINE UT_Vector2T(const fpreal64 v[tuple_size])
190  : Base(v)
191  {}
192  explicit SYS_FORCE_INLINE UT_Vector2T(const int32 v[tuple_size])
193  : Base(v)
194  {}
195  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(void) { return vec[0]; }
293  T x(void) const { return vec[0]; }
294  T &y(void) { return vec[1]; }
295  T y(void) 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 (void) { vec[0] *= vec[1]; }
324  void dehomogenize(void) { 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>
487 {
488  return dot(u, v) / v.length2() * v;
489 }
490 template <typename T, typename S>
492 {
493  return UT_Vector2T<T>(v.x()*m(0,0) + v.y()*m(1,0),
494  v.x()*m(0,1) + v.y()*m(1,1));
495 }
496 template <>
498 {
499  const v4uf l(v.x(), v.x(), v.y(), v.y());
500  const v4uf r(m.data());
501  const v4uf p = l * r;
502 
503  return UT_Vector2T<float>(p[0] + p[2], p[1] + p[3]);
504 }
505 template <typename T, typename S>
507 {
508  return UT_Vector2T<T>(m(0,0)*v.x() + m(0,1)*v.y(),
509  m(1,0)*v.x() + m(1,1)*v.y());
510 }
511 template <>
513 {
514  const v4uf l(m.data());
515  const v4uf r(v.x(), v.y(), v.x(), v.y());
516  const v4uf p = l * r;
517  return UT_Vector2T<float>(p[0] + p[1], p[2] + p[3]);
518 }
519 template <typename T, typename S>
521 {
522  return rowVecMult(v, m);
523 }
524 template <typename T>
526 {
527  return (v1 - v2).length();
528 }
529 
530 template <typename T>
531 inline size_t hash_value(const UT_Vector2T<T> &val)
532 {
533  return val.hash();
534 }
535 
536 // Overload for custom formatting of UT_Vector2T<T> with UTformat.
537 template<typename T>
538 UT_API size_t format(char *buffer, size_t buffer_size, const UT_Vector2T<T> &v);
539 
540 
541 template<typename T>
543 {
545  typedef T DataType;
546  static const exint TupleSize = 2;
547  static const bool isVectorType = true;
548 };
549 
550 #endif
T x(void) const
Definition: UT_Vector2.h:293
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:609
UT_Vector2T< T > SYSabs(const UT_Vector2T< T > &v)
Definition: UT_Vector2.h:450
GLenum GLenum GLenum input
Definition: glew.h:13879
SYS_FORCE_INLINE UT_Vector2T(const fpreal16 v[tuple_size])
Definition: UT_Vector2.h:183
class UT_API UT_Vector2T
SYS_FORCE_INLINE UT_Vector2T(T vx, T vy)
Definition: UT_Vector2.h:178
UT_FixedVector< T, 2 > FixedVectorType
Definition: UT_Vector2.h:544
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:491
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
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:625
UT_Vector2T< T > operator/(const UT_Vector2T< T > &v, S scalar)
Definition: UT_Vector2.h:429
T & x(void)
Definition: UT_Vector2.h:292
void assign(const T *v)
Set the values of the vector components.
Definition: UT_Vector2.h:319
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:75
#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:32
const GLdouble * v
Definition: glew.h:1391
static const exint TupleSize
3D Vector class.
4D Vector class.
Definition: UT_Vector4.h:163
2D Vector class.
Definition: UT_Vector2.h:145
const T * data(void) const
Return the raw matrix data.
Definition: UT_Matrix2.h:397
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
SYS_FORCE_INLINE UT_Vector2T(T v)
Definition: UT_Vector2.h:172
UT_Vector2T< T > & operator*=(const UT_Matrix2T< S > &mat)
Definition: UT_Vector2.h:252
long long int64
Definition: SYS_Types.h:111
GLfloat GLfloat GLfloat v2
Definition: glew.h:1856
SYS_FORCE_INLINE UT_Vector2T(const int32 v[tuple_size])
Definition: UT_Vector2.h:192
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:97
int findMaxAbsAxis() const
These allow you to find out what indices to use for different axes.
Definition: UT_Vector2.h:264
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:635
int64 exint
Definition: SYS_Types.h:120
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:309
double fpreal64
Definition: SYS_Types.h:196
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:486
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:439
bool operator>=(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Definition: UT_Vector2.h:394
Definition: VM_SIMD.h:188
SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, T >::Type length2() const noexcept
int int32
Definition: SYS_Types.h:39
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:91
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
void multiplyComponents(const UT_Vector2T< T > &v)
Definition: UT_Vector2.h:234
SYS_FORCE_INLINE UT_Vector2T(const fpreal32 v[tuple_size])
Definition: UT_Vector2.h:186
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:468
SYS_FORCE_INLINE UT_Vector2T(const int64 v[tuple_size])
Definition: UT_Vector2.h:195
size_t hash_value(const UT_Vector2T< T > &val)
Definition: UT_Vector2.h:531
void dehomogenize(void)
Express the point in homogeneous coordinates or vice-versa.
Definition: UT_Vector2.h:324
T operator()(unsigned i) const
Definition: UT_Vector2.h:301
void homogenize(void)
Express the point in homogeneous coordinates or vice-versa.
Definition: UT_Vector2.h:323
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:76
T y(void) const
Definition: UT_Vector2.h:295
SYS_FORCE_INLINE UT_Vector2T< T > & operator=(const UT_Vector2T< S > &v)
Definition: UT_Vector2.h:217
T & y(void)
Definition: UT_Vector2.h:294
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
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition: glew.h:12681
UT_Vector2T< T > colVecMult(const UT_Matrix2T< S > &m, const UT_Vector2T< T > &v)
Definition: UT_Vector2.h:506
SYS_FORCE_INLINE UT_Vector2T(const fpreal64 v[tuple_size])
Definition: UT_Vector2.h:189
float fpreal32
Definition: SYS_Types.h:195
GLdouble GLdouble t
Definition: glew.h:1398
GLfloat GLfloat v1
Definition: glew.h:1852
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:525
UT_FixedVector< T, 2, true > Base
Definition: UT_Vector2.h:148