20 #ifndef __UT_Vector2_h__
21 #define __UT_Vector2_h__
51 constexpr
bool operator<=(const UT_Vector2T<T> &
v1,
const UT_Vector2T<T> &
v2) noexcept;
56 template <
typename T,
typename S>
58 template <
typename T,
typename S>
60 template <
typename T,
typename S>
62 template <
typename T,
typename S>
64 template <
typename T,
typename S>
66 template <
typename T,
typename S>
68 template <
typename T,
typename S>
70 template <
typename T,
typename S>
72 template <
typename T,
typename S>
89 template <
typename T,
typename S>
96 template <
typename T,
typename S>
100 template <
typename T>
104 template <
typename T,
typename S>
110 template <
typename T,
typename S>
113 {
return v0 * (1 - u -
v) + v1 * u + v2 *v; }
116 template <
typename T>
135 template <
typename T,
typename S>
138 template <
typename T,
typename S>
143 template <
typename T>
150 template <
typename T>
158 template <
typename T>
163 static constexpr
int tuple_size = 2;
205 template <
typename S>
213 template <
typename S>
215 { vec[0] = v.
x(); vec[1] = v.
y();
return *
this; }
296 return SYSsqrt( length2() );
373 return (vec[0] - e1.
vec[0]) * (e2.
vec[1] - e1.
vec[1]) -
374 (vec[1] - e1.
vec[1]) * (e2.
vec[0] - e1.
vec[0]);
377 template <
typename S>
441 unsigned hash()
const {
return SYSvector_hash(
data(), tuple_size); }
448 vec[0] = xx; vec[1] = yy;
451 void assign(
const T *
v) {vec[0]=v[0]; vec[1]=v[1];}
461 void save(std::ostream &os,
int binary = 0)
const;
530 friend std::ostream &operator<<(std::ostream &os, const UT_Vector2T<T> &
v)
538 template <
typename T>
541 for (
int i = 0; i != tuple_size; ++i )
552 template <
typename T>
557 template <
typename T>
562 template <
typename T>
567 template <
typename T>
572 template <
typename T>
575 return ((v1.x() <
v2.x()) || (v1.x() ==
v2.x() && v1.y() <
v2.y()));
577 template <
typename T>
580 return (v1 <
v2) || (v1 ==
v2);
582 template <
typename T>
587 template <
typename T>
592 template <
typename T,
typename S>
597 template <
typename T,
typename S>
602 template <
typename T,
typename S>
607 template <
typename T,
typename S>
612 template <
typename T,
typename S>
617 template <
typename T,
typename S>
622 template <
typename T,
typename S>
627 template <
typename T,
typename S>
633 template <
typename T>
639 template <
typename T>
642 return v1.
x() * v2.
y() - v1.
y() * v2.
x();
644 template <
typename T>
652 template <
typename T>
662 template <
typename T>
672 template <
typename T,
typename S>
679 template <
typename T,
typename S>
688 template <
typename T>
699 template <
typename T>
704 template <
typename T,
typename S>
708 v.
x()*m(0,1) + v.
y()*m(1,1));
713 const v4uf l(v.
x(), v.
x(), v.
y(), v.
y());
715 const v4uf p = l *
r;
719 template <
typename T,
typename S>
723 m(1,0)*v.
x() + m(1,1)*v.
y());
729 const v4uf r(v.
x(), v.
y(), v.
x(), v.
y());
730 const v4uf p = l *
r;
733 template <
typename T,
typename S>
738 template <
typename T>
741 return (v1 - v2).length();
744 template <
typename T>
754 template<
typename T, ex
int D >
768 template<
typename T >
771 template<
typename T >
774 template<
typename T >
781 template <
typename T>
784 template<
typename TS >
794 template <
typename V >
798 template <
typename T>
807 template <
typename T>
810 template<
typename TS >
822 template<
typename TS >
834 template <
typename V >
838 template <
typename T>
constexpr SYS_FORCE_INLINE UT_Vector2T(const UT_Vector2T< S > &v) noexcept
Our own type of any given value_type.
constexpr SYS_FORCE_INLINE UT_Vector2T & operator*=(const T &a) 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)
constexpr SYS_FORCE_INLINE UT_Vector2T(const fpreal64 v[]) noexcept
constexpr SYS_FORCE_INLINE UT_Vector2T & operator-=(const UT_Vector2T &a) noexcept
typename UT_StorageNum< T >::MathFloat UT_StorageMathFloat_t
constexpr SYS_FORCE_INLINE T x() const noexcept
#define SYS_STATIC_ASSERT(expr)
friend constexpr bool operator!=(const UT_Vector2T &a, const UT_Vector2T &b) noexcept
friend constexpr bool operator<=(const UT_Vector2T &a, const UT_Vector2T &b) noexcept
UT_FixedVector< T, 2 > FixedVectorType
T & operator()(unsigned i)
UT_FromUnbounded creates a V from an unbounded array-like type.
UT_Vector2T< T > rowVecMult(const UT_Vector2T< T > &v, const UT_Matrix2T< S > &m)
constexpr SYS_FORCE_INLINE T & operator[](exint i) noexcept
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.
bool SYSisFinite(fpreal64 f)
UT_Vector2T< T > operator/(const UT_Vector2T< T > &v, S scalar)
constexpr SYS_FORCE_INLINE UT_Vector2T & operator*=(const UT_Vector2T &a) noexcept
const GLuint GLenum const void * binary
bool SYSisInteger(const UT_Vector2T< T > &v1)
Componentwise integer test.
typename SYS_FixedArrayElement< T >::type SYS_FixedArrayElement_t
fpreal64 distance2(const UT_VectorD &v1, const UT_VectorD &v2)
Distance squared (L2) aka quadrance.
constexpr SYS_FORCE_INLINE UT_Vector2T & operator/=(const T &a) noexcept
constexpr bool SYSisNan(const F f)
void assign(const T *v)
Set the values of the vector components.
GLboolean GLboolean GLboolean GLboolean a
constexpr SYS_FORCE_INLINE UT_Vector2T< T > operator()(const TS &as) const noexcept
JSON reader class which handles parsing of JSON or bJSON files.
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
Class which writes ASCII or binary JSON streams.
constexpr SYS_FORCE_INLINE auto dot(const UT_Vector2T &b) const noexcept
static const exint TupleSize
GLfloat GLfloat GLfloat v2
friend constexpr bool isZero(const UT_Vector2T &a) noexcept
constexpr UT_Vector2T(const UT_Vector4T< T > &v) noexcept
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)
constexpr SYS_FORCE_INLINE T & x() noexcept
constexpr SYS_FORCE_INLINE UT_Vector2T< T > & operator=(const UT_Vector2T< S > &v)
UT_Vector2T< T > SYSlerp(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2, S t)
Componentwise linear interpolation.
constexpr SYS_FORCE_INLINE T length() const noexcept
constexpr SYS_FORCE_INLINE UT_Vector2T & operator-=(const T &a) noexcept
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.
typename UT_StorageAtLeast32Bit< T0, T1 >::type UT_StorageAtLeast32Bit_t
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
constexpr SYS_FORCE_INLINE bool isNan() const noexcept
constexpr SYS_FORCE_INLINE const T * data() const noexcept
friend constexpr auto length2(const UT_Vector2T &a) noexcept
friend constexpr bool operator<(const UT_Vector2T &a, const UT_Vector2T &b) noexcept
constexpr SYS_FORCE_INLINE T distance(const UT_Vector2T &b) 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.
friend constexpr bool operator==(const UT_Vector2T &a, const UT_Vector2T &b) noexcept
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.
GLboolean GLboolean GLboolean b
constexpr bool operator>=(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2) noexcept
UT_API size_t format(char *buffer, size_t buffer_size, const UT_Vector2T< T > &v)
constexpr SYS_FORCE_INLINE T * data() noexcept
constexpr SYS_FORCE_INLINE UT_Vector2T(const fpreal32 v[]) noexcept
SYS_FORCE_INLINE UT_Vector2T< T > operator-() const
void multiplyComponents(const UT_Vector2T< T > &v)
constexpr SYS_FORCE_INLINE T distance2(const UT_Vector2T &b) const noexcept
constexpr SYS_FORCE_INLINE UT_Vector2T & operator+=(const UT_Vector2T &a) noexcept
constexpr SYS_FORCE_INLINE T length2() const noexcept
UT_Vector2T< T > SYSmax(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
size_t hash_value(const UT_Vector2T< T > &val)
constexpr SYS_FORCE_INLINE UT_Vector2T & operator+=(const T &a) noexcept
constexpr SYS_FORCE_INLINE bool isZero() const noexcept
constexpr SYS_FORCE_INLINE bool equalZero(const T tolerance=SYS_FTOLERANCE) const noexcept
constexpr UT_Vector2T(const UT_Vector3T< T > &v) noexcept
constexpr SYS_FORCE_INLINE T maxComponent() const noexcept
T operator()(unsigned i) const
constexpr SYS_FORCE_INLINE void negate() noexcept
constexpr SYS_FORCE_INLINE UT_Vector2T(const T vx, const T vy) noexcept
LeafData & operator=(const LeafData &)=delete
Class to store JSON objects as C++ objects.
friend constexpr bool operator>(const UT_Vector2T &a, const UT_Vector2T &b) noexcept
friend constexpr bool operator>=(const UT_Vector2T &a, const UT_Vector2T &b) noexcept
constexpr SYS_FORCE_INLINE UT_Vector2T(const int64 v[]) noexcept
GLubyte GLubyte GLubyte GLubyte w
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.
constexpr SYS_FORCE_INLINE UT_Vector2T(T v) noexcept
constexpr SYS_FORCE_INLINE UT_Vector2T(const int32 v[]) noexcept
const T * data() const
Return the raw matrix data.
constexpr SYS_FORCE_INLINE const T & operator[](exint i) const noexcept
constexpr bool operator>(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2) noexcept
constexpr SYS_FORCE_INLINE UT_Vector2T< T > operator()(const TS &as) const noexcept
constexpr UT_Vector2T< SYS_FixedArrayElement_t< TS > > UTmakeVector2T(const TS &as) noexcept
bool SYSisEqual(const UT_Vector2T< T > &a, const UT_Vector2T< T > &b, S tol=SYS_FTOLERANCE)
Componentwise equality.
UT_Vector2T< T > colVecMult(const UT_Matrix2T< S > &m, const UT_Vector2T< T > &v)
constexpr SYS_FORCE_INLINE bool isFinite() const noexcept
SYS_FORCE_INLINE UT_StorageMathFloat_t< T > normalize() noexcept
constexpr SYS_FORCE_INLINE bool isEqual(const UT_Vector2T &b, const T tolerance=SYS_FTOLERANCE) const noexcept
friend constexpr auto distance2(const UT_Vector2T &a, const UT_Vector2T &b) noexcept
void dehomogenize()
Express the point in homogeneous coordinates or vice-versa.
constexpr SYS_FORCE_INLINE T & y() noexcept
T distance2d(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
constexpr auto dot(const UT_Vector2T< T > &a, const UT_Vector2T< T > &b) noexcept
The dot product.
constexpr SYS_FORCE_INLINE UT_Vector2T< T > & operator=(const UT_Vector2T< T > &that)=default
constexpr SYS_FORCE_INLINE T y() const noexcept
constexpr SYS_FORCE_INLINE UT_Vector2T(const fpreal16 v[]) noexcept
void homogenize()
Express the point in homogeneous coordinates or vice-versa.