20 #ifndef __UT_Vector2_h__
21 #define __UT_Vector2_h__
53 template <
typename T,
typename S>
55 template <
typename T,
typename S>
57 template <
typename T,
typename S>
59 template <
typename T,
typename S>
61 template <
typename T,
typename S>
63 template <
typename T,
typename S>
65 template <
typename T,
typename S>
67 template <
typename T,
typename S>
69 template <
typename T,
typename S>
86 template <
typename T,
typename S>
94 template <
typename T,
typename S>
100 template <
typename T,
typename S>
103 {
return v0 * (1 - u -
v) + v1 * u + v2 *v; }
106 template <
typename T>
125 template <
typename T,
typename S>
128 template <
typename T,
typename S>
133 template <
typename T>
140 template <
typename T>
148 template <
typename T>
157 using Base::operator=;
158 using Base::operator*=;
167 static const int tuple_size = 2;
206 template <
typename S>
212 template <
typename S,
bool S_INSTANTIATED>
220 template <
typename S>
222 { vec[0] = v.
x(); vec[1] = v.
y();
return *
this; }
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]);
255 template <
typename S>
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]; }
313 unsigned hash()
const {
return SYSvector_hash(
data(), tuple_size); }
320 vec[0] = xx; vec[1] = yy;
323 void assign(
const T *
v) {vec[0]=v[0]; vec[1]=v[1];}
333 void save(std::ostream &os,
int binary = 0)
const;
351 friend std::ostream &operator<<(std::ostream &os, const UT_Vector2T<T> &
v)
362 template <
typename T>
367 template <
typename T>
372 template <
typename T>
377 template <
typename T>
382 template <
typename T>
385 return ((
v1.x() <
v2.x()) || (
v1.x() ==
v2.x() &&
v1.y() <
v2.y()));
387 template <
typename T>
392 template <
typename T>
397 template <
typename T>
402 template <
typename T,
typename S>
407 template <
typename T,
typename S>
412 template <
typename T,
typename S>
417 template <
typename T,
typename S>
422 template <
typename T,
typename S>
427 template <
typename T,
typename S>
432 template <
typename T,
typename S>
437 template <
typename T,
typename S>
442 template <
typename T>
445 return v1.
x()*v2.
x() + v1.
y()*v2.
y();
447 template <
typename T>
450 return v1.
x() * v2.
y() - v1.
y() * v2.
x();
452 template <
typename T>
460 template <
typename T>
470 template <
typename T>
480 template <
typename T,
typename S>
489 template <
typename T>
500 template <
typename T>
505 template <
typename T,
typename S>
509 v.
x()*
m(0,1) + v.
y()*
m(1,1));
514 const v4uf l(v.
x(), v.
x(), v.
y(), v.
y());
520 template <
typename T,
typename S>
524 m(1,0)*v.
x() +
m(1,1)*v.
y());
530 const v4uf r(v.
x(), v.
y(), v.
x(), v.
y());
534 template <
typename T,
typename S>
539 template <
typename T>
542 return (v1 - v2).length();
545 template <
typename T>
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.
UT_Vector2T< T > SYSabs(const UT_Vector2T< T > &v)
GLenum GLenum GLenum input
SYS_FORCE_INLINE UT_Vector2T(const fpreal16 v[tuple_size])
SYS_FORCE_INLINE UT_Vector2T(T vx, T vy)
UT_FixedVector< T, 2 > FixedVectorType
T & operator()(unsigned i)
UT_Vector2T< T > rowVecMult(const UT_Vector2T< T > &v, const UT_Matrix2T< S > &m)
static int entries()
Returns the vector size.
int findMinAbsAxis() const
These allow you to find out what indices to use for different axes.
T whichSide(const UT_Vector2T< T > &e1, const UT_Vector2T< T > &e2) const
SYS_FORCE_INLINE ThisType & operator=(const ThisType &that)=default
GLuint const GLfloat * val
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.
UT_Vector2T< T > operator/(const UT_Vector2T< T > &v, S scalar)
GLboolean GLboolean GLboolean GLboolean a
void assign(const T *v)
Set the values of the vector components.
JSON reader class which handles parsing of JSON or bJSON files.
Class which writes ASCII or binary JSON streams.
static const exint TupleSize
T cross(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Cross product, which for 2d vectors results in a fpreal.
SYS_FORCE_INLINE UT_Vector2T(T v)
UT_Vector2T< T > & operator*=(const UT_Matrix2T< S > &mat)
GLfloat GLfloat GLfloat v2
SYS_FORCE_INLINE UT_Vector2T(const int32 v[tuple_size])
UT_Vector2T< T > SYSlerp(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2, S t)
Componentwise linear interpolation.
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.
int findMaxAbsAxis() const
These allow you to find out what indices to use for different axes.
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
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.
GLint GLenum GLsizei GLint GLsizei const void * data
const GLuint GLenum const void * binary
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.
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.
static const bool isVectorType
GLubyte GLubyte GLubyte GLubyte w
T dot(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
The dot product.
bool operator>=(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, T >::Type length2() const noexcept
UT_Vector2T< T > SYSinvlerp(const UT_Vector2T< T > &a, const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Componentwise inverse linear interpolation.
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.
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)
SYS_FORCE_INLINE UT_Vector2T< T > operator-() const
void multiplyComponents(const UT_Vector2T< T > &v)
SYS_FORCE_INLINE UT_Vector2T(const fpreal32 v[tuple_size])
UT_Vector2T< T > SYSmax(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
SYS_FORCE_INLINE UT_Vector2T(const int64 v[tuple_size])
size_t hash_value(const UT_Vector2T< T > &val)
T operator()(unsigned i) const
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
GLdouble GLdouble GLdouble r
Class to store JSON objects as C++ objects.
SYS_FORCE_INLINE UT_Vector2T< T > & operator=(const UT_Vector2T< S > &v)
void assign(T xx=0.0f, T yy=0.0f)
Set the values of the vector components.
UT_Vector2T< T > SYSmin(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
Componentwise min and maximum.
SYS_FORCE_INLINE UT_Vector2T(const UT_FixedVector< S, tuple_size, S_INSTANTIATED > &v)
Arbitrary UT_FixedVector of the same size.
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
const T * data() const
Return the raw matrix data.
UT_Vector2T< T > colVecMult(const UT_Matrix2T< S > &m, const UT_Vector2T< T > &v)
SYS_FORCE_INLINE UT_Vector2T(const fpreal64 v[tuple_size])
void dehomogenize()
Express the point in homogeneous coordinates or vice-versa.
SYS_FORCE_INLINE UT_Vector2T(const UT_Vector2T< S > &v)
Our own type of any given value_type.
T distance2d(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
UT_FixedVector< T, 2, true > Base
void homogenize()
Express the point in homogeneous coordinates or vice-versa.