55#ifndef DVD_MATH_VECTORS_H_
56#define DVD_MATH_VECTORS_H_
64 bool Fneq128( __m128
const& a, __m128
const& b )
noexcept;
65 bool Fneq128( __m128
const& a, __m128
const& b,
const F32 epsilon )
noexcept;
66 __m128
DotSimd(
const __m128& a,
const __m128& b )
noexcept;
67 __m128
SimpleDot( __m128 a, __m128 b )
noexcept;
77 explicit SimdVector( T reg0, T reg1, T reg2, T reg3 ) noexcept :
_reg{ reg0, reg1, reg2, reg3 }
105 explicit SimdVector(
F32 reg[4] ) noexcept :
_reg( _mm_set_ps( reg[3], reg[2], reg[1], reg[0] ) )
128 template <
typename T>
139 template<
typename U>
requires std::is_pod_v<U>
143 vec2( T xIn, T yIn ) noexcept :
x( xIn ),
y( yIn )
146 template <
typename U>
requires std::is_pod_v<U>
147 vec2( U xIn, U yIn ) noexcept :
x(
static_cast<T
>(xIn) ),
y(
static_cast<T
>(yIn) )
150 template <
typename U,
typename V>
requires std::is_pod_v<U> && std::is_pod_v<U>
151 vec2( U xIn, V yIn ) noexcept :
x(
static_cast<T
>(xIn) ),
y(
static_cast<T
>(yIn) )
163 template<
typename U>
requires std::is_pod_v<U>
167 template<
typename U>
requires std::is_pod_v<U>
171 template<
typename U>
requires std::is_pod_v<U>
178 return x > v.x &&
y > v.y;
182 return x < v.x&&
y < v.y;
186 return *
this < v || *
this == v;
190 return *
this > v || *
this == v;
200 template<
typename U>
requires std::is_pod_v<U>
205 template<
typename U>
requires std::is_pod_v<U>
211 template<
typename U>
requires std::is_pod_v<U>
214 return vec2( this->
x - _f, this->
y - _f );
216 template<
typename U>
requires std::is_pod_v<U>
219 return vec2( this->
x + _f, this->
y + _f );
221 template<
typename U>
requires std::is_pod_v<U>
224 return vec2( this->
x * _f, this->
y * _f );
226 template<
typename U>
requires std::is_pod_v<U>
231 return vec2( this->
x / _i, this->
y / _i );
235 template<
typename U>
requires std::is_pod_v<U>
238 return vec2( this->
x + v.x, this->y + v.y );
240 template<
typename U>
requires std::is_pod_v<U>
243 return vec2( this->
x - v.x, this->y - v.y );
245 template<
typename U>
requires std::is_pod_v<U>
248 return vec2( this->
x * v.x, this->y * v.y );
253 return vec2( -this->
x, -this->
y );
256 template<
typename U>
requires std::is_pod_v<U>
259 this->
set( *
this + _f );
return *
this;
261 template<
typename U>
requires std::is_pod_v<U>
264 this->
set( *
this - _f );
return *
this;
266 template<
typename U>
requires std::is_pod_v<U>
269 this->
set( *
this * _f );
return *
this;
271 template<
typename U>
requires std::is_pod_v<U>
274 this->
set( *
this / _f );
return *
this;
277 template<
typename U>
requires std::is_pod_v<U>
280 this->
set( *
this * v );
return *
this;
282 template<
typename U>
requires std::is_pod_v<U>
285 this->
set( *
this + v );
return *
this;
287 template<
typename U>
requires std::is_pod_v<U>
290 this->
set( *
this - v );
return *
this;
292 template<
typename U>
requires std::is_pod_v<U>
295 this->
set( *
this / v );
return *
this;
298 template<
typename U>
requires std::is_unsigned_v<U>
303 template<
typename U>
requires std::is_unsigned_v<U>
311 return vec2(
IS_ZERO( v.x ) ? this->x : this->x / v.x,
312 IS_ZERO( v.y ) ? this->y : this->y / v.y );
315 [[nodiscard]]
operator T* ()
noexcept
319 [[nodiscard]]
operator const T* ()
const noexcept
327 std::swap( this->
x, iv->x ); std::swap( this->
x, iv->x );
332 std::swap( this->
x, iv.x ); std::swap( this->
x, iv.x );
335 void set(
const T* v )
noexcept
337 std::memcpy( &
_v[0], &v[0],
sizeof( T ) * 2 );
340 void set( T value )
noexcept
342 this->
set( value, value );
345 void set( T xIn, T yIn )
noexcept
347 this->
x = xIn; this->
y = yIn;
349 template <
typename U>
requires std::is_pod_v<U>
350 void set( U xIn, U yIn )
noexcept
352 this->
x =
static_cast<T
>(xIn); this->
y =
static_cast<T
>(yIn);
357 this->
set( &v._v[0] );
362 this->
set( v.x, v.y );
367 this->
set( v.x, v.y );
383 return static_cast<T
>(std::atan2( this->
y, this->
x ));
388 return static_cast<T
>(std::atan2( v.
y - this->y, v.
x - this->x ));
403 void lerp( const
vec2& v, T factor ) noexcept;
405 void lerp( const
vec2& v, const
vec2& factor ) noexcept;
407 [[nodiscard]] T
dot( const
vec2& v ) const noexcept;
415 template<typename U> requires
std::is_pod_v<U>
418 template<typename U> requires
std::is_pod_v<U>
421 [[nodiscard]]
void get( T* v ) const;
446 T
_v[2] = {T{0}, T{0} };
451 template <
typename T,
typename U>
requires std::is_pod_v<U>
452 [[nodiscard]] vec2<T>
Lerp( vec2<T> u, vec2<T> v, U factor )
noexcept;
454 template <
typename T>
455 [[nodiscard]] vec2<T>
Lerp( vec2<T> u, vec2<T> v, vec2<T> factor )
noexcept;
456 template <
typename T>
457 [[nodiscard]] vec2<T>
Cross( vec2<T> v1, vec2<T> v2 )
noexcept;
458 template <
typename T>
459 [[nodiscard]] vec2<T>
Inverse( vec2<T> v )
noexcept;
460 template <
typename T>
462 template <
typename T>
464 template <
typename T>
466 template <
typename T>
469 template <
typename T>
471 template <
typename T>
478 template <
typename T>
486 vec3( T value ) noexcept :
vec3( value, value, value )
489 template<
typename U>
requires std::is_pod_v<U>
490 vec3( U value ) noexcept :
vec3( value, value, value )
493 vec3( T xIn, T yIn, T zIn ) noexcept :
x( xIn ),
y( yIn ),
z( zIn )
496 template <
typename U>
requires std::is_pod_v<U>
497 vec3( U xIn, U yIn, U zIn ) noexcept :
x(
static_cast<T
>(xIn) ),
y(
static_cast<T
>(yIn) ),
z(
static_cast<T
>(zIn) )
500 template <
typename U,
typename V>
501 vec3( U xIn, U yIn, V zIn ) noexcept :
x(
static_cast<T
>(xIn) ),
y(
static_cast<T
>(yIn) ),
z(
static_cast<T
>(zIn) )
504 template <
typename U,
typename V>
505 vec3( U xIn, V yIn, V zIn ) noexcept :
x(
static_cast<T
>(xIn) ),
y(
static_cast<T
>(yIn) ),
z(
static_cast<T
>(zIn) )
508 template <
typename U,
typename V,
typename W>
509 vec3( U xIn, V yIn, W zIn ) noexcept :
x(
static_cast<T
>(xIn) ),
y(
static_cast<T
>(yIn) ),
z(
static_cast<T
>(zIn) )
512 vec3(
const T* v ) noexcept :
vec3( v[0], v[1], v[2] )
524 template<
typename U>
requires std::is_pod_v<U>
528 template<
typename U>
requires std::is_pod_v<U>
532 template<
typename U>
requires std::is_pod_v<U>
539 return x > v.x &&
y > v.y &&
z > v.z;
543 return x < v.x&&
y < v.y&&
z < v.z;
547 return *
this < v || *
this == v;
551 return *
this > v || *
this == v;
561 template<
typename U>
requires std::is_pod_v<U>
566 template<
typename U>
requires std::is_pod_v<U>
572 template <
typename U>
requires std::is_pod_v<U>
575 return vec3( this->
x + _f, this->
y + _f, this->
z + _f );
577 template <
typename U>
requires std::is_pod_v<U>
580 return vec3( this->
x - _f, this->
y - _f, this->
z - _f );
582 template <
typename U>
requires std::is_pod_v<U>
585 return vec3( this->
x * _f, this->
y * _f, this->
z * _f );
587 template <
typename U>
requires std::is_pod_v<U>
593 }
return vec3( this->
x / _f, this->
y / _f, this->
z / _f );
598 return vec3( -this->
x, -this->
y, -this->
z );
601 template <
typename U>
requires std::is_pod_v<U>
604 return vec3( this->
x + v.x, this->y + v.y, this->z + v.z );
606 template <
typename U>
requires std::is_pod_v<U>
609 return vec3( this->
x - v.x, this->y - v.y, this->z - v.z );
611 template<
typename U>
requires std::is_pod_v<U>
614 return vec3( this->
x * v.x, this->y * v.y, this->z * v.z );
617 template<
typename U>
requires std::is_pod_v<U>
620 this->
set( *
this + _f );
return *
this;
622 template<
typename U>
requires std::is_pod_v<U>
625 this->
set( *
this - _f );
return *
this;
627 template<
typename U>
requires std::is_pod_v<U>
630 this->
set( *
this * _f );
return *
this;
632 template<
typename U>
requires std::is_pod_v<U>
635 this->
set( *
this / _f );
return *
this;
638 template<
typename U>
requires std::is_pod_v<U>
641 this->
set( *
this * v );
return *
this;
643 template<
typename U>
requires std::is_pod_v<U>
646 this->
set( *
this + v );
return *
this;
648 template<
typename U>
requires std::is_pod_v<U>
651 this->
set( *
this - v );
return *
this;
653 template<
typename U>
requires std::is_pod_v<U>
656 this->
set( *
this / v );
return *
this;
659 template<
typename U>
requires std::is_unsigned_v<U>
664 template<
typename U>
requires std::is_unsigned_v<U>
665 [[nodiscard]]
const T&
operator[](
const U i )
const noexcept
670 template<
typename U>
requires std::is_pod_v<U>
673 return vec3(
IS_ZERO( v.x ) ? this->x : this->x / v.x,
674 IS_ZERO( v.y ) ? this->y : this->y / v.y,
675 IS_ZERO( v.z ) ? this->z : this->z / v.z );
678 [[nodiscard]]
operator T* ()
noexcept
682 [[nodiscard]]
operator const T* ()
const noexcept
699 this->
r =
rb.x; this->
b =
rb.y;
703 this->
x =
xz.x; this->
z =
xz.y;
707 void set(
const T* v )
noexcept
709 std::memcpy( &
_v[0], &v[0], 3 *
sizeof( T ) );
712 void set( T value )
noexcept
714 x = value;
y = value;
z = value;
717 void set( T xIn, T yIn, T zIn )
noexcept
719 this->
x = xIn; this->
y = yIn; this->
z = zIn;
721 template <
typename U>
requires std::is_pod_v<U>
722 void set( U xIn, U yIn, U zIn )
noexcept
724 this->
x =
static_cast<T
>(xIn); this->
y =
static_cast<T
>(yIn); this->
z =
static_cast<T
>(zIn);
729 std::memcpy(
_v, v._v, 2 *
sizeof( T ) );
734 std::memcpy(
_v, v._v, 3 *
sizeof( T ) );
739 std::memcpy(
_v, v._v, 3 *
sizeof( T ) );
744 std::memset(
_v, 0, 3 *
sizeof( T ) );
757 template<
typename U>
requires std::is_pod_v<U>
760 template<
typename U>
requires std::is_pod_v<U>
763 [[nodiscard]]
bool isUniform(
F32 tolerance = 0.0001f ) const noexcept;
765 template<typename U> requires
std::is_pod_v<U>
770 [[nodiscard]] T
dot( const
vec3& v ) const noexcept;
774 [[nodiscard]] T
distance( const
vec3& v ) const noexcept;
798 void lerp( const
vec3& v, T factor ) noexcept;
801 void lerp( const
vec3& v, const
vec3& factor ) noexcept;
822 void get( T* v ) const noexcept;
863 T
_v[3] = {T{0}, T{0}, T{0}};
868 template <
typename T,
typename U>
requires std::is_pod_v<U>
869 [[nodiscard]] vec3<T>
Lerp(
const vec3<T>& u,
const vec3<T>& v, U factor )
noexcept;
871 template <
typename T>
872 [[nodiscard]] vec3<T>
Lerp(
const vec3<T>& u,
const vec3<T>& v,
const vec3<T>& factor )
noexcept;
873 template <
typename T>
874 [[nodiscard]] vec3<T>
Abs(
const vec3<T>&
vector )
noexcept;
875 template <
typename T>
876 [[nodiscard]] vec3<T>
Min(
const vec3<T>& v1,
const vec3<T>& v2 )
noexcept;
877 template <
typename T>
878 [[nodiscard]] vec3<T>
Max(
const vec3<T>& v1,
const vec3<T>& v2 )
noexcept;
879 template <
typename T>
881 template <
typename T>
884 template <
typename T>
885 [[nodiscard]] T
Dot(
const vec3<T>& a,
const vec3<T>& b )
noexcept;
887 template <
typename T>
888 [[nodiscard]] vec3<T>
Cross(
const vec3<T>& v1,
const vec3<T>& v2 )
noexcept;
889 template <
typename T>
890 [[nodiscard]] vec3<T>
AreOrthogonal(
const vec3<T>& v1,
const vec3<T>& v2 )
noexcept;
891 template <
typename T>
892 [[nodiscard]] vec3<T>
Inverse(
const vec3<T>& v )
noexcept;
893 template <
typename T>
894 [[nodiscard]] vec3<T>
operator*( T fl,
const vec3<T>& v )
noexcept;
897 [[nodiscard]] vec3<T>
ProjectToNorm(
const vec3<T>& in,
const vec3<T>& direction );
898 template <
typename T>
900 template <
typename T>
901 void OrthoNormalize( vec3<T>& v1, vec3<T>& v2, vec3<T>& v3 )
noexcept;
903 [[nodiscard]] vec3<T>
Perpendicular(
const vec3<T>& v )
noexcept;
904 template <
typename T>
905 [[nodiscard]] vec3<T>
Clamped(
const vec3<T>& v,
const vec3<T>& min,
const vec3<T>& max )
noexcept;
913 template <
typename T>
921 vec4( T xIn, T yIn, T zIn, T wIn ) noexcept :
x( xIn ),
y( yIn ),
z( zIn ),
w( wIn )
924 vec4( T xIn, T yIn, T zIn ) noexcept :
x( xIn ),
y( yIn ),
z( zIn ),
w( T{1} )
927 template<
typename U>
requires std::is_pod_v<U>
928 vec4( U xIn, U yIn, U zIn, U wIn ) noexcept :
x(
static_cast<T
>(xIn) ),
y(
static_cast<T
>(yIn) ),
z(
static_cast<T
>(zIn) ),
w(
static_cast<T
>(wIn) )
931 template<
typename U>
requires std::is_pod_v<U>
932 vec4( U xIn, U yIn, U zIn ) noexcept :
vec4( xIn, yIn, zIn, T{1} )
941 vec4( T value ) noexcept :
vec4( value, value, value, value )
944 template<
typename U>
requires std::is_pod_v<U>
945 vec4( U value ) noexcept :
vec4( value, value, value, value )
948 vec4(
const T* v ) noexcept :
vec4( v[0], v[1], v[2], v[3] )
966 template<
typename U>
requires std::is_pod_v<U>
970 template<
typename U>
requires std::is_pod_v<U>
974 template<
typename U>
requires std::is_pod_v<U>
981 return x > v.x &&
y > v.y &&
z > v.z &&
w > v.w;
985 return x < v.x&&
y < v.y&&
z < v.z&&
w < v.w;
989 return *
this < v || *
this == v;
993 return *
this > v || *
this == v;
1003 template<
typename U>
requires std::is_pod_v<U>
1008 template<
typename U>
requires std::is_pod_v<U>
1014 template<
typename U>
requires std::is_pod_v<U>
1017 return vec4( this->
x - _f, this->
y - _f, this->
z - _f, this->
w - _f );
1019 template<
typename U>
requires std::is_pod_v<U>
1022 return vec4( this->
x + _f, this->
y + _f, this->
z + _f, this->
w + _f );
1024 template<
typename U>
requires std::is_pod_v<U>
1027 return vec4( this->
x * _f, this->
y * _f, this->
z * _f, this->
w * _f );
1029 template<
typename U>
requires std::is_pod_v<U>
1034 return vec4(
static_cast<T
>(this->
x / _f),
1035 static_cast<T
>(this->
y / _f),
1036 static_cast<T
>(this->
z / _f),
1037 static_cast<T
>(this->
w / _f) );
1048 template<
typename U>
requires std::is_pod_v<U>
1051 return vec4( this->
x + v.x, this->y + v.y, this->z + v.z, this->w + v.w );
1053 template<
typename U>
requires std::is_pod_v<U>
1056 return vec4( this->
x - v.x, this->y - v.y, this->z - v.z, this->w - v.w );
1058 template<
typename U>
requires std::is_pod_v<U>
1061 return vec4( this->
x * v.x, this->y * v.y, this->z * v.z, this->w * v.w );
1063 template<
typename U>
requires std::is_pod_v<U>
1066 return vec4(
IS_ZERO( v.x ) ? this->x : this->x / v.x,
1067 IS_ZERO( v.y ) ? this->y : this->y / v.y,
1068 IS_ZERO( v.z ) ? this->z : this->z / v.z,
1069 IS_ZERO( v.w ) ? this->w : this->w / v.w );
1072 template<
typename U>
requires std::is_pod_v<U>
1075 this->
set( *
this + _f );
return *
this;
1077 template<
typename U>
requires std::is_pod_v<U>
1080 this->
set( *
this - _f );
return *
this;
1082 template<
typename U>
requires std::is_pod_v<U>
1085 this->
set( *
this * _f );
return *
this;
1087 template<
typename U>
requires std::is_pod_v<U>
1092 this->
set( *
this / _f );
1096 template<
typename U>
requires std::is_pod_v<U>
1099 this->
set( *
this * v );
return *
this;
1101 template<
typename U>
requires std::is_pod_v<U>
1104 this->
set( *
this / v );
return *
this;
1106 template<
typename U>
requires std::is_pod_v<U>
1109 this->
set( *
this + v );
return *
this;
1111 template<
typename U>
requires std::is_pod_v<U>
1114 this->
set( *
this - v );
return *
this;
1117 [[nodiscard]]
operator T* ()
noexcept
1121 [[nodiscard]]
operator const T* ()
const noexcept
1126 template<
typename U>
requires std::is_unsigned_v<U>
1131 template<
typename U>
requires std::is_unsigned_v<U>
1134 return this->
_v[_i];
1187 void xz( T xIn, T zIn )
noexcept
1189 this->
x = xIn; this->
z = zIn;
1199 void xw( T xIn, T wIn )
noexcept
1201 this->
x = xIn; this->
w = wIn;
1211 void yw( T yIn, T wIn )
noexcept
1213 this->
y = yIn; this->
w = wIn;
1231 void xyw( T xIn, T yIn, T wIn )
noexcept
1233 xy( xIn, yIn ); this->
w = wIn;
1235 void xzw( T xIn, T zIn, T wIn )
noexcept
1237 xz( xIn, zIn ); this->
w = wIn;
1241 void set(
const T* v )
noexcept
1243 std::memcpy(
_v, v, 4 *
sizeof( T ) );
1251 void set( T xIn, T yIn, T zIn, T wIn )
noexcept
1255 template <
typename U>
requires std::is_pod_v<U>
1256 void set( U xIn, U yIn, U zIn, U wIn )
noexcept
1258 set(
static_cast<T
>(xIn),
static_cast<T
>(yIn),
static_cast<T
>(zIn),
static_cast<T
>(wIn) );
1268 std::memcpy( &
_v[0], &v._v[0], 3 *
sizeof( T ) );
1273 std::memcpy( &
_v[0], &v._v[0], 3 *
sizeof( T ) );
w = wIn;
1278 std::memcpy( &
_v[0], &v._v[0], 2 *
sizeof( T ) );
1283 this->
set( v1.x, v1.y, v2.x, v2.y );
1291 template<
typename U>
requires std::is_pod_v<U>
1294 template<
typename U>
requires std::is_pod_v<U>
1303 template<typename U> requires
std::is_pod_v<U>
1310 [[nodiscard]] T
dot( const
vec4& v ) const noexcept;
1321 void round() noexcept;
1323 void lerp( const
vec4& v, T factor ) noexcept;
1325 void lerp( const
vec4& v, const
vec4& factor ) noexcept;
1397 T
_v[4] = {T{0}, T{0}, T{0}, T{1}};
1404 template <
typename T>
1405 [[nodiscard]] vec4<T>
Lerp(
const vec4<T>& u,
const vec4<T>& v, T factor )
noexcept;
1407 template <
typename T>
1408 [[nodiscard]] vec4<T>
Lerp(
const vec4<T>& u,
const vec4<T>& v,
const vec4<T>& factor )
noexcept;
1409 template <
typename T>
1410 [[nodiscard]] vec4<T>
Abs(
const vec4<T>&
vector )
noexcept;
1412 template <
typename T>
1413 [[nodiscard]] vec4<T>
Min(
const vec4<T>& v1,
const vec4<T>& v2 )
noexcept;
1414 template <
typename T>
1415 [[nodiscard]] vec4<T>
Max(
const vec4<T>& v1,
const vec4<T>& v2 )
noexcept;
1416 template <
typename T>
1418 template <
typename T>
1421 template <
typename T>
1422 [[nodiscard]] vec4<T>
operator*( T fl,
const vec4<T>& v )
noexcept;
1423 template <
typename T>
1425 template <
typename T>
1427 template<
typename T>
1428 [[nodiscard]] vec4<T>
Perpendicular(
const vec4<T>& vec,
const vec4<T>& hint1,
const vec4<T>& hint2 )
noexcept;
1429 template <
typename T>
1430 [[nodiscard]] vec4<T>
Clamped(
const vec4<T>& v,
const vec4<T>& min,
const vec4<T>& max )
noexcept;
1458 template<
typename T>
1464 template<
typename U>
requires std::is_pod_v<U>
1465 [[nodiscard]]
bool contains( U xIn, U yIn )
const noexcept
1467 return COORDS_IN_RECT(
static_cast<T
>(xIn),
static_cast<T
>(yIn), *
this );
1471 return contains( coords.x, coords.y );
1473 [[nodiscard]]
bool contains( T xIn, T yIn )
const noexcept
1483 return clamp( coords.x, coords.y );
bool contains(U xIn, U yIn) const noexcept
bool contains(const vec2< T > coords) const noexcept
vec2< T > clamp(const vec2< T > coords) const noexcept
bool contains(T xIn, T yIn) const noexcept
vec2< T > clamp(T xIn, T yIn) const noexcept
SimdVector(F32 reg[4]) noexcept
SimdVector(F32 reg) noexcept
SimdVector(const __m128 reg) noexcept
bool operator!=(const SimdVector &other) const noexcept
SimdVector(F32 reg0, F32 reg1, F32 reg2, F32 reg3) noexcept
bool operator==(const SimdVector &other) const noexcept
SimdVector(T val) noexcept
bool operator==(const SimdVector &) const =default
SimdVector(T reg[4]) noexcept
SimdVector(T reg0, T reg1, T reg2, T reg3) noexcept
void set(const vec2 &v) noexcept
set the 2 components of the vector using a source vector
vec2 & operator+=(const vec2< U > v) noexcept
bool compare(vec2< U > v) const noexcept
compare 2 vectors
void lerp(const vec2 &v, T factor) noexcept
lerp between this and the specified vector by the specified amount
vec2 operator+(const vec2< U > v) const noexcept
T minComponent() const noexcept
get the smallest value of X or Y
void set(const vec4< T > &v) noexcept
set the 2 components of the vector using the first 2 components of the source vector
void swap(vec2 *iv) noexcept
swap the components of this vector with that of the specified one
vec2 closestPointOnSegment(const vec2 &vA, const vec2 &vB)
return the closest point on the line segment defined between the 2 points (A, B) and this vector
bool operator<=(const vec2 &v) const noexcept
vec2 operator+(U _f) const noexcept
vec2 & normalize() noexcept
convert the vector to unit length
T distance(const vec2 &v) const
compute the vector's distance to another specified vector
T angle() const
return the angle defined by the 2 components
vec2(const vec4< T > &_v) noexcept
vec2 & operator-=(const vec2< U > v) noexcept
void set(T value) noexcept
set the 2 components of the vector manually
vec2 & operator/=(U _f) noexcept
vec2 & operator+=(U _f) noexcept
vec2(const T *_v) noexcept
T & operator[](U i) noexcept
bool operator==(const vec2< U > &v) const noexcept
vec2 operator*(const vec2< U > v) const noexcept
void set(const T *v) noexcept
set the 2 components of the vector manually using a source pointer to a (large enough) array
vec2(const vec2< U > &v) noexcept
bool operator>(const vec2 &v) const noexcept
vec2 & operator*=(U _f) noexcept
vec2 & operator/=(const vec2< U > v) noexcept
void set(U xIn, U yIn) noexcept
void reset()
set the 2 components of the vector back to 0
vec2(const vec3< T > &_v) noexcept
vec2 & operator-=(U _f) noexcept
vec2 operator/(U _i) const noexcept
T maxComponent() const noexcept
get the largest value of X or Y
T distanceSquared(const vec2 &v) const noexcept
compute the vector's squared distance to another specified vector
bool operator<(const vec2 &v) const noexcept
vec2 closestPointOnLine(const vec2 &vA, const vec2 &vB)
return the closest point on the line defined by the 2 points (A, B) and this vector
void set(T xIn, T yIn) noexcept
set the 2 components of the vector manually
vec2 operator*(U _f) const noexcept
vec2 operator-() const noexcept
vec2 operator-(const vec2< U > v) const noexcept
vec2(const vec3< U > &v) noexcept
const T & operator[](U i) const noexcept
T lengthSquared() const noexcept
return the squared distance of the vector
void round()
round both values
bool operator!=(const vec2 &v) const noexcept
vec2 operator-(U _f) const noexcept
void get(T *v) const
export the vector's components in the first 2 positions of the specified array
vec2(const vec4< U > &v) noexcept
vec2(U xIn, U yIn) noexcept
T length() const noexcept
return the vector's length
void set(const vec3< T > &v) noexcept
set the 2 components of the vector using the first 2 components of the source vector
vec2(T xIn, T yIn) noexcept
T projectionOnLine(const vec2 &vA, const vec2 &vB) const
project this vector on the line defined by the 2 points(A, B)
void swap(vec2 &iv) noexcept
swap the components of this vector with that of the specified one
bool operator==(const vec2 &v) const noexcept
T dot(const vec2 &v) const noexcept
calculate the dot product between this vector and the specified one
bool operator!=(const vec2< U > &v) const noexcept
T angle(const vec2 &v) const
return the angle defined by the 2 components
vec2 & operator*=(const vec2< U > v) noexcept
vec2 operator/(const vec2 &v) const noexcept
bool operator>=(const vec2 &v) const noexcept
vec2(U xIn, V yIn) noexcept
bool operator==(const vec3< U > &v) const noexcept
T angle(vec3 &v) const
returns the angle in radians between '*this' and 'v'
vec2< T > xz() const noexcept
T dot(const vec3 &v) const noexcept
calculate the dot product between this vector and the specified one
vec3 & operator-=(U _f) noexcept
void set(const vec4< T > &v) noexcept
set the 3 components of the vector using the first 3 components of the source vector
vec3 & normalize() noexcept
transform the vector to unit length
bool operator>(const vec3 &v) const noexcept
vec3(U xIn, U yIn, U zIn) noexcept
void lerp(const vec3 &v, T factor) noexcept
lerp between this and the specified vector by the specified amount
vec3(U xIn, V yIn, V zIn) noexcept
T length() const noexcept
return the vector's length
vec3(const vec2< T > v, T zIn) noexcept
T maxComponent() const noexcept
get the largest value of X,Y or Z
bool operator!=(const vec3< U > &v) const noexcept
vec3 & operator/=(const vec3< U > &v) noexcept
const T & operator[](const U i) const noexcept
vec3 & operator-=(const vec3< U > &v) noexcept
bool operator==(const vec3 &v) const noexcept
bool operator<(const vec3 &v) const noexcept
bool isZeroLength() const noexcept
return true if length is zero
void reset() noexcept
set all the components back to 0
T projectionOnLine(const vec3 &vA, const vec3 &vB) const
project this vector on the line defined by the 2 points(A, B)
vec3 closestPointOnLine(const vec3 &vA, const vec3 &vB)
void swap(vec3 &iv) noexcept
swap the components of this vector with that of the specified one
bool compare(const vec3< U > &v, U epsi) const noexcept
compare 2 vectors within the specified tolerance
vec3 operator+(const vec3< U > &v) const noexcept
vec3(U xIn, V yIn, W zIn) noexcept
T minComponent() const noexcept
get the smallest value of X,Y or Z
vec3(const vec2< T > v) noexcept
void rotateX(D64 radians)
rotate this vector on the X axis
T lengthSquared() const noexcept
return the squared distance of the vector
vec3 operator/(U _f) const noexcept
vec3 operator-(const vec3< U > &v) const noexcept
vec3 operator/(const vec3< U > &v) const noexcept
T & operator[](const U i) noexcept
vec3(const vec4< T > &v) noexcept
vec3 direction(const vec3 &u) const noexcept
get the direction vector to the specified point
void cross(const vec3 &v1, const vec3 &v2) noexcept
set this vector to be equal to the cross of the 2 specified vectors
vec3 closestPointOnSegment(const vec3 &vA, const vec3 &vB)
bool operator<=(const vec3 &v) const noexcept
vec3 operator-(U _f) const noexcept
void rotateZ(D64 radians)
rotate this vector on the Z axis
void get(T *v) const noexcept
vec3(U xIn, U yIn, V zIn) noexcept
bool isUniform(F32 tolerance=0.0001f) const noexcept
uniform vector: x = y = z
void xz(const vec2< T > xz) noexcept
vec3(const vec2< U > v) noexcept
void set(T value) noexcept
set the 3 components of the vector manually
void set(U xIn, U yIn, U zIn) noexcept
vec3(const T *v) noexcept
bool operator!=(const vec3 &v) const noexcept
void rotateY(D64 radians)
rotate this vector on the Y axis
vec3 & operator+=(const vec3< U > &v) noexcept
vec3 operator+(U _f) const noexcept
vec3 & operator/=(U _f) noexcept
vec3 & operator*=(U _f) noexcept
void rb(const vec2< T > rb) noexcept
vec3 & operator*=(const vec3< U > &v) noexcept
void set(const T *v) noexcept
set the 3 components of the vector manually using a source pointer to a (large enough) array
vec3 operator*(U _f) const noexcept
void set(const vec2< T > v) noexcept
set the 3 components of the vector using a smaller source vector
bool operator>=(const vec3 &v) const noexcept
void set(T xIn, T yIn, T zIn) noexcept
set the 3 components of the vector manually
vec3(const vec4< U > &v) noexcept
T distanceSquared(const vec3 &v) const noexcept
compute the vector's squared distance to another specified vector
vec3(T xIn, T yIn, T zIn) noexcept
vec3 operator-() const noexcept
vec3 projectToNorm(const vec3< T > &direction) noexcept
project this vector onto the given direction
vec2< T > rb() const noexcept
GLSL like accessors (const to prevent erroneous usage like .xy() += n)
bool compare(const vec3< U > &v) const noexcept
compare 2 vectors
bool isPerpendicular(const vec3< U > &other, F32 epsilon=EPSILON_F32) const noexcept
The current vector is perpendicular to the specified one within epsilon.
void set(const vec3 &v) noexcept
set the 3 components of the vector using a source vector
T distance(const vec3 &v) const noexcept
compute the vector's distance to another specified vector
vec3 operator*(const vec3< U > &v) const noexcept
vec3 & operator+=(U _f) noexcept
void round()
round all three values
vec3(const vec3< U > &v) noexcept
vec4 operator*(const vec4< U > &v) const noexcept
vec4 & operator+=(U _f) noexcept
vec4(const vec2< U > v) noexcept
void set(const T *v) noexcept
set the 4 components of the vector manually using a source pointer to a (large enough) array
vec4 operator-() const noexcept
vec4 projectToNorm(const vec4< T > &direction)
project this vector onto the given direction
vec2< T > ga() const noexcept
void rb(const vec2< T > rb) noexcept
vec2< T > xw() const noexcept
void yw(T yIn, T wIn) noexcept
vec4 operator+(U _f) const noexcept
void set(const vec3< T > &v) noexcept
set the 4 components of the vector using a smaller source vector
T maxComponent() const noexcept
get the largest value of X,Y,Z or W
vec4 operator-(U _f) const noexcept
void set(const vec2< T > v) noexcept
set the 4 components of the vector using a smaller source vector
void bgr(const vec3< T > &bgr) noexcept
void xw(const vec2< T > xw) noexcept
void reset() noexcept
set all the components back to 0
vec4(const vec2< T > v) noexcept
void zyx(const vec3< T > &zyx) noexcept
vec2< T > yw() const noexcept
void yw(const vec2< T > yw) noexcept
void xw(T xIn, T wIn) noexcept
bool operator<=(const vec4 &v) const noexcept
bool operator!=(const vec4 &v) const noexcept
bool operator>=(const vec4 &v) const noexcept
void xz(T xIn, T zIn) noexcept
T & operator[](U i) noexcept
vec2< T > rb() const noexcept
GLSL like accessors (const to prevent erroneous usage like .xyz() += n)
vec4(const vec2< T > v, T zIn) noexcept
vec3< T > xyw() const noexcept
vec4 & operator-=(U _f) noexcept
bool operator>(const vec4 &v) const noexcept
vec4 operator*(U _f) const noexcept
vec4 & operator*=(U _f) noexcept
vec4(const vec3< T > &v, T wIn) noexcept
T lengthSquared() const noexcept
return the squared distance of the vector
void round() noexcept
round all four values
vec2< T > ra() const noexcept
void swap(vec4 *iv) noexcept
swap the components of this vector with that of the specified one
vec4 & operator/=(U _f) noexcept
vec4 operator/(const vec4< U > &v) const noexcept
vec4(T xIn, T yIn, T zIn) noexcept
bool operator==(const vec4< U > &v) const noexcept
vec3< T > rga() const noexcept
void xzw(T xIn, T zIn, T wIn) noexcept
T minComponent() const noexcept
get the smallest value of X,Y,Z or W
vec4 & operator/=(const vec4< U > &v) noexcept
const T & operator[](U _i) const noexcept
void set(const vec2< T > v1, const vec2< T > v2) noexcept
set the 4 components of the vector using smaller source vectors
vec4(U xIn, U yIn, U zIn) noexcept
vec4(__m128 reg) noexcept
void lerp(const vec4 &v, T factor) noexcept
lerp between this and the specified vector by the specified amount
bool compare(const vec4< U > &v) const noexcept
compare 2 vectors
vec4(const vec4< U > &v) noexcept
T length() const noexcept
return the vector's length
void xyw(T xIn, T yIn, T wIn) noexcept
vec4 operator+(const vec4< U > &v) const noexcept
void xz(const vec2< T > xz) noexcept
vec4 & normalize() noexcept
transform the vector to unit length
vec4(const T *v) noexcept
void set(T value) noexcept
set the 4 components of the vector manually
bool isPerpendicular(const vec4< U > &other, F32 epsilon=EPSILON_F32) const noexcept
The current vector is perpendicular to the specified one within epsilon.
void set(U xIn, U yIn, U zIn, U wIn) noexcept
void set(const vec3< T > &v, T wIn) noexcept
set the 4 components of the vector using a smaller source vector
vec4 & operator-=(const vec4< U > &v) noexcept
bool compare(const vec4< U > &v, U epsi) const noexcept
compare 2 vectors within the specified tolerance
vec4(T xIn, T yIn, T zIn, T wIn) noexcept
void ga(const vec2< T > ga) noexcept
vec3< T > bgr() const noexcept
void rga(const vec3< T > &rga) noexcept
void set(const vec4 &v) noexcept
set the 4 components of the vector using a source vector
T dot(const vec4 &v) const noexcept
calculate the dot product between this vector and the specified one
vec4 operator-(const vec4< U > &v) const noexcept
vec4 operator/(U _f) const noexcept
vec3< T > zyx() const noexcept
void set(T xIn, T yIn, T zIn, T wIn) noexcept
set the 4 components of the vector manually
vec4 & operator*=(const vec4< U > &v) noexcept
vec4 & operator+=(const vec4< U > &v) noexcept
void ra(const vec2< T > ra) noexcept
vec4(const vec2< T > v, T zIn, T wIn) noexcept
vec2< T > xz() const noexcept
vec4(const vec3< T > &v) noexcept
vec4(U xIn, U yIn, U zIn, U wIn) noexcept
bool operator<(const vec4 &v) const noexcept
vec4(const vec3< U > &v) noexcept
bool operator!=(const vec4< U > &v) const noexcept
bool operator==(const vec4 &v) const noexcept
vec4(const SimdVector< T > ®) noexcept
void xyw(const vec3< T > &xyw) noexcept
__m128 SimpleDot(__m128 a, __m128 b) noexcept
__m128 DotSimd(const __m128 &a, const __m128 &b) noexcept
bool Fneq128(__m128 const &a, __m128 const &b) noexcept
Handle console commands that start with a forward slash.
static const vec3< I32 > iWORLD_Z_NEG_AXIS
vec2< T > Normalized(vec2< T > vector) noexcept
vec3< T > Abs(const vec3< T > &vector) noexcept
static const vec3< I32 > iWORLD_Z_AXIS
static const vec3< I32 > iVECTOR3_ZERO
bool IS_ZERO(const T X) noexcept
static const Rect< I32 > UNIT_RECT
T Lerp(T v1, T v2, U t) noexcept
static const vec2< F32 > VECTOR2_UNIT
vec2< T > operator*(T fl, vec2< T > v) noexcept
multiply a vector by a value
static const vec3< I32 > iWORLD_Y_AXIS
static const vec2< F32 > VECTOR2_ZERO
Quaternion multiplications require these to be floats.
static const vec3< F32 > WORLD_X_NEG_AXIS
static const vec3< F32 > WORLD_X_AXIS
vec3< T > Min(const vec3< T > &v1, const vec3< T > &v2) noexcept
static const vec3< I32 > iWORLD_X_AXIS
static const vec3< F32 > WORLD_Y_NEG_AXIS
static const vec3< F32 > WORLD_Z_AXIS
void CLAMP_IN_RECT(T &inout_x, T &inout_y, T rect_x, T rect_y, T rect_z, T rect_w) noexcept
vec2< T > Inverse(vec2< T > v) noexcept
vec3< T > Perpendicular(const vec3< T > &v) noexcept
static const vec4< I32 > iVECTOR4_ZERO
static const vec3< I32 > iWORLD_Y_NEG_AXIS
T Dot(vec2< T > a, vec2< T > b) noexcept
general vec2 dot product
constexpr F32 EPSILON_F32
eastl::vector< Type > vector
vec3< T > AreOrthogonal(const vec3< T > &v1, const vec3< T > &v2) noexcept
vec3< T > Max(const vec3< T > &v1, const vec3< T > &v2) noexcept
vec2< T > Normalize(vec2< T > &vector) noexcept
static const vec3< F32 > VECTOR3_UNIT
void OrthoNormalize(vec2< T > &n, vec2< T > &u) noexcept
static const vec4< F32 > VECTOR4_UNIT
static const vec3< F32 > DEFAULT_GRAVITY
static const vec3< F32 > WORLD_Z_NEG_AXIS
vec2< T > Cross(vec2< T > v1, vec2< T > v2) noexcept
general vec2 cross function
static const vec2< I32 > iVECTOR2_ZERO
bool COORDS_IN_RECT(T input_x, T input_y, T rect_x, T rect_y, T rect_z, T rect_w) noexcept
static const vec3< I32 > iWORLD_X_NEG_AXIS
vec3< T > ProjectToNorm(const vec3< T > &in, const vec3< T > &direction)
vec2< T > Clamped(vec2< T > v, vec2< T > min, vec2< T > max) noexcept
static const vec3< F32 > VECTOR3_ZERO
static const vec4< F32 > VECTOR4_ZERO
static const vec3< F32 > WORLD_Y_AXIS
static const Rect< I32 > UNIT_VIEWPORT