parent
ee7b52c8ee
commit
bcd6716592
4 changed files with 0 additions and 1736 deletions
@ -1,179 +0,0 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2007-02-21
|
||||
// Updated : 2007-03-01
|
||||
// Licence : This source is under MIT License
|
||||
// File : glm/gtx/matx.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Dependency:
|
||||
// - GLM core
|
||||
// - GLM_GTX_vecx
|
||||
// - GLM_GTX_matrix_selection
|
||||
// - GLM_GTX_matrix_access
|
||||
// - GLM_GTX_inverse_transpose
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef glm_gtx_matx |
||||
#define glm_gtx_matx |
||||
|
||||
// Dependency:
|
||||
#include "../glm.hpp" |
||||
#include "../gtx/vecx.hpp" |
||||
|
||||
namespace glm{ |
||||
namespace detail{ |
||||
|
||||
template <int N, typename T = float>
|
||||
class _xmatxGTX |
||||
{ |
||||
private: |
||||
// Data
|
||||
_xvecxGTX<N, T> value[N]; |
||||
|
||||
public: |
||||
_xmatxGTX<N, T> _inverse() const; |
||||
|
||||
public: |
||||
typedef T value_type; |
||||
typedef int size_type; |
||||
static const size_type value_size; |
||||
|
||||
// Constructors
|
||||
_xmatxGTX(); |
||||
explicit _xmatxGTX(const T x); |
||||
|
||||
// Accesses
|
||||
_xvecxGTX<N, T>& operator[](int i) {return value[i];} |
||||
const _xvecxGTX<N, T> & operator[](int i) const {return value[i];} |
||||
operator T*() {return &value[0][0];} |
||||
operator const T*() const {return &value[0][0];} |
||||
|
||||
// Unary updatable operators
|
||||
_xmatxGTX<N, T>& operator= (const _xmatxGTX<N, T>& m); |
||||
_xmatxGTX<N, T>& operator+= (const T s); |
||||
_xmatxGTX<N, T>& operator+= (const _xmatxGTX<N, T>& m); |
||||
_xmatxGTX<N, T>& operator-= (const T s); |
||||
_xmatxGTX<N, T>& operator-= (const _xmatxGTX<N, T>& m); |
||||
_xmatxGTX<N, T>& operator*= (const T s); |
||||
_xmatxGTX<N, T>& operator*= (const _xmatxGTX<N, T>& m); |
||||
_xmatxGTX<N, T>& operator/= (const T s); |
||||
_xmatxGTX<N, T>& operator/= (const _xmatxGTX<N, T>& m); |
||||
_xmatxGTX<N, T>& operator++ (); |
||||
_xmatxGTX<N, T>& operator-- (); |
||||
}; |
||||
|
||||
// Binary operators
|
||||
template <int N, typename T> |
||||
_xmatxGTX<N, T> operator+ (const _xmatxGTX<N, T>& m, const T s); |
||||
|
||||
template <int N, typename T>
|
||||
_xmatxGTX<N, T> operator+ (const T s, const _xmatxGTX<N, T>& m); |
||||
|
||||
template <int N, typename T> |
||||
_xvecxGTX<N, T> operator+ (const _xmatxGTX<N, T>& m, const _xvecxGTX<N, T>& v); |
||||
|
||||
template <int N, typename T> |
||||
_xvecxGTX<N, T> operator+ (const _xvecxGTX<N, T>& v, const _xmatxGTX<N, T>& m); |
||||
|
||||
template <int N, typename T>
|
||||
_xmatxGTX<N, T> operator+ (const _xmatxGTX<N, T>& m1, const _xmatxGTX<N, T>& m2); |
||||
|
||||
template <int N, typename T>
|
||||
_xmatxGTX<N, T> operator- (const _xmatxGTX<N, T>& m, const T s); |
||||
|
||||
template <int N, typename T>
|
||||
_xmatxGTX<N, T> operator- (const T s, const _xmatxGTX<N, T>& m); |
||||
|
||||
template <int N, typename T>
|
||||
_xvecxGTX<N, T> operator- (const _xmatxGTX<N, T>& m, const _xvecxGTX<N, T>& v); |
||||
|
||||
template <int N, typename T>
|
||||
_xvecxGTX<N, T> operator- (const _xvecxGTX<N, T>& v, const _xmatxGTX<N, T>& m); |
||||
|
||||
template <int N, typename T> |
||||
_xmatxGTX<N, T> operator- (const _xmatxGTX<N, T>& m1, const _xmatxGTX<N, T>& m2); |
||||
|
||||
template <int N, typename T>
|
||||
_xmatxGTX<N, T> operator* (const _xmatxGTX<N, T>& m, const T s); |
||||
|
||||
template <int N, typename T> |
||||
_xmatxGTX<N, T> operator* (const T s, const _xmatxGTX<N, T>& m); |
||||
|
||||
template <int N, typename T> |
||||
_xvecxGTX<N, T> operator* (const _xmatxGTX<N, T>& m, const _xvecxGTX<N, T>& v); |
||||
|
||||
template <int N, typename T> |
||||
_xvecxGTX<N, T> operator* (const _xvecxGTX<N, T>& v, const _xmatxGTX<N, T>& m); |
||||
|
||||
template <int N, typename T> |
||||
_xmatxGTX<N, T> operator* (const _xmatxGTX<N, T>& m1, const _xmatxGTX<N, T>& m2); |
||||
|
||||
template <int N, typename T> |
||||
_xmatxGTX<N, T> operator/ (const _xmatxGTX<N, T>& m, const T s); |
||||
|
||||
template <int N, typename T> |
||||
_xmatxGTX<N, T> operator/ (const T s, const _xmatxGTX<N, T>& m); |
||||
|
||||
template <int N, typename T> |
||||
_xvecxGTX<N, T> operator/ (const _xmatxGTX<N, T>& m, const _xvecxGTX<N, T>& v); |
||||
|
||||
template <int N, typename T> |
||||
_xvecxGTX<N, T> operator/ (const _xvecxGTX<N, T>& v, const _xmatxGTX<N, T>& m); |
||||
|
||||
template <int N, typename T> |
||||
_xmatxGTX<N, T> operator/ (const _xmatxGTX<N, T>& m1, const _xmatxGTX<N, T>& m2); |
||||
|
||||
// Unary constant operators
|
||||
template <int N, typename T> |
||||
const _xmatxGTX<N, T> operator- (const _xmatxGTX<N, T>& m); |
||||
|
||||
template <int N, typename T> |
||||
const _xmatxGTX<N, T> operator-- (const _xmatxGTX<N, T>& m, int); |
||||
|
||||
template <int N, typename T> |
||||
const _xmatxGTX<N, T> operator++ (const _xmatxGTX<N, T>& m, int); |
||||
|
||||
}//namespace detail
|
||||
|
||||
// Extension functions
|
||||
template <int N, typename T> detail::_xmatxGTX<N, T> matrixCompMultGTX(const detail::_xmatxGTX<N, T>& x, const detail::_xmatxGTX<N, T>& y); |
||||
template <int N, typename T> detail::_xmatxGTX<N, T> outerProductGTX(const detail::_xvecxGTX<N, T>& c, const detail::_xvecxGTX<N, T>& r); |
||||
template <int N, typename T> detail::_xmatxGTX<N, T> transposeGTX(const detail::_xmatxGTX<N, T>& x); |
||||
|
||||
template <int N, typename T> T determinantGTX(const detail::_xmatxGTX<N, T>& m); |
||||
template <int N, typename T> detail::_xmatxGTX<N, T> inverseTransposeGTX(const detail::_xmatxGTX<N, T> & m); |
||||
|
||||
template <int N, typename T> void columnGTX(detail::_xmatxGTX<N, T>& m, int ColIndex, const detail::_xvecxGTX<N, T>& v); |
||||
template <int N, typename T> void rowGTX(detail::_xmatxGTX<N, T>& m, int RowIndex, const detail::_xvecxGTX<N, T>& v); |
||||
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> columnGTX(const detail::_xmatxGTX<N, T>& m, int ColIndex); |
||||
template <int N, typename T> detail::_xvecxGTX<N, T> rowGTX(const detail::_xmatxGTX<N, T>& m, int RowIndex); |
||||
|
||||
namespace gtx |
||||
{ |
||||
//! GLM_GTX_matx extension: - Work in progress - NxN matrix types.
|
||||
namespace matx |
||||
{ |
||||
// Matrix Functions
|
||||
template <int N, typename T> inline detail::_xmatxGTX<N, T> matrixCompMult(const detail::_xmatxGTX<N, T>& x, const detail::_xmatxGTX<N, T>& y){return matrixCompMult(x, y);} |
||||
template <int N, typename T> inline detail::_xmatxGTX<N, T> outerProduct(const detail::_xvecxGTX<N, T>& c, const detail::_xvecxGTX<N, T>& r){return outerProductGTX(c, r);} |
||||
template <int N, typename T> inline detail::_xmatxGTX<N, T> transpose(const detail::_xmatxGTX<N, T>& x){return transposeGTX(x);} |
||||
|
||||
template <int N, typename T> inline T determinant(const detail::_xmatxGTX<N, T>& m){return determinantGTX(m);} |
||||
template <int N, typename T> inline detail::_xmatxGTX<N, T> inverseTranspose(const detail::_xmatxGTX<N, T>& m){return inverseTransposeGTX(m);} |
||||
|
||||
template <int N, typename T> inline void column(detail::_xmatxGTX<N, T>& m, int ColIndex, const detail::_xvecxGTX<N, T>& v){setColumnGTX(m, v);} |
||||
template <int N, typename T> inline void row(detail::_xmatxGTX<N, T>& m, int RowIndex, const detail::_xvecxGTX<N, T>& v){setRowGTX(m, v);} |
||||
|
||||
template <int N, typename T> inline detail::_xvecxGTX<N, T> column(const detail::_xmatxGTX<N, T>& m, int ColIndex){return column(m, ColIndex);} |
||||
template <int N, typename T> inline detail::_xvecxGTX<N, T> row(const detail::_xmatxGTX<N, T>& m, int RowIndex){return row(m, RowIndex);} |
||||
} |
||||
} |
||||
} |
||||
|
||||
#include "matx.inl" |
||||
|
||||
namespace glm{using namespace gtx::matx;} |
||||
|
||||
#endif//glm_gtx_matx
|
@ -1,479 +0,0 @@ |
||||
/////////////////////////////////////////////////////////////////////////////////////////////////// |
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) |
||||
/////////////////////////////////////////////////////////////////////////////////////////////////// |
||||
// Created : 2007-02-21 |
||||
// Updated : 2007-02-21 |
||||
// Licence : This source is under MIT License |
||||
// File : glm/gtx/matx.inl |
||||
/////////////////////////////////////////////////////////////////////////////////////////////////// |
||||
|
||||
#include <cassert> |
||||
#include <algorithm> |
||||
|
||||
namespace glm{ |
||||
namespace detail{ |
||||
|
||||
template <int N, typename T> const typename _xmatxGTX<N, T>::size_type _xmatxGTX<N, T>::value_size = N; |
||||
|
||||
////////////////////////////////////////////////////////////// |
||||
// _xmatxGTX constructors |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T>::_xmatxGTX() |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->value[i][i] = T(0); |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T>::_xmatxGTX(const T f) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->value[i][i] = f; |
||||
} |
||||
|
||||
////////////////////////////////////////////////////////////// |
||||
// _xmatxGTX operators |
||||
|
||||
// This function shouldn't required but it seems that VC7.1 have an optimisation bug if this operator wasn't declared |
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T>& _xmatxGTX<N, T>::operator= (const _xmatxGTX<N, T>& m) |
||||
{ |
||||
//memcpy could be faster |
||||
//memcpy(&this->value, &m.value, 16 * sizeof(T)); |
||||
for(int i = 0; i < N; ++i) |
||||
this->value[i] = m[i]; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T>& _xmatxGTX<N, T>::operator+= (const T s) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->value[i] += s; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T>& _xmatxGTX<N, T>::operator+= (const _xmatxGTX<N, T>& m) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->value[i] += m[i]; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T>& _xmatxGTX<N, T>::operator-= (const T s) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->value[i] -= s; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T>& _xmatxGTX<N, T>::operator-= (const _xmatxGTX<N, T>& m) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->value[i] -= m[i]; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T>& _xmatxGTX<N, T>::operator*= (const T s) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->value[i] *= s; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T>& _xmatxGTX<N, T>::operator*= (const _xmatxGTX<N, T>& m) |
||||
{ |
||||
return (*this = *this * m); |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T>& _xmatxGTX<N, T>::operator/= (const T s) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->value[i] /= s; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T>& _xmatxGTX<N, T>::operator/= (const _xmatxGTX<N, T>& m) |
||||
{ |
||||
return (*this = *this / m); |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T>& _xmatxGTX<N, T>::operator-- () |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
--this->value[i]; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T>& _xmatxGTX<N, T>::operator++ () |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
++this->value[i]; |
||||
return *this; |
||||
} |
||||
|
||||
// Private functions |
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T> _xmatxGTX<N, T>::_inverse() const |
||||
{ |
||||
_xmatxGTX<N, T> Result = *this; |
||||
|
||||
int ColIndex[N]; |
||||
int RowIndex[N]; |
||||
bool Pivoted[N]; |
||||
memset(ColIndex, 0, N * sizeof(int)); |
||||
memset(RowIndex, 0, N * sizeof(int)); |
||||
memset(Pivoted, 0, N * sizeof(bool)); |
||||
|
||||
int iRow = 0, iCol = 0; |
||||
|
||||
// elimination by full pivoting |
||||
for(int i0 = 0; i0 < N; i0++) |
||||
{ |
||||
// search matrix (excluding pivoted rows) for maximum absolute entry |
||||
T fMax = T(0); |
||||
for(int i1 = 0; i1 < N; i1++) |
||||
{ |
||||
if(Pivoted[i1]) |
||||
continue; |
||||
|
||||
for(int i2 = 0; i2 < N; i2++) |
||||
{ |
||||
if(Pivoted[i2]) |
||||
continue; |
||||
|
||||
T Abs = abs(Result[i1][i2]); |
||||
if(Abs > fMax) |
||||
{ |
||||
fMax = Abs; |
||||
iRow = i1; |
||||
iCol = i2; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if(fMax == T(0)) |
||||
{ |
||||
return _xmatxGTX<N, T>(1.0f); // Error |
||||
} |
||||
|
||||
Pivoted[iCol] = true; |
||||
|
||||
// swap rows so that A[iCol][iCol] contains the pivot entry |
||||
if(iRow != iCol) |
||||
{ |
||||
_xvecxGTX<N, T> Row = rowGTX(Result, iRow); |
||||
_xvecxGTX<N, T> Col = rowGTX(Result, iCol); |
||||
rowGTX(Result, iRow, Col); |
||||
rowGTX(Result, iCol, Row); |
||||
} |
||||
|
||||
// keep track of the permutations of the rows |
||||
RowIndex[i0] = iRow; |
||||
ColIndex[i0] = iCol; |
||||
|
||||
// scale the row so that the pivot entry is 1 |
||||
T fInv = T(1) / Result[iCol][iCol]; |
||||
Result[iCol][iCol] = T(1); |
||||
for(int i2 = 0; i2 < N; i2++) |
||||
Result[iCol][i2] *= fInv; |
||||
|
||||
// zero out the pivot column locations in the other rows |
||||
for(int i1 = 0; i1 < N; ++i1) |
||||
{ |
||||
if(i1 == iCol) |
||||
continue; |
||||
|
||||
T Tmp = Result[i1][iCol]; |
||||
Result[i1][iCol] = T(0); |
||||
for(int i2 = 0; i2 < N; i2++) |
||||
Result[i1][i2] -= Result[iCol][i2] * Tmp; |
||||
} |
||||
} |
||||
|
||||
// reorder rows so that A[][] stores the inverse of the original matrix |
||||
for(int i1 = N-1; i1 >= 0; --i1) |
||||
{ |
||||
if(RowIndex[i1] == ColIndex[i1]) |
||||
continue; |
||||
for(int i2 = 0; i2 < N; ++i2) |
||||
std::swap(Result[i2][RowIndex[i1]], Result[i2][ColIndex[i1]]); |
||||
} |
||||
|
||||
return Result; |
||||
} |
||||
|
||||
// Binary operators |
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T> operator+ (const _xmatxGTX<N, T>& m, const T s) |
||||
{ |
||||
_xmatxGTX<N, T> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = m[i] + s; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T> operator+ (const T s, const _xmatxGTX<N, T>& m) |
||||
{ |
||||
_xmatxGTX<N, T> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = s + m[i]; |
||||
return result; |
||||
} |
||||
/* |
||||
template <int N, typename T> |
||||
inline tvec4<T> operator+ (const _xmatxGTX<N, T>& m, const tvec4<T>& v) |
||||
{ |
||||
|
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline tvec4<T> operator+ (const tvec4<T>& v, const _xmatxGTX<N, T>& m) |
||||
{ |
||||
|
||||
} |
||||
*/ |
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T> operator+ (const _xmatxGTX<N, T>& m1, const _xmatxGTX<N, T>& m2) |
||||
{ |
||||
_xmatxGTX<N, T> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = m1[i] + m2[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T> operator- (const _xmatxGTX<N, T>& m, const T s) |
||||
{ |
||||
_xmatxGTX<N, T> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = m[i] - s; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T> operator- (const T s, const _xmatxGTX<N, T>& m) |
||||
{ |
||||
_xmatxGTX<N, T> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = s - m[i]; |
||||
return result; |
||||
} |
||||
/* |
||||
template <int N, typename T> |
||||
inline tvec4<T> operator- (const _xmatxGTX<N, T>& m, const tvec4<T>& v) |
||||
{ |
||||
|
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline tvec4<T> operator- (const tvec4<T>& v, const _xmatxGTX<N, T>& m) |
||||
{ |
||||
|
||||
} |
||||
*/ |
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T> operator- (const _xmatxGTX<N, T>& m1, const _xmatxGTX<N, T>& m2) |
||||
{ |
||||
_xmatxGTX<N, T> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = m1[i] - m2[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T> operator* (const _xmatxGTX<N, T>& m, const T s) |
||||
{ |
||||
_xmatxGTX<N, T> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = m[i] * s; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T> operator* (const T s, const _xmatxGTX<N, T>& m) |
||||
{ |
||||
_xmatxGTX<N, T> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = s * m[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T> operator* (const _xmatxGTX<N, T>& m, const _xvecxGTX<N, T>& v) |
||||
{ |
||||
_xvecxGTX<N, T> result(T(0)); |
||||
for(int j = 0; j < N; ++j) |
||||
for(int i = 0; i < N; ++i) |
||||
result[j] += m[i][j] * v[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T> operator* (const _xvecxGTX<N, T>& v, const _xmatxGTX<N, T>& m) |
||||
{ |
||||
_xvecxGTX<N, T> result(T(0)); |
||||
for(int j = 0; j < N; ++j) |
||||
for(int i = 0; i < N; ++i) |
||||
result[j] += m[j][i] * v[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T> operator* (const _xmatxGTX<N, T>& m1, const _xmatxGTX<N, T>& m2) |
||||
{ |
||||
_xmatxGTX<N, T> Result(T(0)); |
||||
for(int k = 0; k < N; ++k) |
||||
for(int j = 0; j < N; ++j) |
||||
for(int i = 0; i < N; ++i) |
||||
Result[k][j] += m1[i][j] * m2[k][i]; |
||||
return Result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T> operator/ (const _xmatxGTX<N, T>& m, const T s) |
||||
{ |
||||
_xmatxGTX<N, T> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = m[i] / s; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T> operator/ (const T s, const _xmatxGTX<N, T>& m) |
||||
{ |
||||
_xmatxGTX<N, T> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = s / m[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T> operator/ (const _xmatxGTX<N, T>& m, const _xvecxGTX<N, T>& v) |
||||
{ |
||||
return m._inverse() * v; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T> operator/ (const _xvecxGTX<N, T>& v, const _xmatxGTX<N, T>& m) |
||||
{ |
||||
return v * m._inverse(); |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xmatxGTX<N, T> operator/ (const _xmatxGTX<N, T>& m1, const _xmatxGTX<N, T>& m2) |
||||
{ |
||||
return m1 * m2._inverse(); |
||||
} |
||||
|
||||
// Unary constant operators |
||||
template <int N, typename T> |
||||
inline const _xmatxGTX<N, T> operator- (const _xmatxGTX<N, T>& m) |
||||
{ |
||||
_xmatxGTX<N, T> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = -m[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline const _xmatxGTX<N, T> operator++ (const _xmatxGTX<N, T>& m, int) |
||||
{ |
||||
_xmatxGTX<N, T> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = m[i] + T(1); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline const _xmatxGTX<N, T> operator-- (const _xmatxGTX<N, T>& m, int) |
||||
{ |
||||
_xmatxGTX<N, T> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = m[i] - T(1); |
||||
return result; |
||||
} |
||||
}//namespace detail |
||||
|
||||
// Matrix Functions |
||||
template <int N, typename T> |
||||
inline detail::_xmatxGTX<N, T> matrixCompMultGTX(const detail::_xmatxGTX<N, T>& x, const detail::_xmatxGTX<N, T>& y) |
||||
{ |
||||
detail::_xmatxGTX<N, T> result; |
||||
for(int j = 0; j < N; ++j) |
||||
for(int i = 0; i < N; ++i) |
||||
result[j][i] = x[j][i] * y[j][i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xmatxGTX<N, T> outerProductGTX(const detail::_xvecxGTX<N, T>& c, const detail::_xvecxGTX<N, T>& r) |
||||
{ |
||||
detail::_xmatxGTX<N, T> result; |
||||
for(int j = 0; j < N; ++j) |
||||
for(int i = 0; i < N; ++i) |
||||
result[j][i] = c[i] * r[j]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xmatxGTX<N, T> transposeGTX(const detail::_xmatxGTX<N, T>& m) |
||||
{ |
||||
detail::_xmatxGTX<N, T> result; |
||||
for(int j = 0; j < N; ++j) |
||||
for(int i = 0; i < N; ++i) |
||||
result[j][i] = m[i][j]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline T determinantGTX(const detail::_xmatxGTX<N, T>& m) |
||||
{ |
||||
|
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xmatxGTX<N, T> inverseTransposeGTX(const detail::_xmatxGTX<N, T>& m) |
||||
{ |
||||
|
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline void columnGTX(detail::_xmatxGTX<N, T>& m, int ColIndex, const detail::_xvecxGTX<N, T>& v) |
||||
{ |
||||
m[ColIndex] = v; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline void rowGTX(detail::_xmatxGTX<N, T>& m, int RowIndex, const detail::_xvecxGTX<N, T>& v) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
m[i][RowIndex] = v[i]; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> columnGTX(const detail::_xmatxGTX<N, T>& m, int ColIndex) |
||||
{ |
||||
return m[ColIndex]; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> rowGTX(const detail::_xmatxGTX<N, T>& m, int RowIndex) |
||||
{ |
||||
detail::_xvecxGTX<N, T> v; |
||||
for(int i = 0; i < N; ++i) |
||||
v[i] = m[i][RowIndex]; |
||||
return v; |
||||
} |
||||
} //namespace glm |
@ -1,215 +0,0 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2007-02-21
|
||||
// Updated : 2007-02-21
|
||||
// Licence : This source is under MIT License
|
||||
// File : glm/gtx/vecx.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Dependency:
|
||||
// - GLM core
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef glm_gtx_vecx |
||||
#define glm_gtx_vecx |
||||
|
||||
namespace glm{ |
||||
namespace detail{ |
||||
|
||||
template <int N> |
||||
class _bvecxGTX |
||||
{ |
||||
private: |
||||
bool data[N]; |
||||
|
||||
public: |
||||
typedef bool value_type; |
||||
typedef int size_type; |
||||
static const size_type value_size; |
||||
static const size_type col_size; |
||||
static const size_type row_size; |
||||
|
||||
// Common constructors
|
||||
_bvecxGTX(); |
||||
_bvecxGTX(const _bvecxGTX& v); |
||||
|
||||
// Accesses
|
||||
bool& operator[](int i); |
||||
bool operator[](int i) const; |
||||
operator bool*(); |
||||
operator const bool*() const; |
||||
|
||||
// Bool constructors
|
||||
explicit _bvecxGTX(const bool a); |
||||
|
||||
// Operators
|
||||
_bvecxGTX<N>& operator=(const _bvecxGTX<N>& v); |
||||
_bvecxGTX<N> operator! () const; |
||||
}; |
||||
|
||||
template <int N, typename T = float> |
||||
class _xvecxGTX |
||||
{ |
||||
private: |
||||
T data[N]; |
||||
|
||||
public: |
||||
typedef T value_type; |
||||
typedef int size_type; |
||||
static const size_type value_size; |
||||
|
||||
// Common constructors
|
||||
_xvecxGTX(); |
||||
_xvecxGTX(const _xvecxGTX<N, T>& v); |
||||
|
||||
// Accesses
|
||||
T& operator[](int i); |
||||
T operator[](int i) const; |
||||
operator T*(); |
||||
operator const T*() const; |
||||
|
||||
// T constructors
|
||||
explicit _xvecxGTX(const T x); |
||||
|
||||
// Unary updatable operators
|
||||
_xvecxGTX<N, T>& operator= (const _xvecxGTX<N, T>& v); |
||||
_xvecxGTX<N, T>& operator+=(const T s); |
||||
_xvecxGTX<N, T>& operator+=(const _xvecxGTX<N, T>& v); |
||||
_xvecxGTX<N, T>& operator-=(const T s); |
||||
_xvecxGTX<N, T>& operator-=(const _xvecxGTX<N, T>& v); |
||||
_xvecxGTX<N, T>& operator*=(const T s); |
||||
_xvecxGTX<N, T>& operator*=(const _xvecxGTX<N, T>& v); |
||||
_xvecxGTX<N, T>& operator/=(const T s); |
||||
_xvecxGTX<N, T>& operator/=(const _xvecxGTX<N, T>& v); |
||||
_xvecxGTX<N, T>& operator++(); |
||||
_xvecxGTX<N, T>& operator--(); |
||||
}; |
||||
|
||||
// Binary operators
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> operator+ (const detail::_xvecxGTX<N, T>& v, const T s); |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> operator+ (const T s, const detail::_xvecxGTX<N, T>& v); |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> operator+ (const detail::_xvecxGTX<N, T>& v1, const detail::_xvecxGTX<N, T>& v2); |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> operator- (const detail::_xvecxGTX<N, T>& v, const T s); |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> operator- (const T s, const detail::_xvecxGTX<N, T>& v); |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> operator- (const detail::_xvecxGTX<N, T>& v1, const detail::_xvecxGTX<N, T>& v2); |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> operator* (const detail::_xvecxGTX<N, T>& v, const T s); |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> operator* (const T s, const detail::_xvecxGTX<N, T>& v); |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> operator* (const detail::_xvecxGTX<N, T>& v1, const detail::_xvecxGTX<N, T>& v2); |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> operator/ (const detail::_xvecxGTX<N, T>& v, const T s); |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> operator/ (const T s, const detail::_xvecxGTX<N, T>& v); |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> operator/ (const detail::_xvecxGTX<N, T>& v1, const detail::_xvecxGTX<N, T>& v2); |
||||
|
||||
// Unary constant operators
|
||||
template <int N, typename T> |
||||
const detail::_xvecxGTX<N, T> operator- (const detail::_xvecxGTX<N, T>& v); |
||||
|
||||
template <int N, typename T> |
||||
const detail::_xvecxGTX<N, T> operator-- (const detail::_xvecxGTX<N, T>& v, int); |
||||
|
||||
template <int N, typename T> |
||||
const detail::_xvecxGTX<N, T> operator++ (const detail::_xvecxGTX<N, T>& v, int); |
||||
|
||||
}//namespace detail
|
||||
|
||||
namespace gtx |
||||
{ |
||||
//! GLM_GTX_vecx extension: - Work in progress - Add custom size vectors
|
||||
namespace vecx |
||||
{ |
||||
template<typename T, int N> |
||||
struct vec |
||||
{ |
||||
typedef detail::_xvecxGTX<N, T> type; |
||||
}; |
||||
|
||||
// Trigonometric Functions
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> radiansGTX(const detail::_xvecxGTX<N, T>& degrees); //< \brief Converts degrees to radians and returns the result. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> degreesGTX(const detail::_xvecxGTX<N, T>& radians); //< \brief Converts radians to degrees and returns the result. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> sinGTX(const detail::_xvecxGTX<N, T>& angle); //< \brief The standard trigonometric sine function. The values returned by this function will range from [-1, 1]. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> cosGTX(const detail::_xvecxGTX<N, T>& angle); //< \brief The standard trigonometric cosine function. The values returned by this function will range from [-1, 1]. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> tanGTX(const detail::_xvecxGTX<N, T>& angle); //< \brief The standard trigonometric tangent function. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> asinGTX(const detail::_xvecxGTX<N, T>& x); //< \brief Arc sine. Returns an angle whose sine is x. The range of values returned by this function is [-PI/2, PI/2]. Results are undefined if |x| > 1. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> acosGTX(const detail::_xvecxGTX<N, T>& x); //< \brief Arc cosine. Returns an angle whose sine is x. The range of values returned by this function is [0, PI]. Results are undefined if |x| > 1. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> atanGTX(const detail::_xvecxGTX<N, T>& y, const detail::_xvecxGTX<N, T>& x); //< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> atanGTX(const detail::_xvecxGTX<N, T>& y_over_x); //< \brief Arc tangent. Returns an angle whose tangent is y_over_x. The range of values returned by this function is [-PI/2, PI/2]. (From GLM_GTX_vecx extension)
|
||||
|
||||
// Exponential Functions
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> powGTX(const detail::_xvecxGTX<N, T>& x, const detail::_xvecxGTX<N, T>& y); //< \brief Returns x raised to the y power. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> expGTX(const detail::_xvecxGTX<N, T>& x); //< \brief Returns the natural exponentiation of x, i.e., e^x. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> logGTX(const detail::_xvecxGTX<N, T>& x); //< \brief Returns the natural logarithm of x, i.e., returns the value y which satisfies the equation x = e^y. Results are undefined if x <= 0. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> exp2GTX(const detail::_xvecxGTX<N, T>& x); //< \brief Returns 2 raised to the x power. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> log2GTX(const detail::_xvecxGTX<N, T>& x); //< \brief Returns the base 2 log of x, i.e., returns the value y, which satisfies the equation x = 2 ^ y. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> sqrtGTX(const detail::_xvecxGTX<N, T>& x); //< \brief Returns the positive square root of x. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> inversesqrtGTX(const detail::_xvecxGTX<N, T>& x); //< \brief Returns the reciprocal of the positive square root of x. (From GLM_GTX_vecx extension)
|
||||
|
||||
// Common Functions
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> absGTX(const detail::_xvecxGTX<N, T>& x); //< \brief Returns x if x >= 0; otherwise, it returns -x. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> floorGTX(const detail::_xvecxGTX<N, T>& x); //< \brief Returns a value equal to the nearest integer that is less then or equal to x. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> ceilGTX(const detail::_xvecxGTX<N, T>& x); //< \brief Returns a value equal to the nearest integer that is greater than or equal to x. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> fractGTX(const detail::_xvecxGTX<N, T>& x); //< \brief Return x - floor(x). (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> modGTX(const detail::_xvecxGTX<N, T>& x, T y); //< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> modGTX(const detail::_xvecxGTX<N, T>& x, const detail::_xvecxGTX<N, T>& y); //< \brief Modulus. Returns x - y * floor(x / y) for each component in x using the corresponding component of y. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> minGTX(const detail::_xvecxGTX<N, T>& x, T y); //< \brief Returns y if y < x; otherwise, it returns x. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> minGTX(const detail::_xvecxGTX<N, T>& x, const detail::_xvecxGTX<N, T>& y); //< \brief Returns minimum of each component of x compared with the floating-point value y. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> maxGTX(const detail::_xvecxGTX<N, T>& x, T y); //< \brief Returns y if x < y; otherwise, it returns x. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> maxGTX(const detail::_xvecxGTX<N, T>& x, const detail::_xvecxGTX<N, T>& y); //< \brief Returns maximum of each component of x compared with the floating-point value y. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> clampGTX(const detail::_xvecxGTX<N, T>& x, T minVal, T maxVal); //< \brief Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> clampGTX(const detail::_xvecxGTX<N, T>& x, const detail::_xvecxGTX<N, T>& minVal, const detail::_xvecxGTX<N, T>& maxVal); //< \brief Returns the component-wise result of min(max(x, minVal), maxVal). (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> stepGTX(T edge, const detail::_xvecxGTX<N, T>& x); //< \brief Returns 0.0 if x <= edge; otherwise, it returns 1.0. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> stepGTX(const detail::_xvecxGTX<N, T>& edge, const detail::_xvecxGTX<N, T>& x); //< \brief Returns 0.0 if x <= edge; otherwise, it returns 1.0. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> smoothstepGTX(T edge0, T edge1, const detail::_xvecxGTX<N, T>& x); //< \brief Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x, edge1. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> smoothstepGTX(const detail::_xvecxGTX<N, T>& edge0, const detail::_xvecxGTX<N, T>& edge1, const detail::_xvecxGTX<N, T>& x);//< \brief Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x, edge1. (From GLM_GTX_vecx extension)
|
||||
|
||||
// Geometric Functions
|
||||
template <int N, typename T> T lengthGTX(const detail::_xvecxGTX<N, T>& x); //< \brief Returns the length of x, i.e., sqrt(x * x). (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> T distanceGTX(const detail::_xvecxGTX<N, T>& p0, const detail::_xvecxGTX<N, T>& p1); //< \brief Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> T dotGTX(const detail::_xvecxGTX<N, T>& x, const detail::_xvecxGTX<N, T>& y); //< \brief Returns the dot product of x and y, i.e., result = x[0] * y[0] + x[1] * y[1]. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> normalizeGTX(const detail::_xvecxGTX<N, T>& x); //< \brief Returns a vector in the same direction as x but with length of 1. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> faceforwardGTX(const detail::_xvecxGTX<N, T>& Norm, const detail::_xvecxGTX<N, T>& I, const detail::_xvecxGTX<N, T>& Nref); //< \brief If dot(Nref, I) < 0.0, return N, otherwise, return -N. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> reflectGTX(const detail::_xvecxGTX<N, T>& I, const detail::_xvecxGTX<N, T>& N); //< \brief For the incident vector I and surface orientation N, returns the reflection direction : result = I - 2.0 * dot(N, I) * N. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_xvecxGTX<N, T> refractGTX(const detail::_xvecxGTX<N, T>& I, const detail::_xvecxGTX<N, T>& N, T eta); //< \brief For the incident vector I and surface normal N, and the ratio of indices of refraction eta, return the refraction vector. (From GLM_GTX_vecx extension)
|
||||
|
||||
// Vector Relational Functions
|
||||
template <int N, typename T> detail::_bvecxGTX<N> lessThanGTX(const detail::_xvecxGTX<N, T>& x, const detail::_xvecxGTX<N, T>& y); //< \brief Returns the component-wise compare of x < y. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_bvecxGTX<N> lessThanEqualGTX(const detail::_xvecxGTX<N, T>& x, const detail::_xvecxGTX<N, T>& y); //< \brief Returns the component-wise compare of x <= y. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_bvecxGTX<N> greaterThanGTX(const detail::_xvecxGTX<N, T>& x, const detail::_xvecxGTX<N, T>& y); //< \brief Returns the component-wise compare of x > y. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_bvecxGTX<N> greaterThanEqualGTX(const detail::_xvecxGTX<N, T>& x, const detail::_xvecxGTX<N, T>& y); //< \brief Returns the component-wise compare of x >= y. (From GLM_GTX_vecx extension)
|
||||
template <int N> detail::_bvecxGTX<N> equalGTX(const detail::_bvecxGTX<N>& x, const detail::_bvecxGTX<N>& y); //< \brief Returns the component-wise compare of x == y. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_bvecxGTX<N> equalGTX(const detail::_xvecxGTX<N, T>& x, const detail::_xvecxGTX<N, T>& y); //< \brief Returns the component-wise compare of x == y. (From GLM_GTX_vecx extension)
|
||||
template <int N> detail::_bvecxGTX<N> notEqualGTX(const detail::_bvecxGTX<N>& x, const detail::_bvecxGTX<N>& y); //< \brief Returns the component-wise compare of x != y. (From GLM_GTX_vecx extension)
|
||||
template <int N, typename T> detail::_bvecxGTX<N> notEqualGTX(const detail::_xvecxGTX<N, T>& x, const detail::_xvecxGTX<N, T>& y); //< \brief Returns the component-wise compare of x != y. (From GLM_GTX_vecx extension)
|
||||
template <int N> bool anyGTX(const detail::_bvecxGTX<N>& x); //< \brief Returns true if any component of x is true. (From GLM_GTX_vecx extension)
|
||||
template <int N> bool allGTX(const detail::_bvecxGTX<N>& x); //< \brief Returns true if all component of x is true. (From GLM_GTX_vecx extension)
|
||||
template <int N> detail::_bvecxGTX<N> notGTX(const detail::_bvecxGTX<N>& v); //< \brief Returns the component-wise logical complement of x. (From GLM_GTX_vecx extension)
|
||||
} |
||||
} |
||||
} |
||||
|
||||
#include "vecx.inl" |
||||
|
||||
namespace glm{using namespace gtx::vecx;} |
||||
|
||||
#endif//glm_gtx_vecx
|
@ -1,863 +0,0 @@ |
||||
/////////////////////////////////////////////////////////////////////////////////////////////////// |
||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) |
||||
/////////////////////////////////////////////////////////////////////////////////////////////////// |
||||
// Created : 2007-02-21 |
||||
// Updated : 2007-02-21 |
||||
// Licence : This source is under MIT License |
||||
// File : glm/gtx/vecx.inl |
||||
/////////////////////////////////////////////////////////////////////////////////////////////////// |
||||
|
||||
#include <cassert> |
||||
|
||||
namespace glm |
||||
{ |
||||
namespace detail{ |
||||
|
||||
template <int N> const typename _bvecxGTX<N>::size_type _bvecxGTX<N>::value_size = N; |
||||
|
||||
// Bool constructors |
||||
template <int N> |
||||
inline _bvecxGTX<N>::_bvecxGTX() |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] = false; |
||||
} |
||||
|
||||
template <int N> |
||||
inline _bvecxGTX<N>::_bvecxGTX(const _bvecxGTX<N>& v) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] = v[i]; |
||||
} |
||||
|
||||
template <int N> |
||||
inline _bvecxGTX<N>::_bvecxGTX(const bool s) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] = s; |
||||
} |
||||
|
||||
// Accesses |
||||
template <int N> |
||||
inline bool& _bvecxGTX<N>::operator[](int i) |
||||
{ |
||||
assert(i >= 0 && i < N); |
||||
return this->data[i]; |
||||
} |
||||
|
||||
template <int N> |
||||
inline bool _bvecxGTX<N>::operator[](int i) const |
||||
{ |
||||
assert(i >= 0 && i < N); |
||||
return this->data[i]; |
||||
} |
||||
|
||||
template <int N> |
||||
inline _bvecxGTX<N>::operator bool*() |
||||
{ |
||||
return data; |
||||
} |
||||
|
||||
template <int N> |
||||
inline _bvecxGTX<N>::operator const bool*() const |
||||
{ |
||||
return data; |
||||
} |
||||
|
||||
// Operators |
||||
template <int N> |
||||
inline _bvecxGTX<N>& _bvecxGTX<N>::operator=(const _bvecxGTX<N>& v) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] = v[i]; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N> |
||||
inline _bvecxGTX<N> _bvecxGTX<N>::operator! () const |
||||
{ |
||||
_bvecxGTX<N> result; |
||||
for(int i = 0; i < N; ++i) |
||||
result[i] = !this->data[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> const typename _xvecxGTX<N, T>::size_type _xvecxGTX<N, T>::value_size = N; |
||||
|
||||
// Common constructors |
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>::_xvecxGTX() |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] = T(0); |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>::_xvecxGTX(const _xvecxGTX<N, T>& v) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] = v[i]; |
||||
} |
||||
|
||||
// T constructors |
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>::_xvecxGTX(const T s) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] = s; |
||||
} |
||||
|
||||
// Accesses |
||||
template <int N, typename T> |
||||
inline T& _xvecxGTX<N, T>::operator[](int i) |
||||
{ |
||||
assert(i >= 0 && i < N); |
||||
return this->data[i]; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline T _xvecxGTX<N, T>::operator[](int i) const |
||||
{ |
||||
assert(i >= 0 && i < N); |
||||
return this->data[i]; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>::operator T*() |
||||
{ |
||||
return data; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>::operator const T*() const |
||||
{ |
||||
return data; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>& _xvecxGTX<N, T>::operator=(const _xvecxGTX<N, T>& v) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] = v[i]; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>& _xvecxGTX<N, T>::operator+= (const T s) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] += s; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>& _xvecxGTX<N, T>::operator+=(const _xvecxGTX<N, T>& v) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] += v[i]; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>& _xvecxGTX<N, T>::operator-= (const T s) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] -= s; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>& _xvecxGTX<N, T>::operator-=(const _xvecxGTX<N, T>& v) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] -= v[i]; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>& _xvecxGTX<N, T>::operator*=(const T s) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] *= s; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>& _xvecxGTX<N, T>::operator*= (const _xvecxGTX<N, T>& v) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] *= v[i]; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>& _xvecxGTX<N, T>::operator/=(const T s) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] /= s; |
||||
return *this; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline _xvecxGTX<N, T>& _xvecxGTX<N, T>::operator/= (const _xvecxGTX<N, T>& v) |
||||
{ |
||||
for(int i = 0; i < N; ++i) |
||||
this->data[i] /= v[i]; |
||||
return *this; |
||||
} |
||||
|
||||
|
||||
// Unary constant operators |
||||
template <int N, typename T> |
||||
inline const detail::_xvecxGTX<N, T> operator- (const detail::_xvecxGTX<N, T>& v) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = -v[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline const detail::_xvecxGTX<N, T> operator++ (const detail::_xvecxGTX<N, T>& v, int) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = v[i] + T(1); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline const detail::_xvecxGTX<N, T> operator-- (const detail::_xvecxGTX<N, T>& v, int) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = v[i] - T(1); |
||||
return result; |
||||
} |
||||
|
||||
// Binary operators |
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> operator+ (const detail::_xvecxGTX<N, T>& v, const T s) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = v[i] + s; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> operator+ (const T s, const detail::_xvecxGTX<N, T>& v) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = v[i] + s; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> operator+ (const detail::_xvecxGTX<N, T>& v1, const detail::_xvecxGTX<N, T>& v2) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = v1[i] + v2[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> operator- (const detail::_xvecxGTX<N, T>& v, const T s) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = v[i] - s; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> operator- (const T s, const detail::_xvecxGTX<N, T>& v) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = s - v[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> operator- (const detail::_xvecxGTX<N, T>& v1, const detail::_xvecxGTX<N, T>& v2) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = v1[i] - v2[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> operator* (const detail::_xvecxGTX<N, T>& v, const T s) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = v[i] * s; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> operator* (const T s, const detail::_xvecxGTX<N, T>& v) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = s * v[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> operator* (const detail::_xvecxGTX<N, T>& v1, const detail::_xvecxGTX<N, T>& v2) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = v1[i] * v2[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> operator/ (const detail::_xvecxGTX<N, T>& v, const T s) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = v[i] / s; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> operator/ (const T s, const detail::_xvecxGTX<N, T>& v) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = s / v[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
inline detail::_xvecxGTX<N, T> operator/ (const detail::_xvecxGTX<N, T>& v1, const detail::_xvecxGTX<N, T>& v2) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = v1[i] / v2[i]; |
||||
return result; |
||||
} |
||||
|
||||
}//namespace detail |
||||
|
||||
namespace gtx{ |
||||
namespace vecx{ |
||||
|
||||
// Trigonometric Functions |
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> radiansGTX(const detail::_xvecxGTX<N, T>& degrees) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = radians(degrees[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> degreesGTX(const detail::_xvecxGTX<N, T>& radians) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = degrees(radians[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> sinGTX(const detail::_xvecxGTX<N, T>& angle) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = sin(angle[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> cosGTX(const detail::_xvecxGTX<N, T>& angle) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = cos(angle[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> tanGTX(const detail::_xvecxGTX<N, T>& angle) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = tan(angle[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> asinGTX(const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = asin(x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> acosGTX(const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = acos(x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> atanGTX(const detail::_xvecxGTX<N, T>& y, const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = atan(y[i], x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> atanGTX(const detail::_xvecxGTX<N, T>& y_over_x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = atan(y_over_x[i]); |
||||
return result; |
||||
} |
||||
|
||||
// Exponential Functions |
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> powGTX(const detail::_xvecxGTX<N, T>& x, const detail::_xvecxGTX<N, T>& y) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = pow(x[i], y[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> expGTX(const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = exp(x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> logGTX(const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = log(x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> exp2GTX(const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = exp2(x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> log2GTX(const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = log2(x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> sqrtGTX(const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = sqrt(x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> inversesqrtGTX(const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = inversesqrt(x[i]); |
||||
return result; |
||||
} |
||||
|
||||
// Common Functions |
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> absGTX(const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = abs(x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> signGTX(const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = sign(x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> floorGTX(const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = floor(x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> ceilGTX(const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = ceil(x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> fractGTX(const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = fract(x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> modGTX(const detail::_xvecxGTX<N, T>& x, T y) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = mod(x[i], y); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> modGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
const detail::_xvecxGTX<N, T>& y) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = mod(x[i], y[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> minGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
T y) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = min(x[i], y); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> minGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
const detail::_xvecxGTX<N, T>& y) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = min(x[i], y[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> maxGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
T y) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = max(x[i], y); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> maxGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
const detail::_xvecxGTX<N, T>& y) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = max(x[i], y[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> clampGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
T minVal, |
||||
T maxVal) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = clamp(x[i], minVal, maxVal); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> clampGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
const detail::_xvecxGTX<N, T>& minVal, |
||||
const detail::_xvecxGTX<N, T>& maxVal) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = clamp(x[i], minVal[i], maxVal[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> stepGTX( |
||||
T edge, |
||||
const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = step(edge, x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> stepGTX( |
||||
const detail::_xvecxGTX<N, T>& edge, |
||||
const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = step(edge[i], x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> smoothstepGTX( |
||||
T edge0, |
||||
T edge1, |
||||
const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = step(edge0, edge1, x[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> smoothstepGTX( |
||||
const detail::_xvecxGTX<N, T>& edge0, |
||||
const detail::_xvecxGTX<N, T>& edge1, |
||||
const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
detail::_xvecxGTX<N, T> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = step(edge0[i], edge1[i], x[i]); |
||||
return result; |
||||
} |
||||
|
||||
// Geometric Functions |
||||
template <int N, typename T> |
||||
T lengthGTX( |
||||
const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
T sqr = dot(x, x); |
||||
return sqrt(sqr); |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
T distanceGTX( |
||||
const detail::_xvecxGTX<N, T>& p0, |
||||
const detail::_xvecxGTX<N, T>& p1) |
||||
{ |
||||
return lengthGTX(p1 - p0); |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
T dotGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
const detail::_xvecxGTX<N, T>& y) |
||||
{ |
||||
T result = T(0); |
||||
for(int i = 0; i < N; ++i) |
||||
result += x[i] * y[i]; |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> normalizeGTX( |
||||
const detail::_xvecxGTX<N, T>& x) |
||||
{ |
||||
T sqr = dot(x, x); |
||||
return x * inversesqrt(sqr); |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> faceforwardGTX( |
||||
const detail::_xvecxGTX<N, T>& Normal, |
||||
const detail::_xvecxGTX<N, T>& I, |
||||
const detail::_xvecxGTX<N, T>& Nref) |
||||
{ |
||||
return dot(Nref, I) < T(0) ? Normal : -Normal; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> reflectGTX( |
||||
const detail::_xvecxGTX<N, T>& I, |
||||
const detail::_xvecxGTX<N, T>& Normal) |
||||
{ |
||||
return I - Normal * dot(Normal, I) * T(2); |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_xvecxGTX<N, T> refractGTX( |
||||
const detail::_xvecxGTX<N, T>& I, |
||||
const detail::_xvecxGTX<N, T>& Normal, |
||||
T eta) |
||||
{ |
||||
T dot = dot(Normal, I); |
||||
T k = T(1) - eta * eta * (T(1) - dot * dot); |
||||
if(k < T(0)) |
||||
return detail::_xvecxGTX<N, T>(T(0)); |
||||
else |
||||
return eta * I - (eta * dot + sqrt(k)) * Normal; |
||||
} |
||||
|
||||
// Vector Relational Functions |
||||
template <int N, typename T> |
||||
detail::_bvecxGTX<N> lessThanGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
const detail::_xvecxGTX<N, T>& y) |
||||
{ |
||||
detail::_bvecxGTX<N> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = lessThan(x[i], y[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_bvecxGTX<N> lessThanEqualGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
const detail::_xvecxGTX<N, T>& y) |
||||
{ |
||||
detail::_bvecxGTX<N> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = lessThanEqual(x[i], y[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_bvecxGTX<N> greaterThanGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
const detail::_xvecxGTX<N, T>& y) |
||||
{ |
||||
detail::_bvecxGTX<N> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = greaterThan(x[i], y[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_bvecxGTX<N> greaterThanEqualGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
const detail::_xvecxGTX<N, T>& y) |
||||
{ |
||||
detail::_bvecxGTX<N> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = greaterThanEqual(x[i], y[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N> |
||||
detail::_bvecxGTX<N> equalGTX( |
||||
const detail::_bvecxGTX<N>& x, |
||||
const detail::_bvecxGTX<N>& y) |
||||
{ |
||||
detail::_bvecxGTX<N> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = equal(x[i], y[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_bvecxGTX<N> equalGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
const detail::_xvecxGTX<N, T>& y) |
||||
{ |
||||
detail::_bvecxGTX<N> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = equal(x[i], y[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N> |
||||
detail::_bvecxGTX<N> notEqualGTX( |
||||
const detail::_bvecxGTX<N>& x, |
||||
const detail::_bvecxGTX<N>& y) |
||||
{ |
||||
detail::_bvecxGTX<N> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = equal(x[i], y[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N, typename T> |
||||
detail::_bvecxGTX<N> notEqualGTX( |
||||
const detail::_xvecxGTX<N, T>& x, |
||||
const detail::_xvecxGTX<N, T>& y) |
||||
{ |
||||
detail::_bvecxGTX<N> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = notEqual(x[i], y[i]); |
||||
return result; |
||||
} |
||||
|
||||
template <int N> |
||||
bool anyGTX(const detail::_bvecxGTX<N>& x) |
||||
{ |
||||
for(int i = 0; i< N; ++i) |
||||
if(x[i]) return true; |
||||
return false; |
||||
} |
||||
|
||||
template <int N> |
||||
bool allGTX(const detail::_bvecxGTX<N>& x) |
||||
{ |
||||
for(int i = 0; i< N; ++i) |
||||
if(!x[i]) return false; |
||||
return true; |
||||
} |
||||
|
||||
template <int N> |
||||
detail::_bvecxGTX<N> notGTX( |
||||
const detail::_bvecxGTX<N>& v) |
||||
{ |
||||
detail::_bvecxGTX<N> result; |
||||
for(int i = 0; i< N; ++i) |
||||
result[i] = !v[i]; |
||||
return result; |
||||
} |
||||
|
||||
}//namespace vecx |
||||
}//namespace gtx |
||||
|
||||
} //namespace glm |
Loading…
Reference in New Issue