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*=;
168 static constexpr
int tuple_size = 2;
202 template <
typename S>
208 template <
typename S,
bool S_INSTANTIATED>
216 template <
typename S>
218 { vec[0] = v.
x(); vec[1] = v.
y();
return *
this; }
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]);
251 template <
typename S>
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]; }
309 unsigned hash()
const {
return SYSvector_hash(
data(), tuple_size); }
316 vec[0] = xx; vec[1] = yy;
319 void assign(
const T *
v) {vec[0]=v[0]; vec[1]=v[1];}
329 void save(std::ostream &os,
int binary = 0)
const;
347 friend std::ostream &operator<<(std::ostream &os, const UT_Vector2T<T> &
v)
358 template <
typename T>
363 template <
typename T>
368 template <
typename T>
373 template <
typename T>
378 template <
typename T>
381 return ((
v1.x() <
v2.x()) || (
v1.x() ==
v2.x() &&
v1.y() <
v2.y()));
383 template <
typename T>
388 template <
typename T>
393 template <
typename T>
398 template <
typename T,
typename S>
403 template <
typename T,
typename S>
408 template <
typename T,
typename S>
413 template <
typename T,
typename S>
418 template <
typename T,
typename S>
423 template <
typename T,
typename S>
428 template <
typename T,
typename S>
433 template <
typename T,
typename S>
438 template <
typename T>
441 return v1.
x()*v2.
x() + v1.
y()*v2.
y();
443 template <
typename T>
446 return v1.
x() * v2.
y() - v1.
y() * v2.
x();
448 template <
typename T>
456 template <
typename T>
466 template <
typename T>
476 template <
typename T,
typename S>
485 template <
typename T>
496 template <
typename T>
501 template <
typename T,
typename S>
505 v.
x()*
m(0,1) + v.
y()*
m(1,1));
510 const v4uf l(v.
x(), v.
x(), v.
y(), v.
y());
516 template <
typename T,
typename S>
520 m(1,0)*v.
x() +
m(1,1)*v.
y());
526 const v4uf r(v.
x(), v.
y(), v.
x(), v.
y());
530 template <
typename T,
typename S>
535 template <
typename T>
538 return (v1 - v2).length();
541 template <
typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T(const T vx, const T vy)
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)
constexpr SYS_FORCE_INLINE UT_Vector2T(T v)
constexpr SYS_FORCE_INLINE UT_Vector2T(const fpreal16 v[tuple_size])
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
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)
constexpr SYS_FORCE_INLINE UT_Vector2T(const int32 v[tuple_size])
const GLuint GLenum const void * binary
GLenum GLenum GLenum input
constexpr SYS_FORCE_INLINE UT_Vector2T(const int64 v[tuple_size])
void assign(const T *v)
Set the values of the vector components.
JSON reader class which handles parsing of JSON or bJSON files.
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
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.
UT_Vector2T< T > & operator*=(const UT_Matrix2T< S > &mat)
GLubyte GLubyte GLubyte GLubyte w
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.
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.
GLfloat GLfloat GLfloat v2
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.
constexpr SYS_FORCE_INLINE UT_Vector2T(const fpreal64 v[tuple_size])
static const bool isVectorType
GLboolean GLboolean GLboolean GLboolean a
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)
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.
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
constexpr SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, T >::Type length2() const noexcept
constexpr SYS_FORCE_INLINE UT_Vector2T(const fpreal32 v[tuple_size])
void multiplyComponents(const UT_Vector2T< T > &v)
UT_Vector2T< T > SYSmax(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
constexpr SYS_FORCE_INLINE const T * data() const noexcept
size_t hash_value(const UT_Vector2T< T > &val)
T operator()(unsigned i) const
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
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.
const T * data() const
Return the raw matrix data.
UT_Vector2T< T > colVecMult(const UT_Matrix2T< S > &m, const UT_Vector2T< T > &v)
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.