21 #ifndef GF_VECTOR_OPS_H    22 #define GF_VECTOR_OPS_H    26 #include <type_traits>    32 #ifndef DOXYGEN_SHOULD_SKIP_THIS    40   template<
typename T, std::
size_t N>
    43     for (std::size_t i = 0; i < 
N; ++i) {
    56   template<
typename T, std::
size_t N>
    66   template<
typename T, std::
size_t N>
    71     for (std::size_t i = 0; i < 
N; ++i) {
    82   template<
typename T, 
typename U, std::
size_t N>
    87     for (std::size_t i = 0; i < 
N; ++i) {
    98   template<
typename T, 
typename U, std::
size_t N>
   101     for (std::size_t i = 0; i < 
N; ++i) {
   112   template<typename T, typename U, std::size_t N, typename E = typename std::enable_if<std::is_arithmetic<U>::value, 
U>::type>
   117     for (std::size_t i = 0; i < 
N; ++i) {
   128   template<
typename T, 
typename U, std::
size_t N>
   131     for (std::size_t i = 0; i < 
N; ++i) {
   142   template<typename T, typename U, std::size_t N, typename E = typename std::enable_if<std::is_arithmetic<T>::value, 
T>::type>
   147     for (std::size_t i = 0; i < 
N; ++i) {
   159   template<
typename T, 
typename U, std::
size_t N>
   164     for (std::size_t i = 0; i < 
N; ++i) {
   175   template<
typename T, 
typename U, std::
size_t N>
   178     for (std::size_t i = 0; i < 
N; ++i) {
   190   template<typename T, typename U, std::size_t N, typename E = typename std::enable_if<std::is_arithmetic<U>::value, 
U>::type>
   195     for (std::size_t i = 0; i < 
N; ++i) {
   206   template<
typename T, 
typename U, std::
size_t N>
   209     for (std::size_t i = 0; i < 
N; ++i) {
   220   template<typename T, typename U, std::size_t N, typename E = typename std::enable_if<std::is_arithmetic<T>::value, 
T>::type>
   225     for (std::size_t i = 0; i < 
N; ++i) {
   237   template<
typename T, 
typename U, std::
size_t N>
   242     for (std::size_t i = 0; i < 
N; ++i) {
   253   template<
typename T, 
typename U, std::
size_t N>
   256     for (std::size_t i = 0; i < 
N; ++i) {
   267   template<typename T, typename U, std::size_t N, typename E = typename std::enable_if<std::is_arithmetic<U>::value, 
U>::type>
   272     for (std::size_t i = 0; i < 
N; ++i) {
   283   template<
typename T, 
typename U, std::
size_t N>
   286     for (std::size_t i = 0; i < 
N; ++i) {
   297   template<typename T, typename U, std::size_t N, typename E = typename std::enable_if<std::is_arithmetic<T>::value, 
T>::type>
   302     for (std::size_t i = 0; i < 
N; ++i) {
   313   template<
typename T, 
typename U, std::
size_t N>
   318     for (std::size_t i = 0; i < 
N; ++i) {
   329   template<
typename T, 
typename U, std::
size_t N>
   332     for (std::size_t i = 0; i < 
N; ++i) {
   343   template<typename T, typename U, std::size_t N, typename E = typename std::enable_if<std::is_arithmetic<U>::value, 
U>::type>
   348     for (std::size_t i = 0; i < 
N; ++i) {
   359   template<
typename T, 
typename U, std::
size_t N>
   362     for (std::size_t i = 0; i < 
N; ++i) {
   373   template<typename T, typename U, std::size_t N, typename E = typename std::enable_if<std::is_arithmetic<T>::value, 
T>::type>
   378     for (std::size_t i = 0; i < 
N; ++i) {
   389   template<std::
size_t N>
   394     for (std::size_t i = 0; i < 
N; ++i) {
   405   template<std::
size_t N>
   410     for (std::size_t i = 0; i < 
N; ++i) {
   429   template<
typename T, std::
size_t N>
   434     for (std::size_t i = 0; i < 
N; ++i) {
   445   template<
typename T, std::
size_t N>
   450     for (std::size_t i = 0; i < 
N; ++i) {
   461   template<
typename T, std::
size_t N>
   466     for (std::size_t i = 0; i < 
N; ++i) {
   477   template<
typename T, std::
size_t N>
   482     for (std::size_t i = 0; i < 
N; ++i) {
   483       out.
data[i] = std::abs(val.
data[i]);
   494   template<
typename T, std::
size_t N>
   499     for (std::size_t i = 0; i < 
N; ++i) {
   510   template<
typename T, std::
size_t N>
   515     for (std::size_t i = 0; i < 
N; ++i) {
   526   template<
typename T, std::
size_t N>
   531     for (std::size_t i = 0; i < 
N; ++i) {
   542   template<
typename T, std::
size_t N>
   547     for (std::size_t i = 0; i < 
N; ++i) {
   561   template<
typename T, std::
size_t N>
   566     for (std::size_t i = 0; i < 
N; ++i) {
   579   template<
typename T, std::
size_t N>
   584     for (std::size_t i = 0; i < 
N; ++i) {
   595   template<
typename T, 
typename U, std::
size_t N>
   600     for (std::size_t i = 0; i < 
N; ++i) {
   624   template<
typename T, std::
size_t N>
   629     for (std::size_t i = 0; i < 
N; ++i) {
   630       out += std::abs(vec.
data[i]);
   650   template<
typename T, std::
size_t N>
   655     for (std::size_t i = 0; i < 
N; ++i) {
   678   template<
typename T, std::
size_t N>
   681     return std::sqrt(squareLength(vec));
   684 #ifndef DOXYGEN_SHOULD_SKIP_THIS   690     return std::hypot(vec.x, vec.y);
   696     return std::hypot(vec.x, vec.y);
   716   template<
typename T, std::
size_t N>
   719     T out = std::abs(vec.
data[0]);
   721     for (std::size_t i = 1; i < 
N; ++i) {
   722       out = std::max(out, std::abs(vec.
data[i]));
   745   template<
typename T, std::
size_t N>
   748     return manhattanLength(vec) + squareLength(vec);
   764   template<
typename T, std::
size_t N>
   767     return manhattanLength(lhs - rhs);
   783   template<
typename T, std::
size_t N>
   786     return squareLength(lhs - rhs);
   802   template<
typename T, std::
size_t N>
   805     return euclideanLength(lhs - rhs);
   821   template<
typename T, std::
size_t N>
   824     return chebyshevLength(lhs - rhs);
   840   template<
typename T, std::
size_t N>
   843     return naturalLength(lhs - rhs);
   861   template<
typename T, std::
size_t N>
   864     T length = euclideanLength(vec);
   878     return { std::cos(angle), std::sin(angle) };
   891     return std::atan2(vec.
y, vec.
x);
   908     return { -vec.
y, vec.
x };
   927     return dot(a, c) * b - dot(a, b) * c;
   947     return - dot(c, b) * a + dot(c, a) * b;
   970     return lhs.
x * rhs.
y - lhs.
y * rhs.
x;
   986       lhs.
y * rhs.
z - lhs.
z * rhs.
y,
   987       lhs.
z * rhs.
x - lhs.
x * rhs.
z,
   988       lhs.
x * rhs.
y - lhs.
y * rhs.
x   992 #ifndef DOXYGEN_SHOULD_SKIP_THIS   997 #endif // GF_VECTOR_OPS_H Vector< typename std::common_type< T, U >::type, N > operator/(Vector< T, N > lhs, Vector< U, N > rhs)
Component-wise division. 
Definition: VectorOps.h:315
 
Vector< T, N > & operator+=(Vector< T, N > &lhs, U rhs)
Right scalar addition and assignment. 
Definition: VectorOps.h:130
 
Vector< typename std::common_type< T, U >::type, N > operator+(Vector< T, N > lhs, U rhs)
Right scalar addition. 
Definition: VectorOps.h:114
 
T euclideanLength(Vector< T, N > vec)
Euclidean length of a vector. 
Definition: VectorOps.h:680
 
T x
First coordinate in the (x,y) representation. 
Definition: Vector.h:470
 
Vector< typename std::common_type< T, U >::type, N > operator*(Vector< T, N > lhs, Vector< U, N > rhs)
Component-wise multiplication. 
Definition: VectorOps.h:239
 
Vector< typename std::common_type< T, U >::type, N > operator/(T lhs, Vector< U, N > rhs)
Left scalar division. 
Definition: VectorOps.h:375
 
Vector< T, N > clamp(Vector< T, N > val, Vector< T, N > lo, Vector< T, N > hi)
Component-wise clamp function. 
Definition: VectorOps.h:563
 
Vector< bool, N > greaterThan(Vector< T, N > lhs, Vector< T, N > rhs)
Component-wise comparison operator. 
Definition: VectorOps.h:528
 
constexpr Vector< T, 3 > cross(Vector< T, 3 > lhs, Vector< T, 3 > rhs)
Cross product for 3D vectors. 
Definition: VectorOps.h:984
 
Vector< T, 2 > vectorTripleProduct(Vector< T, 2 > a, Vector< T, 2 > b, Vector< T, 2 > c)
Regular vector triple product. 
Definition: VectorOps.h:926
 
Vector< T, N > & operator/=(Vector< T, N > &lhs, U rhs)
Right scalar division and assignment. 
Definition: VectorOps.h:361
 
Vector< typename std::common_type< T, U >::type, N > operator-(Vector< T, N > lhs, U rhs)
Right scalar substraction. 
Definition: VectorOps.h:192
 
Vector< typename std::common_type< T, U >::type, N > operator+(Vector< T, N > lhs, Vector< U, N > rhs)
Component-wise addition. 
Definition: VectorOps.h:84
 
T lerp(T lhs, T rhs, U t)
Linear interpolation function. 
Definition: Math.h:242
 
Vector< bool, N > equals(Vector< T, N > lhs, Vector< T, N > rhs)
Component-wise equality operator. 
Definition: VectorOps.h:496
 
Vector< T, N > normalize(Vector< T, N > vec)
Normalize a vector. 
Definition: VectorOps.h:863
 
Vector< T, N > & operator+=(Vector< T, N > &lhs, Vector< U, N > rhs)
Component-wise addition and assignment. 
Definition: VectorOps.h:100
 
T y
Second coordinate in the (x,y) representation. 
Definition: Vector.h:471
 
T x
First coordinate in the (x,y,z) representation. 
Definition: Vector.h:717
 
constexpr T square(T val)
Square function. 
Definition: Math.h:275
 
float angle(Vector< T, 2 > vec)
Angle of a vector relative to the x-axis. 
Definition: VectorOps.h:890
 
constexpr T clamp(T val, T lo, T hi)
Clamping function. 
Definition: Math.h:260
 
T data[N]
The internal representation of the vector. 
Definition: Vector.h:251
 
T squareDistance(Vector< T, N > lhs, Vector< T, N > rhs)
Square Euclidean distance between two vectors. 
Definition: VectorOps.h:785
 
Vector< bool, N > lessThan(Vector< T, N > lhs, Vector< T, N > rhs)
Component-wise comparison operator. 
Definition: VectorOps.h:512
 
Vector< T, N > select(Vector< bool, N > cond, Vector< T, N > lhs, Vector< T, N > rhs)
Component-wise selection operator. 
Definition: VectorOps.h:544
 
Vector< T, N > min(Vector< T, N > lhs, Vector< T, N > rhs)
Component-wise minimum. 
Definition: VectorOps.h:447
 
Vector< typename std::common_type< T, U >::type, N > operator*(Vector< T, N > lhs, U rhs)
Right scalar multiplication. 
Definition: VectorOps.h:269
 
Vector< typename std::common_type< T, U >::type, N > operator+(T lhs, Vector< U, N > rhs)
Left scalar addition. 
Definition: VectorOps.h:144
 
Vector< T, N > & operator-=(Vector< T, N > &lhs, Vector< U, N > rhs)
Component-wise substraction and assignment. 
Definition: VectorOps.h:177
 
The namespace for gf classes. 
Definition: Action.h:34
 
Vector< T, N > clamp(Vector< T, N > val, T lo, T hi)
Component-wise clamp function. 
Definition: VectorOps.h:581
 
Vector< T, 2 > unit(T angle)
Unit vector in a specified direction. 
Definition: VectorOps.h:877
 
float angle(Direction direction)
Get an angle from a direction. 
 
bool operator==(Vector< T, N > lhs, Vector< T, N > rhs)
Equality operator between two vectors. 
Definition: VectorOps.h:42
 
Vector< bool, N > operator||(Vector< bool, N > lhs, Vector< bool, N > rhs)
Component-wise logical or operator. 
Definition: VectorOps.h:391
 
Vector< typename std::common_type< T, U >::type, N > operator*(T lhs, Vector< U, N > rhs)
Left scalar multiplication. 
Definition: VectorOps.h:299
 
Vector< T, N > & operator-=(Vector< T, N > &lhs, U rhs)
Right scalar substraction and assignment. 
Definition: VectorOps.h:208
 
Vector< T, N > operator-(Vector< T, N > val)
Component-wise unary minus. 
Definition: VectorOps.h:68
 
T manhattanDistance(Vector< T, N > lhs, Vector< T, N > rhs)
Manhattan distance between two vectors. 
Definition: VectorOps.h:766
 
Vector< typename std::common_type< T, U >::type, N > operator/(Vector< T, N > lhs, U rhs)
Right scalar division. 
Definition: VectorOps.h:345
 
A 2D vector. 
Definition: Vector.h:298
 
T y
Second coordinate in the (x,y,z) representation. 
Definition: Vector.h:718
 
T chebyshevLength(Vector< T, N > vec)
Chebyshev length of a vector. 
Definition: VectorOps.h:718
 
T euclideanDistance(Vector< T, N > lhs, Vector< T, N > rhs)
Euclidean distance between two vectors. 
Definition: VectorOps.h:804
 
Vector< T, N > & operator*=(Vector< T, N > &lhs, U rhs)
Right scalar multiplication and assignment. 
Definition: VectorOps.h:285
 
Vector< T, N > lerp(Vector< T, N > lhs, Vector< T, N > rhs, U t)
Component-wise lerp function. 
Definition: VectorOps.h:597
 
T manhattanLength(Vector< T, N > vec)
Manhattan length of a vector. 
Definition: VectorOps.h:626
 
Vector< T, N > max(Vector< T, N > lhs, Vector< T, N > rhs)
Component-wise maximum. 
Definition: VectorOps.h:463
 
Vector< T, N > & operator/=(Vector< T, N > &lhs, Vector< U, N > rhs)
Component-wise division and assignment. 
Definition: VectorOps.h:331
 
Vector< T, 2 > inverseVectorTripleProduct(Vector< T, 2 > a, Vector< T, 2 > b, Vector< T, 2 > c)
Inverse vector triple product. 
Definition: VectorOps.h:946
 
Vector< typename std::common_type< T, U >::type, N > operator-(Vector< T, N > lhs, Vector< U, N > rhs)
Component-wise substraction. 
Definition: VectorOps.h:161
 
Vector< T, N > abs(Vector< T, N > val)
Component-wise absolute value. 
Definition: VectorOps.h:479
 
A 3D vector. 
Definition: Vector.h:530
 
General purpose math vector. 
Definition: Vector.h:60
 
T z
Third coordinate in the (x,y,z) representation. 
Definition: Vector.h:719
 
Vector< typename std::common_type< T, U >::type, N > operator-(T lhs, Vector< U, N > rhs)
Left scalar substraction. 
Definition: VectorOps.h:222
 
constexpr Vector< T, 2 > perp(Vector< T, 2 > vec)
Perpendicular vector. 
Definition: VectorOps.h:907
 
Vector< T, N > & operator*=(Vector< T, N > &lhs, Vector< U, N > rhs)
Component-wise multiplication and assignment. 
Definition: VectorOps.h:255
 
T naturalDistance(Vector< T, N > lhs, Vector< T, N > rhs)
Natural distance between two vectors. 
Definition: VectorOps.h:842
 
T naturalLength(Vector< T, N > vec)
Natural length of a vector. 
Definition: VectorOps.h:747
 
T squareLength(Vector< T, N > vec)
Square Euclidean length of a vector. 
Definition: VectorOps.h:652
 
T dot(Vector< T, N > lhs, Vector< T, N > rhs)
Scalar product. 
Definition: VectorOps.h:431
 
bool operator!=(Vector< T, N > lhs, Vector< T, N > rhs)
Inequality operator between two vectors. 
Definition: VectorOps.h:58
 
constexpr T cross(Vector< T, 2 > lhs, Vector< T, 2 > rhs)
Cross product for 2D vectors. 
Definition: VectorOps.h:969
 
T chebyshevDistance(Vector< T, N > lhs, Vector< T, N > rhs)
Chebyshev distance between two vectors. 
Definition: VectorOps.h:823