13 #ifndef __UT_FixedVector__
14 #define __UT_FixedVector__
23 template<
typename T,ex
int SIZE,
bool INSTANTIATED=false>
48 template<
typename S,
bool S_INSTANTIATED>
85 template <
typename S,
bool S_INSTANTIATED>
98 template<
typename S,
bool S_INSTANTIATED>
109 template<
typename S,
bool S_INSTANTIATED>
115 result[i] =
vec[i] + that[i];
118 template<
typename S,
bool S_INSTANTIATED>
129 template<
typename S,
bool S_INSTANTIATED>
135 result[i] =
vec[i] - that[i];
138 template<
typename S,
bool S_INSTANTIATED>
144 template<
typename S,
bool S_INSTANTIATED>
150 result[i] =
vec[i] * that[i];
165 result[i] =
vec[i] * that;
168 template<
typename S,
bool S_INSTANTIATED>
174 template<
typename S,
bool S_INSTANTIATED>
180 result[i] =
vec[i] / that[i];
200 result[i] =
vec[i] * t;
217 template<
typename S,
bool S_INSTANTIATED>
222 if (
vec[i] !=
T(that[i]))
227 template<
typename S,
bool S_INSTANTIATED>
230 return !(*
this==that);
234 template<
typename S,
bool S_INSTANTIATED>
235 SYS_FORCE_INLINE bool operator<(const UT_FixedVector<S,SIZE,S_INSTANTIATED> &that)
const noexcept
239 if (
vec[i] != that[i])
240 return (
vec[i] < that[i]);
242 return (
vec[SIZE-1] < that[SIZE-1]);
244 template<
typename S,
bool S_INSTANTIATED>
245 SYS_FORCE_INLINE bool operator<=(const UT_FixedVector<S,SIZE,S_INSTANTIATED> &that)
const noexcept
249 if (
vec[i] != that[i])
250 return (
vec[i] < that[i]);
252 return (
vec[SIZE-1] <= that[SIZE-1]);
254 template<
typename S,
bool S_INSTANTIATED>
260 if (
vec[i] != that[i])
261 return (
vec[i] > that[i]);
263 return (
vec[SIZE-1] > that[SIZE-1]);
265 template<
typename S,
bool S_INSTANTIATED>
271 if (
vec[i] != that[i])
272 return (
vec[i] > that[i]);
274 return (
vec[SIZE-1] >= that[SIZE-1]);
309 if (!(
vec[i] >= -tol) || !(
vec[i] <= tol))
314 template<
typename S,
bool S_INSTANTIATED>
320 if (!(
vec[i] >= that[i]-tol) || !(
vec[i] <= that[i]+tol))
362 return SYSsqrt(len2);
364 template<
typename S,
bool S_INSTANTIATED>
368 TheType
result(TheType(
vec[0])*TheType(that[0]));
370 result += TheType(
vec[i])*TheType(that[i]);
373 template<
typename S,
bool S_INSTANTIATED>
377 TheType
v(TheType(
vec[0]) - TheType(that[0]));
381 v = TheType(
vec[i]) - TheType(that[i]);
386 template<
typename S,
bool S_INSTANTIATED>
390 return SYSsqrt(dist2);
415 template<
typename T,ex
int SIZE,
bool INSTANTIATED,
typename S>
421 result[i] = t * a[i];
425 template<
typename T, ex
int SIZE,
bool INSTANTIATED,
typename S,
bool S_INSTANTIATED>
441 template<
typename T,ex
int SIZE,
bool INSTANTIATED>
SYS_FORCE_INLINE void operator*=(T that)
SYS_FORCE_INLINE void operator+=(T that)
SYS_FORCE_INLINE T minComponent() const
SYS_FORCE_INLINE constexpr const T * data() const noexcept
SYS_FORCE_INLINE UT_FixedVector(const S that[SIZE]) noexcept
SYS_FORCE_INLINE UT_FixedVector< T, SIZE > operator-() const
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.
SYS_FORCE_INLINE const ThisType & operator=(T that) noexcept
SYS_FORCE_INLINE void operator*=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that)
SYS_FORCE_INLINE bool operator>(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const noexcept
SYS_FORCE_INLINE bool isNan() const
SYS_FORCE_INLINE const T & operator[](exint i) const noexcept
SYS_FORCE_INLINE void operator/=(T that)
UT_StorageNum< T > Storage
SYS_FORCE_INLINE ThisType & operator=(const ThisType &that)=default
SYS_FORCE_INLINE bool equalZero(T tol=T(SYS_FTOLERANCE)) const
SYS_FORCE_INLINE bool isZero() const noexcept
bool SYSisFinite(fpreal64 f)
UT_FixedVector< T, SIZE, INSTANTIATED > FixedVectorType
GLboolean GLboolean GLboolean GLboolean a
SYS_FORCE_INLINE UT_FixedVector< typename UT_StorageBetter< T, S >::Type, SIZE > operator+(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const
SYS_FORCE_INLINE void negate()
constexpr bool SYSisNan(const F f)
SYS_FORCE_INLINE UT_FixedVector< typename UT_StorageBetter< T, S >::Type, SIZE > operator/(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const
SYS_FORCE_INLINE UT_FixedVector< T, SIZE > operator*(T that) const
static const exint TupleSize
SYS_FORCE_INLINE bool operator==(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const noexcept
SYS_FORCE_INLINE UT_FixedVector()=default
SYS_FORCE_INLINE UT_FixedVector(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) noexcept
SYS_FORCE_INLINE bool isFinite() const
SYS_FORCE_INLINE void operator+=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that)
SYS_FORCE_INLINE void operator/=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that)
SYS_FORCE_INLINE UT_FixedVector< T, SIZE > operator/(T that) const
static const bool isVectorType
SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, S >::Type distance2(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const
SYS_FORCE_INLINE bool operator>=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const noexcept
SYS_FORCE_INLINE bool operator!=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const noexcept
SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, T >::Type length2() const noexcept
SYS_FORCE_INLINE T maxComponent() const
SYS_FORCE_INLINE UT_StorageNum< typename UT_StorageBetter< T, S >::Type >::MathFloat distance(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const
SYS_FORCE_INLINE T * data() noexcept
UT_FixedVector< T, SIZE, INSTANTIATED > ThisType
SYS_FORCE_INLINE UT_FixedVector< typename UT_StorageBetter< T, S >::Type, SIZE > operator*(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const
SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, S >::Type dot(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const
GLdouble GLdouble GLdouble b
typename SYS_SelectType< typename UT_StorageNum< typename UT_StorageBetter< T0, T1 >::Type >::AtLeast32Bit, T0, UT_StorageNum< typename UT_StorageBetter< T0, T1 >::Type >::theStorage==UT_Storage::INVALID >::type Type
SYS_FORCE_INLINE T & operator[](exint i) noexcept
SYS_FORCE_INLINE bool isEqual(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that, S tol=S(SYS_FTOLERANCE)) const
UT_FixedVector< T, 1 > FixedVectorType
SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, S >::Type dot(const UT_FixedVector< T, SIZE, INSTANTIATED > &a, const UT_FixedVector< S, SIZE, S_INSTANTIATED > &b)
SYS_FORCE_INLINE Storage::MathFloat normalize()
SYS_FORCE_INLINE void operator-=(T that)
SYS_FORCE_INLINE ThisType & operator=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) noexcept
vint4 min(const vint4 &a, const vint4 &b)
SYS_FORCE_INLINE UT_FixedVector< typename UT_StorageBetter< T, S >::Type, SIZE > operator-(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const
SYS_FORCE_INLINE Storage::MathFloat length() const
SYS_FORCE_INLINE UT_FixedVector(T that) noexcept
Initializes every component to the same value.
SYS_FORCE_INLINE T avgComponent() const
static const exint theSize
SYS_FORCE_INLINE void operator-=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that)