20 #ifndef __UT_Vector2_h__
21 #define __UT_Vector2_h__
52 constexpr
bool operator<=(const UT_Vector2T<T> &
v1,
const UT_Vector2T<T> &
v2) noexcept;
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>
71 template <
typename T,
typename S>
73 template <
typename T,
typename S>
94 template <
typename T,
typename S>
102 template <
typename T,
typename S>
108 template <
typename T,
typename S>
111 {
return v0 * (1 - u -
v) + v1 * u + v2 *v; }
114 template <
typename T>
133 template <
typename T,
typename S>
136 template <
typename T,
typename S>
141 template <
typename T>
148 template <
typename T>
156 template <
typename T>
161 static constexpr
int tuple_size = 2;
203 template <
typename S>
216 template <
typename S>
218 { vec[0] = v.
x(); vec[1] = v.
y();
return *
this; }
299 return SYSsqrt( length2() );
376 return (vec[0] - e1.
vec[0]) * (e2.
vec[1] - e1.
vec[1]) -
377 (vec[1] - e1.
vec[1]) * (e2.
vec[0] - e1.
vec[0]);
380 template <
typename S>
382 {
return operator=(*
this * mat); }
426 T &
x() {
return vec[0]; }
427 constexpr
T x()
const noexcept {
return vec[0]; }
428 T &
y() {
return vec[1]; }
429 constexpr
T y()
const noexcept {
return vec[1]; }
443 unsigned hash()
const {
return SYSvector_hash(
data(), tuple_size); }
450 vec[0] = xx; vec[1] = yy;
453 void assign(
const T *
v) {vec[0]=v[0]; vec[1]=v[1];}
463 void save(std::ostream &os,
int binary = 0)
const;
532 friend std::ostream &operator<<(std::ostream &os, const UT_Vector2T<T> &
v)
540 template <
typename T>
543 for (
int i = 0; i != tuple_size; ++i )
554 template <
typename T>
559 template <
typename T>
564 template <
typename T>
569 template <
typename T>
574 template <
typename T>
577 return ((v1.x() <
v2.x()) || (v1.x() ==
v2.x() && v1.y() <
v2.y()));
579 template <
typename T>
582 return (v1 <
v2) || (v1 ==
v2);
584 template <
typename T>
589 template <
typename T>
594 template <
typename T,
typename S>
599 template <
typename T,
typename S>
604 template <
typename T,
typename S>
609 template <
typename T,
typename S>
614 template <
typename T,
typename S>
619 template <
typename T,
typename S>
624 template <
typename T,
typename S>
629 template <
typename T,
typename S>
635 template <
typename T>
641 template <
typename T>
644 return v1.
x() * v2.
y() - v1.
y() * v2.
x();
646 template <
typename T>
654 template <
typename T>
664 template <
typename T>
674 template <
typename T,
typename S>
683 template <
typename T>
694 template <
typename T>
699 template <
typename T,
typename S>
703 v.
x()*
m(0,1) + v.
y()*
m(1,1));
708 const v4uf l(v.
x(), v.
x(), v.
y(), v.
y());
714 template <
typename T,
typename S>
718 m(1,0)*v.
x() +
m(1,1)*v.
y());
724 const v4uf r(v.
x(), v.
y(), v.
x(), v.
y());
728 template <
typename T,
typename S>
733 template <
typename T>
736 return (v1 - v2).length();
739 template <
typename T>
749 template<
typename T, ex
int D >
763 template<
typename T >
766 template<
typename T >
769 template<
typename T >
775 template <
typename T>
778 template<
typename TS >
790 template<
typename TS >
802 template <
typename V >
806 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 UT::FA::DotReturn_t< T, 2 > dot(const UT_Vector2T< T > &a, const UT_Vector2T< T > &b) noexcept
The dot product.
GLboolean GLboolean GLboolean b
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
#define SYS_STATIC_ASSERT(expr)
constexpr T x() const noexcept
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_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.
GLenum GLenum GLenum input
constexpr SYS_FORCE_INLINE T dot(const UT_Vector2T &b) const noexcept
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.
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)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Class which writes ASCII or binary JSON streams.
static const exint TupleSize
friend constexpr T distance2(const UT_Vector2T &a, const UT_Vector2T &b) noexcept
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)
friend constexpr T length2(const UT_Vector2T &a) noexcept
GLubyte GLubyte GLubyte GLubyte w
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.
GLfloat GLfloat GLfloat v2
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
GLboolean GLboolean GLboolean GLboolean a
typename Dot< T, SIZE >::R DotReturn_t
constexpr SYS_FORCE_INLINE bool isNan() const noexcept
constexpr SYS_FORCE_INLINE const T * data() const 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.
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
constexpr T y() const noexcept
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
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
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
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 UT_Vector2T(const UT_FixedVector< T, tuple_size > &v) noexcept
UT_FixedVector of the same size.
constexpr SYS_FORCE_INLINE bool isEqual(const UT_Vector2T &b, const T tolerance=SYS_FTOLERANCE) const noexcept
void dehomogenize()
Express the point in homogeneous coordinates or vice-versa.
T distance2d(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
constexpr SYS_FORCE_INLINE UT_Vector2T< T > & operator=(const UT_Vector2T< T > &that)=default
constexpr SYS_FORCE_INLINE UT_Vector2T(const fpreal16 v[]) noexcept
void homogenize()
Express the point in homogeneous coordinates or vice-versa.