Merge branch '0.9.1' into intrinsic

This commit is contained in:
Christophe Riccio 2010-04-30 12:05:49 +01:00
commit 7a6ae63b43
32 changed files with 337 additions and 3584 deletions

Binary file not shown.

View File

@ -1,3 +1,6 @@
#include "../glm.hpp"
#include "../ext.hpp"
int main()
{

View File

@ -2,7 +2,7 @@
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-05-01
// Updated : 2010-02-20
// Updated : 2010-04-30
// Licence : This source is under MIT License
// File : glm/ext.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -10,27 +10,27 @@
#ifndef glm_ext
#define glm_ext
#include "gtc/double_float.hpp"
#include "gtc/half_float.hpp"
#include "gtc/matrix_access.hpp"
#include "gtc/matrix_operation.hpp"
#include "gtc/matrix_projection.hpp"
#include "gtc/matrix_transform.hpp"
#include "gtc/quaternion.hpp"
#include "gtc/swizzle.hpp"
#include "./gtc/double_float.hpp"
#include "./gtc/half_float.hpp"
#include "./gtc/matrix_access.hpp"
#include "./gtc/matrix_operation.hpp"
#include "./gtc/matrix_projection.hpp"
#include "./gtc/matrix_transform.hpp"
#include "./gtc/quaternion.hpp"
#include "./gtc/swizzle.hpp"
#include "./gtc/type_precision.hpp"
#include "./gtc/type_ptr.hpp"
//#include "./gtx/array_range.hpp"
#include "./gtx/associated_min_max.hpp"
#include "./gtx/bit.hpp"
#include "./gtx/closest_point.hpp"
#include "./gtx/color_cast.hpp"
#include "./gtx/color_space.hpp"
#include "./gtx/color_space_YCoCg.hpp"
#include "./gtx/comparison.hpp"
#include "./gtx/compatibility.hpp"
#include "./gtx/component_wise.hpp"
//#include "./gtx/complex.hpp"
#include "./gtx/determinant.hpp"
#include "./gtx/double_float.hpp"
#include "./gtx/epsilon.hpp"
#include "./gtx/euler_angles.hpp"
#include "./gtx/extend.hpp"
@ -38,30 +38,27 @@
#include "./gtx/fast_exponential.hpp"
#include "./gtx/fast_square_root.hpp"
#include "./gtx/fast_trigonometry.hpp"
//#include "./gtx/flexible_mix.hpp"
//#include "./gtx/gpu_shader4.hpp"
#include "./gtx/gradient_paint.hpp"
#include "./gtx/half_float.hpp"
#include "./gtx/handed_coordinate_space.hpp"
#include "./gtx/inertia.hpp"
#include "./gtx/integer.hpp"
#include "./gtx/intersect.hpp"
#include "./gtx/inverse.hpp"
#include "./gtx/inverse_transpose.hpp"
//#include "./gtx/mat_mn.hpp"
#include "./gtx/log_base.hpp"
#include "./gtx/matrix_access.hpp"
#include "./gtx/matrix_cross_product.hpp"
#include "./gtx/matrix_major_storage.hpp"
#include "./gtx/matrix_operation.hpp"
#include "./gtx/matrix_projection.hpp"
#include "./gtx/matrix_query.hpp"
#include "./gtx/matrix_selection.hpp"
//#include "./gtx/matx.hpp"
#include "./gtx/mixed_product.hpp"
#include "./gtx/norm.hpp"
#include "./gtx/normal.hpp"
#include "./gtx/normalize_dot.hpp"
#include "./gtx/number_precision.hpp"
#include "./gtx/ocl_type.hpp"
#include "./gtx/optimum_pow.hpp"
#include "./gtx/orthonormalize.hpp"
#include "./gtx/perpendicular.hpp"
@ -82,7 +79,6 @@
#include "./gtx/vector_access.hpp"
#include "./gtx/vector_angle.hpp"
#include "./gtx/vector_query.hpp"
//#include "./gtx/vecx.hpp"
#include "./gtx/verbose_operator.hpp"
#include "./img/multiple.hpp"
@ -90,7 +86,6 @@
#include "./virtrev/address.hpp"
#include "./virtrev/equal_operator.hpp"
#include "./virtrev/xstream.hpp"
//const float goldenRatio = 1.618033988749894848f;
//const float pi = 3.141592653589793238f;

View File

@ -24,11 +24,11 @@ namespace glm
namespace gtc{
//! GLM_GTC_swizzle extension
namespace glm_gtc_swizzle{
namespace swizzle{
}//namespace closest_point
}//namespace swizzle
}//namespace gtc
}//namespace glm

View File

@ -3,58 +3,48 @@ namespace gtc{
namespace glm_gtc_swizzle
{
template <typename T>
inline typename tvec4<T>::value_type swizzle
inline T swizzle
(
detail::tvec4<T> const & v,
comp x
) const
)
{
return v[x];
}
template <typename T>
inline tvec2<T> tvec4<T>::swizzle
inline detail::tvec2<T> swizzle
(
detail::tvec4<T> const & v,
comp x, comp y
) const
)
{
return tvec2<T>(
(*this)[x],
(*this)[y]);
return detail::tvec2<T>(
v[x],
v[y]);
}
template <typename T>
inline tvec3<T> tvec4<T>::swizzle
inline detail::tvec3<T> swizzle
(
detail::tvec4<T> const & v,
comp x, comp y, comp z
) const
)
{
return tvec3<T>(
(*this)[x],
(*this)[y],
(*this)[z]);
return detail::tvec3<T>(
v[x],
v[y],
v[z]);
}
template <typename T>
inline tvec4<T> tvec4<T>::swizzle
(
detail::tvec4<T> const & v,
comp x, comp y, comp z, comp w
) const
{
return tvec4<T>(v[x], v[y], v[z], v[w]);
}
template <typename T>
inline tref4<T> swizzle
inline detail::tref4<T> swizzle
(
detail::tvec4<T> const & v,
comp x, comp y, comp z, comp w
)
{
return tref4<T>(v[x], v[y], v[z], v[w]);
return detail::tref4<T>(v[x], v[y], v[z], v[w]);
}
}//namespace glm_gtc_swizzle

299
glm/gtc/type_ptr.hpp Normal file
View File

@ -0,0 +1,299 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-05-06
// Updated : 2010-04-30
// Licence : This source is under MIT License
// File : glm/gtc/type_ptr.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtc_type_ptr
#define glm_gtc_type_ptr
// Dependency:
#include "../glm.hpp"
namespace glm
{
namespace test{
void main_gtc_type_ptr();
}//namespace test
namespace gtc{
//! GLM_GTC_type_ptr extension: Get access to vectors & matrices value type address.
namespace type_ptr{
//! Get the const address of the vector content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T const * value_ptr
(
detail::tvec2<T> const & vec
)
{
return &(vec.x);
}
//! Get the address of the vector content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T * value_ptr
(
detail::tvec2<T> & vec
)
{
return &(vec.x);
}
//! Get the const address of the vector content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T const * value_ptr
(
detail::tvec3<T> const & vec
)
{
return &(vec.x);
}
//! Get the address of the vector content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T * value_ptr
(
detail::tvec3<T> & vec
)
{
return &(vec.x);
}
//! Get the const address of the vector content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T const * value_ptr
(
detail::tvec4<T> const & vec
)
{
return &(vec.x);
}
//! Get the address of the vector content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T * value_ptr
(
detail::tvec4<T> & vec
)
{
return &(vec.x);
}
//! Get the const address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T const * value_ptr
(
detail::tmat2x2<T> const & mat
)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T * value_ptr
(
detail::tmat2x2<T> & mat
)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T const * value_ptr
(
detail::tmat3x3<T> const & mat
)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T * value_ptr
(
detail::tmat3x3<T> & mat
)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T const * value_ptr
(
detail::tmat4x4<T> const & mat
)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T * value_ptr
(
detail::tmat4x4<T> & mat
)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T const * value_ptr
(
detail::tmat2x3<T> const & mat
)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T * value_ptr
(
detail::tmat2x3<T> & mat
)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T const * value_ptr
(
detail::tmat3x2<T> const & mat
)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T * value_ptr
(
detail::tmat3x2<T> & mat
)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T const * value_ptr
(
detail::tmat2x4<T> const & mat
)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T * value_ptr
(
detail::tmat2x4<T> & mat
)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T const * value_ptr
(
detail::tmat4x2<T> const & mat
)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T * value_ptr
(
detail::tmat4x2<T> & mat
)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T const * value_ptr
(
detail::tmat3x4<T> const & mat
)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T * value_ptr
(
detail::tmat3x4<T> & mat
)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T const * value_ptr
(
detail::tmat4x3<T> const & mat
)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTC_type_ptr extension.
template<typename T>
inline T * value_ptr(detail::tmat4x3<T> & mat)
{
return &(mat[0].x);
}
}//namespace type_ptr
}//namespace gtc
}//namespace glm
#include "type_ptr.inl"
namespace glm{using namespace gtc::type_ptr;}
#endif//glm_gtx_type_ptr

View File

@ -1,56 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2005-12-21
// Updated : 2008-10-05
// Licence : This source is under MIT License
// File : glm/gtx/double_float.h
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
// - GLM_GTC_double_float
// - GLM_GTX_quaternion
///////////////////////////////////////////////////////////////////////////////////////////////////
// Note:
// - This implementation doesn't need to redefine all build-in functions to
// support double based type.
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtx_double_float
#define glm_gtx_double_float
// Dependency:
#include "../glm.hpp"
#include "../gtc/double_float.hpp"
#include "../gtx/quaternion.hpp"
namespace glm
{
namespace test{
void main_gtx_double_float();
}//namespace test
namespace gtx{
//! GLM_GTX_double_float extension: Add support for double precision flotting-point types
namespace double_float
{
//! Quaternion of single-precision floating-point numbers.
//! From GLM_GTX_double extension.
typedef detail::tquat<float> fquat;
//! Quaternion of double-precision floating-point numbers.
//! From GLM_GTX_double extension.
typedef detail::tquat<double> dquat;
}//namespace double_float
}//namespace gtx
}//namespace glm
#define GLM_GTX_double_float namespace gtc::double_float; using namespace gtx::double_float
#ifndef GLM_GTX_GLOBAL
namespace glm {using GLM_GTX_double_float;}
#endif//GLM_GTX_GLOBAL
#include "double_float.inl"
#endif//glm_gtx_double_float

View File

@ -1,13 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-04-29
// Updated : 2009-04-29
// Licence : This source is under MIT License
// File : glm/gtc/double_float.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm
{
}

View File

@ -1,60 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2007-09-21
// Updated : 2007-09-21
// Licence : This source is under MIT licence
// File : glm/gtx/flexible_mix.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm
{
// mix
template <typename T, typename U>
inline T mixGTX(T x, T y, U a)
{
//GLM_STATIC_ASSERT(detail::traits<U>::is_float);
//return T(x * (U(1) - a) + y * a);
return T(x + a * (y - x));
}
template <typename T, typename U>
inline detail::tvec2<T> mixGTX(const detail::tvec2<T>& x, const detail::tvec2<T>& y, U a)
{
return detail::tvec2<T>(detail::tvec2<U>(x) * (U(1) - a) + detail::tvec2<U>(y) * a);
//return x * (U(1) - a) + y * a;
}
template <typename T, typename U>
inline detail::tvec3<T> mixGTX(const detail::tvec3<T>& x, const detail::tvec3<T>& y, U a)
{
return detail::tvec3<T>(detail::tvec3<U>(x) * (U(1) - a) + detail::tvec3<U>(y) * a);
//return x * (U(1) - a) + y * a;
//return mix(x, y, tvec3<U>(a));
}
template <typename T, typename U>
inline detail::tvec4<T> mixGTX(const detail::tvec4<T>& x, const detail::tvec4<T>& y, U a)
{
return detail::tvec4<T>(detail::tvec4<U>(x) * (U(1) - a) + detail::tvec4<U>(y) * a);
//return x * (U(1) - a) + y * a;
}
template <typename T, typename U>
inline detail::tvec2<T> mixGTX(const detail::tvec2<T>& x, const detail::tvec2<T>& y, const detail::tvec2<U>& a)
{
return detail::tvec2<T>(detail::tvec2<U>(x) * (U(1) - a) + detail::tvec2<U>(y) * a);
}
template <typename T, typename U>
inline detail::tvec3<T> mixGTX(const detail::tvec3<T>& x, const detail::tvec3<T>& y, const detail::tvec3<U>& a)
{
return detail::tvec3<T>(detail::tvec3<U>(x) * (U(1) - a) + detail::tvec3<U>(y) * a);
}
template <typename T, typename U>
inline detail::tvec4<T> mixGTX(const detail::tvec4<T>& x, const detail::tvec4<T>& y, const detail::tvec4<U>& a)
{
return detail::tvec4<T>(detail::tvec4<U>(x) * (U(1) - a) + detail::tvec4<U>(y) * a);
}
}

View File

@ -1,48 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2005-12-21
// Updated : 2009-04-29
// Licence : This source is under MIT License
// File : glm/gtx/half_float.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
// - GLM_GTC_half_float
// - GLM_GTX_quaternion
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtx_half_float
#define glm_gtx_half_float
// Dependency:
#include "../glm.hpp"
#include "../gtc/half_float.hpp"
#include "../gtx/quaternion.hpp"
namespace glm
{
namespace test{
void main_ext_gtx_half_float();
}//namespace test
namespace gtx{
//! GLM_GTX_half_float extension: Add support for half precision flotting-point types
namespace half_float
{
//! Quaternion of half-precision floating-point numbers.
//! From GLM_GTX_half_float extension.
typedef detail::tquat<detail::thalf> hquat;
}//namespace half_float
}//namespace gtx
}//namespace glm
#define GLM_GTX_half_float namespace gtc::half_float; using namespace gtx::half_float; using namespace gtx::quaternion
#ifndef GLM_GTX_GLOBAL
namespace glm {using GLM_GTX_half_float;}
#endif//GLM_GTX_GLOBAL
#include "half_float.inl"
#endif//glm_gtx_half_float

View File

@ -1,16 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2005-12-21
// Updated : 2008-10-02
// Licence : This source is under MIT License
// File : glm/gtx/half.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{
namespace detail{
}//namespace detail
}//namespace glm

View File

@ -1,405 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2006-04-17
// Updated : 2006-04-17
// Licence : This source is under MIT licence
// File : glm/gtx/mat4x3.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm
{
//////////////////////////////////////////////////////////////
// Constructors
template <typename T>
inline _xmat4x3GTX<T>::_xmat4x3GTX()
{
this->value[0] = tvec3<T>(1, 0, 0);
this->value[1] = tvec3<T>(0, 1, 0);
this->value[2] = tvec3<T>(0, 0, 1);
this->value[3] = tvec3<T>(0, 0, 0);
}
template <typename T>
inline _xmat4x3GTX<T>::_xmat4x3GTX(const T f)
{
this->value[0] = tvec3<T>(f, 0, 0);
this->value[1] = tvec3<T>(0, f, 0);
this->value[2] = tvec3<T>(0, 0, f);
this->value[3] = tvec3<T>(0, 0, 0);
}
template <typename T>
inline _xmat4x3GTX<T>::_xmat4x3GTX
(
const T x0, const T y0, const T z0,
const T x1, const T y1, const T z1,
const T x2, const T y2, const T z2,
const T x3, const T y3, const T z3
)
{
this->value[0] = tvec3<T>(x0, y0, z0);
this->value[1] = tvec3<T>(x1, y1, z1);
this->value[2] = tvec3<T>(x2, y2, z2);
this->value[3] = tvec3<T>(x3, y3, z3);
}
template <typename T>
inline _xmat4x3GTX<T>::_xmat4x3GTX
(
const tvec3<T> & v0,
const tvec3<T> & v1,
const tvec3<T> & v2,
const tvec3<T> & v3
)
{
this->value[0] = v0;
this->value[1] = v1;
this->value[2] = v2;
this->value[3] = v3;
}
//////////////////////////////////////////////////////////////
// Unary updatable operators
template <typename T>
inline _xmat4x3GTX<T>& _xmat4x3GTX<T>::operator= (const _xmat4x3GTX<T>& m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
this->value[3] = m[3];
return *this;
}
template <typename T>
inline _xmat4x3GTX<T>& _xmat4x3GTX<T>::operator+= (const T s)
{
this->value[0] += s;
this->value[1] += s;
this->value[2] += s;
this->value[3] += s;
return *this;
}
template <typename T>
inline _xmat4x3GTX<T>& _xmat4x3GTX<T>::operator+= (const _xmat4x3GTX<T>& m)
{
this->value[0] += m[0];
this->value[1] += m[1];
this->value[2] += m[2];
this->value[3] += m[3];
return *this;
}
template <typename T>
inline _xmat4x3GTX<T>& _xmat4x3GTX<T>::operator-= (const T s)
{
this->value[0] -= s;
this->value[1] -= s;
this->value[2] -= s;
this->value[3] -= s;
return *this;
}
template <typename T>
inline _xmat4x3GTX<T>& _xmat4x3GTX<T>::operator-= (const _xmat4x3GTX<T>& m)
{
this->value[0] -= m[0];
this->value[1] -= m[1];
this->value[2] -= m[2];
this->value[3] -= m[3];
return *this;
}
template <typename T>
inline _xmat4x3GTX<T>& _xmat4x3GTX<T>::operator*= (const T s)
{
this->value[0] *= s;
this->value[1] *= s;
this->value[2] *= s;
this->value[3] *= s;
return *this;
}
template <typename T>
inline _xmat4x3GTX<T>& _xmat4x3GTX<T>::operator*= (const _xmat4x3GTX<T>& m)
{
return (*this = *this * m);
}
template <typename T>
inline _xmat4x3GTX<T> & _xmat4x3GTX<T>::operator/= (const T s)
{
this->value[0] /= s;
this->value[1] /= s;
this->value[2] /= s;
this->value[3] /= s;
return *this;
}
/*
template <typename T>
inline _xmat4x3GTX<T>& _xmat4x3GTX<T>::operator/= (const _xmat4x3GTX<T>& m)
{
return (*this = *this / m);
}
*/
template <typename T>
inline _xmat4x3GTX<T>& _xmat4x3GTX<T>::operator++ ()
{
++this->value[0];
++this->value[1];
++this->value[2];
++this->value[3];
return *this;
}
template <typename T>
inline _xmat4x3GTX<T>& _xmat4x3GTX<T>::operator-- ()
{
--this->value[0];
--this->value[1];
--this->value[2];
--this->value[3];
return *this;
}
//////////////////////////////////////////////////////////////
// Unary constant operators
template <typename T>
inline const _xmat4x3GTX<T> _xmat4x3GTX<T>::operator- () const
{
return _xmat4x3GTX<T>(
-this->value[0],
-this->value[1],
-this->value[2],
-this->value[3]);
}
template <typename T>
inline const _xmat4x3GTX<T> _xmat4x3GTX<T>::operator-- (int n) const
{
_xmat4x3GTX<T> m = *this;
--m.value[0];
--m.value[1];
--m.value[2];
--m.value[3];
return m;
}
template <typename T>
inline const _xmat4x3GTX<T> _xmat4x3GTX<T>::operator++ (int n) const
{
detail::tmat4x4<T> m = *this;
++m.value[0];
++m.value[1];
++m.value[2];
++m.value[3];
return m;
}
//////////////////////////////////////////////////////////////
// Binary operators
template <typename T>
inline _xmat4x3GTX<T> operator+ (const _xmat4x3GTX<T>& m, const T s)
{
return _xmat4x3GTX<T>(
m[0] + s,
m[1] + s,
m[2] + s,
m[3] + s);
}
template <typename T>
inline _xmat4x3GTX<T> operator+ (const _xmat4x3GTX<T>& m1, const _xmat4x3GTX<T>& m2)
{
return _xmat4x3GTX<T>(
m1[0] + m2[0],
m1[1] + m2[1],
m1[2] + m2[2],
m1[3] + m2[3]);
}
template <typename T>
inline _xmat4x3GTX<T> operator- (const _xmat4x3GTX<T>& m, const T s)
{
return _xmat4x3GTX<T>(
m[0] - s,
m[1] - s,
m[2] - s,
m[3] - s);
}
template <typename T>
inline _xmat4x3GTX<T> operator- (const _xmat4x3GTX<T>& m1, const _xmat4x3GTX<T>& m2)
{
return _xmat4x3GTX<T>(
m1[0] - m2[0],
m1[1] - m2[1],
m1[2] - m2[2],
m1[3] - m2[3]);
}
template <typename T>
inline _xmat4x3GTX<T> operator* (const _xmat4x3GTX<T>& m, const T s)
{
return _xmat4x3GTX<T>(
m[0] * s,
m[1] * s,
m[2] * s,
m[3] * s);
}
template <typename T>
inline _xmat4x3GTX<T> operator* (const T s, const _xmat4x3GTX<T> & m)
{
return _xmat4x3GTX<T>(
m[0] * s,
m[1] * s,
m[2] * s,
m[3] * s);
}
template <typename T>
inline tvec3<T> operator* (const _xmat4x3GTX<T>& m, const tvec4<T>& v)
{
return tvec3<T>(
m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * v.w,
m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * v.w,
m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z + m[3][2] * v.w);
}
template <typename T>
inline tvec3<T> operator* (const tvec4<T>& v, const _xmat4x3GTX<T>& m)
{
return tvec3<T>(
m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * v.w,
m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * v.w,
m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z + m[3][2] * v.w);
}
template <typename T>
inline _xmat4x3GTX<T> operator* (const _xmat4x3GTX<T>& m1, const _xmat4x3GTX<T>& m2)
{
const T SrcA00 = m1[0][0];
const T SrcA01 = m1[0][1];
const T SrcA02 = m1[0][2];
const T SrcA10 = m1[1][0];
const T SrcA11 = m1[1][1];
const T SrcA12 = m1[1][2];
const T SrcA20 = m1[2][0];
const T SrcA21 = m1[2][1];
const T SrcA22 = m1[2][2];
const T SrcA30 = m1[3][0];
const T SrcA31 = m1[3][1];
const T SrcA32 = m1[3][2];
const T SrcB00 = m2[0][0];
const T SrcB01 = m2[0][1];
const T SrcB02 = m2[0][2];
const T SrcB10 = m2[1][0];
const T SrcB11 = m2[1][1];
const T SrcB12 = m2[1][2];
const T SrcB20 = m2[2][0];
const T SrcB21 = m2[2][1];
const T SrcB22 = m2[2][2];
const T SrcB30 = m2[3][0];
const T SrcB31 = m2[3][1];
const T SrcB32 = m2[3][2];
_xmat4x3GTX<T> Result;
Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01 + SrcA20 * SrcB02;
Result[0][1] = SrcA01 * SrcB00 + SrcA11 * SrcB01 + SrcA21 * SrcB02;
Result[0][2] = SrcA02 * SrcB00 + SrcA12 * SrcB01 + SrcA22 * SrcB02;
Result[1][0] = SrcA00 * SrcB10 + SrcA10 * SrcB11 + SrcA20 * SrcB12;
Result[1][1] = SrcA01 * SrcB10 + SrcA11 * SrcB11 + SrcA21 * SrcB12;
Result[1][2] = SrcA02 * SrcB10 + SrcA12 * SrcB11 + SrcA22 * SrcB12;
Result[2][0] = SrcA00 * SrcB20 + SrcA10 * SrcB21 + SrcA20 * SrcB22;
Result[2][1] = SrcA01 * SrcB20 + SrcA11 * SrcB21 + SrcA21 * SrcB22;
Result[2][2] = SrcA02 * SrcB20 + SrcA12 * SrcB21 + SrcA22 * SrcB22;
Result[3][0] = SrcA00 * SrcB30 + SrcA10 * SrcB31 + SrcA20 * SrcB32 + SrcA30;
Result[3][1] = SrcA01 * SrcB30 + SrcA11 * SrcB31 + SrcA21 * SrcB32 + SrcA31;
Result[3][2] = SrcA02 * SrcB30 + SrcA12 * SrcB31 + SrcA22 * SrcB32 + SrcA32;
return Result;
}
template <typename T>
inline _xmat4x3GTX<T> operator/ (const _xmat4x3GTX<T>& m, const T s)
{
return _xmat4x3GTX<T>(
m.value[0] / s,
m.value[1] / s,
m.value[2] / s,
m.value[3] / s);
}
/*
template <typename T>
inline _xmat4x3GTX<T> operator/ (const T s, const _xmat4x3GTX<T>& m)
{
return _xmat4x3GTX<T>(
s / m.value[0],
s / m.value[1],
s / m.value[2],
s / m.value[3]);
}
template <typename T>
tvec3<T> operator/ (const _xmat4x3GTX<T>& m, const tvec4<T>& v)
{
}
template <typename T>
tvec3<T> operator/ (const tvec4<T>& v, const _xmat4x3GTX<T>& m)
{
}
*/
template <typename T>
inline _xmat4x3GTX<T> operator/ (const _xmat4x3GTX<T>& m1, const _xmat4x3GTX<T>& m2)
{
T SubFactor01 = m2[2][1] * m2[3][2] - m2[3][1] * m2[2][2];
T SubFactor02 = m2[2][0] * m2[3][2] - m2[3][0] * m2[2][2];
T SubFactor03 = m2[2][0] * m2[3][1] - m2[3][0] * m2[2][1];
T SubFactor04 = m2[1][1] * m2[3][2] - m2[3][1] * m2[1][2];
T SubFactor05 = m2[1][0] * m2[3][2] - m2[3][0] * m2[1][2];
T SubFactor06 = m2[1][0] * m2[3][1] - m2[3][0] * m2[1][1];
T SubFactor07 = m2[1][1] * m2[2][2] - m2[2][1] * m2[1][2];
T SubFactor08 = m2[1][0] * m2[2][2] - m2[2][0] * m2[1][2];
T SubFactor09 = m2[1][0] * m2[2][1] - m2[2][0] * m2[1][1];
_xmat4x3GTX<T> Inverse(
+ m2[1][3] * SubFactor01,
- m2[1][3] * SubFactor02,
+ m2[1][3] * SubFactor03,
-(m2[1][0] * SubFactor01 - m2[1][1] * SubFactor02 + m2[1][2] * SubFactor03),
- m2[0][3] * SubFactor01,
+ m2[0][3] * SubFactor02,
- m2[0][3] * SubFactor03,
+(m2[0][0] * SubFactor02 - m2[0][1] * SubFactor02 + m2[0][2] * SubFactor03),
+ m2[0][3] * SubFactor04,
- m2[0][3] * SubFactor05,
+ m2[0][3] * SubFactor06,
-(m2[0][0] * SubFactor04 - m2[0][1] * SubFactor05 + m2[0][2] * SubFactor06),
- m2[0][3] * SubFactor07,
+ m2[0][3] * SubFactor08,
- m2[0][3] * SubFactor09,
+(m2[0][0] * SubFactor07 - m2[0][1] * SubFactor08 + m2[0][2] * SubFactor09));
T Determinant = m2[0][0] * Inverse[0][0]
+ m2[0][1] * Inverse[1][0]
+ m2[0][2] * Inverse[2][0]
+ m2[0][3] * Inverse[3][0];
Inverse /= Determinant;
return m1 * Inverse;
}
} //namespace glm

View File

@ -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

View File

@ -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

View File

@ -1,141 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-05-07
// Updated : 2009-05-07
// Licence : This source is under MIT License
// File : glm/gtx/simd_vec4.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
// - intrinsic
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtx_simd_mat4
#define glm_gtx_simd_mat4
// Dependency:
#include "../glm.hpp"
#include <xmmintrin.h>
#include <emmintrin.h>
namespace glm
{
namespace detail
{
GLM_ALIGN(16) struct fmat4x4SIMD
{
static __m128 one;
enum no_init
{
NO_INIT
};
typedef float value_type;
typedef fvec4SIMD col_type;
typedef fvec4SIMD row_type;
typedef glm::sizeType size_type;
static size_type value_size();
static size_type col_size();
static size_type row_size();
static bool is_matrix();
fvec4SIMD Data[4];
//////////////////////////////////////
// Constructors
fmat4x4SIMD();
explicit fmat4x4SIMD(float const & s);
explicit fmat4x4SIMD(
float const & x0, float const & y0, float const & z0, float const & w0,
float const & x1, float const & y1, float const & z1, float const & w1,
float const & x2, float const & y2, float const & z2, float const & w2,
float const & x3, float const & y3, float const & z3, float const & w3);
explicit fmat4x4SIMD(
fvec4SIMD const & v0,
fvec4SIMD const & v1,
fvec4SIMD const & v2,
fvec4SIMD const & v3);
explicit fmat4x4SIMD(
tmat4x4 const & m);
// Conversions
//template <typename U>
//explicit tmat4x4(tmat4x4<U> const & m);
//explicit tmat4x4(tmat2x2<T> const & x);
//explicit tmat4x4(tmat3x3<T> const & x);
//explicit tmat4x4(tmat2x3<T> const & x);
//explicit tmat4x4(tmat3x2<T> const & x);
//explicit tmat4x4(tmat2x4<T> const & x);
//explicit tmat4x4(tmat4x2<T> const & x);
//explicit tmat4x4(tmat3x4<T> const & x);
//explicit tmat4x4(tmat4x3<T> const & x);
// Accesses
fvec4SIMD & operator[](size_type i);
fvec4SIMD const & operator[](size_type i) const;
// Unary updatable operators
fmat4x4SIMD & operator= (fmat4x4SIMD const & m);
fmat4x4SIMD & operator+= (float const & s);
fmat4x4SIMD & operator+= (fmat4x4SIMD const & m);
fmat4x4SIMD & operator-= (float const & s);
fmat4x4SIMD & operator-= (fmat4x4SIMD const & m);
fmat4x4SIMD & operator*= (float const & s);
fmat4x4SIMD & operator*= (fmat4x4SIMD const & m);
fmat4x4SIMD & operator/= (float const & s);
fmat4x4SIMD & operator/= (fmat4x4SIMD const & m);
fmat4x4SIMD & operator++ ();
fmat4x4SIMD & operator-- ();
};
// Binary operators
fmat4x4SIMD operator+ (fmat4x4SIMD const & m, float const & s);
fmat4x4SIMD operator+ (float const & s, fmat4x4SIMD const & m);
fmat4x4SIMD operator+ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
fmat4x4SIMD operator- (fmat4x4SIMD const & m, float const & s);
fmat4x4SIMD operator- (float const & s, fmat4x4SIMD const & m);
fmat4x4SIMD operator- (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
fmat4x4SIMD operator* (fmat4x4SIMD const & m, float const & s);
fmat4x4SIMD operator* (float const & s, fmat4x4SIMD const & m);
fvec4SIMD operator* (fmat4x4SIMD const & m, fvec4SIMD const & v);
fvec4SIMD operator* (fvec4SIMD const & v, fmat4x4SIMD const & m);
fmat4x4SIMD operator* (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
fmat4x4SIMD operator/ (fmat4x4SIMD const & m, float const & s);
fmat4x4SIMD operator/ (float const & s, fmat4x4SIMD const & m);
fvec4SIMD operator/ (fmat4x4SIMD const & m, fvec4SIMD const & v);
fvec4SIMD operator/ (fvec4SIMD const & v, fmat4x4SIMD const & m);
fmat4x4SIMD operator/ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
// Unary constant operators
fmat4x4SIMD const operator- (fmat4x4SIMD const & m);
fmat4x4SIMD const operator-- (fmat4x4SIMD const & m, int);
fmat4x4SIMD const operator++ (fmat4x4SIMD const & m, int);
}//namespace detail
namespace gtx{
//! GLM_GTX_simd_mat4 extension: SIMD implementation of vec4 type.
namespace simd_mat4
{
typedef detail::fmat4SIMD mat4SIMD;
}//namespace simd_mat4
}//namespace gtx
}//namespace glm
#include "simd_mat4.inl"
namespace glm{using namespace gtx::simd_mat4;}
#endif//glm_gtx_simd_mat4

View File

@ -1,221 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-05-19
// Updated : 2009-05-19
// Licence : This source is under MIT License
// File : glm/gtx/simd_mat4.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{
namespace detail
{
inline fmat4x4SIMD::fmat4x4SIMD()
{}
inline fmat4x4SIMD::fmat4x4SIMD(float const & s)
{
this->value[0] = fvec4SIMD(s, 0, 0, 0);
this->value[1] = fvec4SIMD(0, s, 0, 0);
this->value[2] = fvec4SIMD(0, 0, s, 0);
this->value[3] = fvec4SIMD(0, 0, 0, s);
}
inline fmat4x4SIMD::fmat4x4SIMD
(
float const & x0, float const & y0, float const & z0, float const & w0,
float const & x1, float const & y1, float const & z1, float const & w1,
float const & x2, float const & y2, float const & z2, float const & w2,
float const & x3, float const & y3, float const & z3, float const & w3
)
{
this->value[0] = fvec4SIMD(x0, y0, z0, w0);
this->value[1] = fvec4SIMD(x1, y1, z1, w1);
this->value[2] = fvec4SIMD(x2, y2, z2, w2);
this->value[3] = fvec4SIMD(x3, y3, z3, w3);
}
inline fmat4x4SIMD::fmat4x4SIMD
(
fvec4SIMD const & v0,
fvec4SIMD const & v1,
fvec4SIMD const & v2,
fvec4SIMD const & v3
)
{
this->value[0] = v0;
this->value[1] = v1;
this->value[2] = v2;
this->value[3] = v3;
}
inline fmat4x4SIMD::fmat4x4SIMD
(
tmat4x4 const & m
)
{
this->value[0] = fvec4SIMD(m[0]);
this->value[1] = fvec4SIMD(m[1]);
this->value[2] = fvec4SIMD(m[2]);
this->value[3] = fvec4SIMD(m[3]);
}
//////////////////////////////////////
// Accesses
inline fvec4SIMD & fmat4x4SIMD::operator[]
(
typename fmat4x4SIMD::size_type i
)
{
assert(
i >= typename tmat4x4<valType>::size_type(0) &&
i < tmat4x4<valType>::col_size());
return value[i];
}
inline fvec4SIMD const & fmat4x4SIMD::operator[]
(
typename fmat4x4SIMD::size_type i
) const
{
assert(
i >= typename fmat4x4SIMD::size_type(0) &&
i < fmat4x4SIMD::col_size());
return value[i];
}
//////////////////////////////////////////////////////////////
// mat4 operators
inline fmat4x4SIMD& fmat4x4SIMD::operator=
(
fmat4x4SIMD const & m
)
{
this->value[0].Data = m[0].Data;
this->value[1].Data = m[1].Data;
this->value[2].Data = m[2].Data;
this->value[3].Data = m[3].Data;
return *this;
}
inline fmat4x4SIMD & fmat4x4SIMD::operator+=
(
fmat4x4SIMD const & m
)
{
this->value[0].Data = _mm_add_ps(this->value[0].Data, m[0].Data);
this->value[1].Data = _mm_add_ps(this->value[1].Data, m[1].Data);
this->value[2].Data = _mm_add_ps(this->value[2].Data, m[2].Data);
this->value[3].Data = _mm_add_ps(this->value[3].Data, m[3].Data);
return *this;
}
inline fmat4x4SIMD & fmat4x4SIMD::operator-=
(
fmat4x4SIMD const & m
)
{
this->value[0].Data = _mm_sub_ps(this->value[0].Data, m[0].Data);
this->value[1].Data = _mm_sub_ps(this->value[1].Data, m[1].Data);
this->value[2].Data = _mm_sub_ps(this->value[2].Data, m[2].Data);
this->value[3].Data = _mm_sub_ps(this->value[3].Data, m[3].Data);
return *this;
}
inline fmat4x4SIMD & fmat4x4SIMD::operator*=
(
fmat4x4SIMD const & m
)
{
_mm_mul_ps(this->Data, m.Data, this->Data);
return *this;
}
inline fmat4x4SIMD & fmat4x4SIMD::operator/=
(
fmat4x4SIMD const & m
)
{
__m128 Inv[4];
_mm_inverse_ps(m.Data, Inv);
_mm_mul_ps(this->Data, Inv, this->Data);
return *this;
}
inline fmat4x4SIMD & fmat4x4SIMD::operator+=
(
float const & s
)
{
__m128 Operand = _mm_set_ps1(s);
this->value[0].Data = _mm_add_ps(this->value[0].Data, Operand);
this->value[1].Data = _mm_add_ps(this->value[1].Data, Operand);
this->value[2].Data = _mm_add_ps(this->value[2].Data, Operand);
this->value[3].Data = _mm_add_ps(this->value[3].Data, Operand);
return *this;
}
inline fmat4x4SIMD & fmat4x4SIMD::operator-=
(
float const & s
)
{
__m128 Operand = _mm_set_ps1(s);
this->value[0].Data = _mm_sub_ps(this->value[0].Data, Operand);
this->value[1].Data = _mm_sub_ps(this->value[1].Data, Operand);
this->value[2].Data = _mm_sub_ps(this->value[2].Data, Operand);
this->value[3].Data = _mm_sub_ps(this->value[3].Data, Operand);
return *this;
}
inline fmat4x4SIMD & fmat4x4SIMD::operator*=
(
float const & s
)
{
__m128 Operand = _mm_set_ps1(s);
this->value[0].Data = _mm_mul_ps(this->value[0].Data, Operand);
this->value[1].Data = _mm_mul_ps(this->value[1].Data, Operand);
this->value[2].Data = _mm_mul_ps(this->value[2].Data, Operand);
this->value[3].Data = _mm_mul_ps(this->value[3].Data, Operand);
return *this;
}
inline fmat4x4SIMD & fmat4x4SIMD::operator/=
(
float const & s
)
{
__m128 Operand = _mm_div_ps(one, s));
this->value[0].Data = _mm_mul_ps(this->value[0].Data, Operand);
this->value[1].Data = _mm_mul_ps(this->value[1].Data, Operand);
this->value[2].Data = _mm_mul_ps(this->value[2].Data, Operand);
this->value[3].Data = _mm_mul_ps(this->value[3].Data, Operand);
return *this;
}
inline fmat4x4SIMD & fmat4x4SIMD::operator++ ()
{
this->value[0].Data = _mm_add_ps(this->value[0].Data, one);
this->value[1].Data = _mm_add_ps(this->value[1].Data, one);
this->value[2].Data = _mm_add_ps(this->value[2].Data, one);
this->value[3].Data = _mm_add_ps(this->value[3].Data, one);
return *this;
}
inline fmat4x4SIMD & fmat4x4SIMD::operator-- ()
{
this->value[0].Data = _mm_sub_ps(this->value[0].Data, one);
this->value[1].Data = _mm_sub_ps(this->value[1].Data, one);
this->value[2].Data = _mm_sub_ps(this->value[2].Data, one);
this->value[3].Data = _mm_sub_ps(this->value[3].Data, one);
return *this;
}
}//namespace detail
}//namespace glm

View File

@ -1,127 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-05-07
// Updated : 2009-05-07
// Licence : This source is under MIT License
// File : glm/gtx/simd_vec4.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
// - intrinsic
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtx_simd_vec4
#define glm_gtx_simd_vec4
// Dependency:
#include "../glm.hpp"
#include "../core/intrinsic_common.hpp"
namespace glm
{
namespace detail
{
GLM_ALIGN(4) struct fvec4SIMD
{
static __m128 one;
union
{
__m128 Data;
struct{float x, y, z, w;};
float array[4];
};
//////////////////////////////////////
// Implicit basic constructors
fvec4SIMD();
fvec4SIMD(__m128 const & Data);
fvec4SIMD(fvec4SIMD const & v);
fvec4SIMD(tvec4<float> const & v);
//////////////////////////////////////
// Explicit basic constructors
fvec4SIMD(float const & s);
fvec4SIMD(float const & x, float const & y, float const & z, float const & w);
fvec4SIMD(float const v[4]);
////////////////////////////////////////
//// Swizzle constructors
//fvec4SIMD(ref4<float> const & r);
////////////////////////////////////////
//// Convertion vector constructors
fvec4SIMD(vec2 const & v, float const & s1, float const & s2);
fvec4SIMD(float const & s1, vec2 const & v, float const & s2);
fvec4SIMD(float const & s1, float const & s2, vec2 const & v);
fvec4SIMD(vec3 const & v, float const & s);
fvec4SIMD(float const & s, vec3 const & v);
fvec4SIMD(vec2 const & v1, vec2 const & v2);
//fvec4SIMD(ivec4SIMD const & v);
//////////////////////////////////////
// Unary arithmetic operators
fvec4SIMD& operator= (fvec4SIMD const & v);
fvec4SIMD& operator+=(fvec4SIMD const & v);
fvec4SIMD& operator-=(fvec4SIMD const & v);
fvec4SIMD& operator*=(fvec4SIMD const & v);
fvec4SIMD& operator/=(fvec4SIMD const & v);
fvec4SIMD& operator+=(float const & s);
fvec4SIMD& operator-=(float const & s);
fvec4SIMD& operator*=(float const & s);
fvec4SIMD& operator/=(float const & s);
fvec4SIMD& operator++();
fvec4SIMD& operator--();
////////////////////////////////////////
//// Unary bit operators
//fvec4SIMD& operator%= (float s);
//fvec4SIMD& operator%= (fvec4SIMD const & v);
//fvec4SIMD& operator&= (float s);
//fvec4SIMD& operator&= (fvec4SIMD const & v);
//fvec4SIMD& operator|= (float s);
//fvec4SIMD& operator|= (fvec4SIMD const & v);
//fvec4SIMD& operator^= (float s);
//fvec4SIMD& operator^= (fvec4SIMD const & v);
//fvec4SIMD& operator<<=(float s);
//fvec4SIMD& operator<<=(fvec4SIMD const & v);
//fvec4SIMD& operator>>=(float s);
//fvec4SIMD& operator>>=(fvec4SIMD const & v);
//////////////////////////////////////
// Swizzle operators
//float swizzle(comp X) const;
//vec2 const swizzle(comp X, comp Y) const;
//vec3 const swizzle(comp X, comp Y, comp Z) const;
//fvec4SIMD const swizzle(comp X, comp Y, comp Z, comp W) const;
//fvec4SIMD const swizzle(int X, int Y, int Z, int W) const;
//ref4<float> swizzle(comp X, comp Y, comp Z, comp W);
};
}//namespace detail
namespace gtx{
//! GLM_GTX_simd_vec4 extension: SIMD implementation of vec4 type.
namespace simd_vec4
{
typedef detail::fvec4SIMD vec4SIMD;
}//namespace simd_vec4
}//namespace gtx
}//namespace glm
#include "simd_vec4.inl"
namespace glm{using namespace gtx::simd_vec4;}
#endif//glm_gtx_simd_vec4

View File

@ -1,263 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-05-07
// Updated : 2009-05-07
// Licence : This source is under MIT License
// File : glm/gtx/simd_vec4.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm
{
namespace detail
{
__m128 fvec4SIMD::one = _mm_set_ps1(1.f);
//////////////////////////////////////
// Implicit basic constructors
inline fvec4SIMD::fvec4SIMD()
{}
inline fvec4SIMD::fvec4SIMD(__m128 const & Data) :
Data(Data)
{}
inline fvec4SIMD::fvec4SIMD(fvec4SIMD const & v) :
Data(v.Data)
{}
inline fvec4SIMD::fvec4SIMD(tvec4<float> const & v) :
Data(_mm_set_ps(v.w, v.z, v.y, v.x))
{}
//////////////////////////////////////
// Explicit basic constructors
inline fvec4SIMD::fvec4SIMD(float const & s) :
Data(_mm_set1_ps(s))
{}
inline fvec4SIMD::fvec4SIMD(float const & x, float const & y, float const & z, float const & w) :
// Data(_mm_setr_ps(x, y, z, w))
Data(_mm_set_ps(w, z, y, x))
{}
inline fvec4SIMD::fvec4SIMD(float const v[4]) :
Data(_mm_load_ps(v))
{}
//////////////////////////////////////
// Swizzle constructors
//fvec4SIMD(ref4<float> const & r);
//////////////////////////////////////
// Convertion vector constructors
inline fvec4SIMD::fvec4SIMD(vec2 const & v, float const & s1, float const & s2) :
Data(_mm_set_ps(s2, s1, v.y, v.x))
{}
inline fvec4SIMD::fvec4SIMD(float const & s1, vec2 const & v, float const & s2) :
Data(_mm_set_ps(s2, v.y, v.x, s1))
{}
inline fvec4SIMD::fvec4SIMD(float const & s1, float const & s2, vec2 const & v) :
Data(_mm_set_ps(v.y, v.x, s2, s1))
{}
inline fvec4SIMD::fvec4SIMD(vec3 const & v, float const & s) :
Data(_mm_set_ps(s, v.z, v.y, v.x))
{}
inline fvec4SIMD::fvec4SIMD(float const & s, vec3 const & v) :
Data(_mm_set_ps(v.z, v.y, v.x, s))
{}
inline fvec4SIMD::fvec4SIMD(vec2 const & v1, vec2 const & v2) :
Data(_mm_set_ps(v2.y, v2.x, v1.y, v1.x))
{}
//inline fvec4SIMD::fvec4SIMD(ivec4SIMD const & v) :
// Data(_mm_cvtepi32_ps(v.Data))
//{}
//////////////////////////////////////
// Unary arithmetic operators
inline fvec4SIMD& fvec4SIMD::operator=(fvec4SIMD const & v)
{
this->Data = v.Data;
return *this;
}
inline fvec4SIMD& fvec4SIMD::operator+=(float const & s)
{
this->Data = _mm_add_ps(Data, _mm_set_ps1(s));
return *this;
}
inline fvec4SIMD& fvec4SIMD::operator+=(fvec4SIMD const & v)
{
this->Data = _mm_add_ps(this->Data , v.Data);
return *this;
}
inline fvec4SIMD& fvec4SIMD::operator-=(float const & s)
{
this->Data = _mm_sub_ps(Data, _mm_set_ps1(s));
return *this;
}
inline fvec4SIMD& fvec4SIMD::operator-=(fvec4SIMD const & v)
{
this->Data = _mm_sub_ps(this->Data , v.Data);
return *this;
}
inline fvec4SIMD& fvec4SIMD::operator*=(float const & s)
{
this->Data = _mm_mul_ps(this->Data, _mm_set_ps1(s));
return *this;
}
inline fvec4SIMD& fvec4SIMD::operator*=(fvec4SIMD const & v)
{
this->Data = _mm_mul_ps(this->Data , v.Data);
return *this;
}
inline fvec4SIMD& fvec4SIMD::operator/=(float const & s)
{
this->Data = _mm_div_ps(Data, _mm_set1_ps(s));
return *this;
}
inline fvec4SIMD& fvec4SIMD::operator/=(fvec4SIMD const & v)
{
this->Data = _mm_div_ps(this->Data , v.Data);
return *this;
}
inline fvec4SIMD& fvec4SIMD::operator++()
{
this->Data = _mm_add_ps(this->Data , glm::detail::one);
return *this;
}
inline fvec4SIMD& fvec4SIMD::operator--()
{
this->Data = _mm_sub_ps(this->Data , glm::detail::one);
return *this;
}
//////////////////////////////////////
// Swizzle operators
//inline fvec4SIMD const fvec4SIMD::swizzle(int d, int c, int b, int a) const
//{
// int const Mask = ((d << 6) | (c << 4) | (b << 2) | (a << 0));
// __m128 Data = _mm_shuffle_ps(this->Data, this->Data, Mask);
// return fvec4SIMD(Data);
//}
// operator+
inline fvec4SIMD operator+ (fvec4SIMD const & v, float s)
{
return fvec4SIMD(_mm_add_ps(v.Data, _mm_set1_ps(s)));
}
inline fvec4SIMD operator+ (float s, fvec4SIMD const & v)
{
return fvec4SIMD(_mm_add_ps(_mm_set1_ps(s), v.Data));
}
inline fvec4SIMD operator+ (fvec4SIMD const & v1, fvec4SIMD const & v2)
{
return fvec4SIMD(_mm_add_ps(v1.Data, v2.Data));
}
//operator-
inline fvec4SIMD operator- (fvec4SIMD const & v, float s)
{
return fvec4SIMD(_mm_sub_ps(v.Data, _mm_set1_ps(s)));
}
inline fvec4SIMD operator- (float s, fvec4SIMD const & v)
{
return fvec4SIMD(_mm_sub_ps(_mm_set1_ps(s), v.Data));
}
inline fvec4SIMD operator- (fvec4SIMD const & v1, fvec4SIMD const & v2)
{
return fvec4SIMD(_mm_sub_ps(v1.Data, v2.Data));
}
//operator*
inline fvec4SIMD operator* (fvec4SIMD const & v, float s)
{
__m128 par0 = v.Data;
__m128 par1 = _mm_set1_ps(s);
return fvec4SIMD(_mm_mul_ps(par0, par1));
}
inline fvec4SIMD operator* (float s, fvec4SIMD const & v)
{
__m128 par0 = _mm_set1_ps(s);
__m128 par1 = v.Data;
return fvec4SIMD(_mm_mul_ps(par0, par1));
}
inline fvec4SIMD operator* (fvec4SIMD const & v1, fvec4SIMD const & v2)
{
return fvec4SIMD(_mm_mul_ps(v1.Data, v2.Data));
}
//operator/
inline fvec4SIMD operator/ (fvec4SIMD const & v, float s)
{
__m128 par0 = v.Data;
__m128 par1 = _mm_set1_ps(s);
return fvec4SIMD(_mm_div_ps(par0, par1));
}
inline fvec4SIMD operator/ (float s, fvec4SIMD const & v)
{
__m128 par0 = _mm_set1_ps(s);
__m128 par1 = v.Data;
return fvec4SIMD(_mm_div_ps(par0, par1));
}
inline fvec4SIMD operator/ (fvec4SIMD const & v1, fvec4SIMD const & v2)
{
return fvec4SIMD(_mm_div_ps(v1.Data, v2.Data));
}
// Unary constant operators
inline fvec4SIMD operator- (fvec4SIMD const & v)
{
return fvec4SIMD(_mm_sub_ps(_mm_setzero_ps(), v.Data));
}
inline fvec4SIMD operator++ (fvec4SIMD const & v, int)
{
return fvec4SIMD(_mm_add_ps(v.Data, glm::detail::one));
}
inline fvec4SIMD operator-- (fvec4SIMD const & v, int)
{
return fvec4SIMD(_mm_sub_ps(v.Data, glm::detail::one));
}
}//namespace detail
namespace gtx{
namespace simd_vec4
{
}//namespace simd_vec4
}//namespace gtx
}//namespace glm

View File

@ -1,67 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2007-11-21
// Updated : 2007-11-21
// Licence : This source is under MIT License
// File : glm/gtx/statistics_operation.h
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtx_statistics_operation
#define glm_gtx_statistics_operation
// Dependency:
#include "../glm.hpp"
namespace glm
{
template <typename T> T statDistanceGTX(const detail::tvec2<T>& v1, const detail::tvec2<T>& v2);
template <typename T> T statDistanceGTX(const detail::tvec3<T>& v1, const detail::tvec3<T>& v2);
template <typename T> T statDistanceGTX(const detail::tvec4<T>& v1, const detail::tvec4<T>& v2);
template <typename T> T statDistanceGTX(const detail::tmat2x2<T>& m1, const detail::tmat2x2<T>& m2);
template <typename T> T statDistanceGTX(const detail::tmat3x3<T>& m1, const detail::tmat3x3<T>& m2);
template <typename T> T statDistanceGTX(const detail::tmat4x4<T>& m1, const detail::tmat4x4<T>& m2);
template <typename T> T expectedValueGTX(const detail::tvec2<T>& v1, const detail::tvec2<T>& v2);
template <typename T> T expectedValueGTX(const detail::tvec3<T>& v1, const detail::tvec3<T>& v2);
template <typename T> T expectedValueGTX(const detail::tvec4<T>& v1, const detail::tvec4<T>& v2);
template <typename T> T expectedValueGTX(const detail::tmat2x2<T>& m1, const detail::tmat2x2<T>& m2);
template <typename T> T expectedValueGTX(const detail::tmat3x3<T>& m1, const detail::tmat3x3<T>& m2);
template <typename T> T expectedValueGTX(const detail::tmat4x4<T>& m1, const detail::tmat4x4<T>& m2);
template <typename T> T varianceGTX(const detail::tvec2<T>& v1, const detail::tvec2<T>& v2);
template <typename T> T varianceGTX(const detail::tvec3<T>& v1, const detail::tvec3<T>& v2);
template <typename T> T varianceGTX(const detail::tvec4<T>& v1, const detail::tvec4<T>& v2);
template <typename T> T varianceGTX(const detail::tmat2x2<T>& m1, const detail::tmat2x2<T>& m2);
template <typename T> T varianceGTX(const detail::tmat3x3<T>& m1, const detail::tmat3x3<T>& m2);
template <typename T> T varianceGTX(const detail::tmat4x4<T>& m1, const detail::tmat4x4<T>& m2);
template <typename T> T standardDevitionGTX(const detail::tvec2<T>& v1, const detail::tvec2<T>& v2);
template <typename T> T standardDevitionGTX(const detail::tvec3<T>& v1, const detail::tvec3<T>& v2);
template <typename T> T standardDevitionGTX(const detail::tvec4<T>& v1, const detail::tvec4<T>& v2);
template <typename T> T standardDevitionGTX(const detail::tmat2x2<T>& m1, const detail::tmat2x2<T>& m2);
template <typename T> T standardDevitionGTX(const detail::tmat3x3<T>& m1, const detail::tmat3x3<T>& m2);
template <typename T> T standardDevitionGTX(const detail::tmat4x4<T>& m1, const detail::tmat4x4<T>& m2);
namespace gtx
{
//! GLM_GTX_statistics_operation extension: - Work in progress - Statistics functions
namespace statistics_operation
{
}
}
}
#include "statistics_operation.inl"
namespace glm{using namespace gtx::statistics_operation;}
#endif//glm_gtx_statistics_operation

View File

@ -1,81 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2007-11-21
// Updated : 2007-11-21
// Licence : This source is under MIT License
// File : glm/gtx/statistics_operator.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <cassert>
namespace glm
{
//! Compute the sum of square of differences between each matrices paremeters
template <typename T>
inline T statDistanceGTX(const detail::tmat2x2<T>& m1, const detail::tmat2x2<T>& m2)
{
T result = T(0);
for(int j = 0; j < 2; ++j)
for(int i = 0; i < 2; ++i)
{
T diff = m1[j][i] - m2[j][i];
result += diff * diff;
}
return result;
}
template <typename T>
inline T statDistanceGTX(const detail::tmat3x3<T>& m1, const detail::tmat3x3<T>& m2)
{
T result = T(0);
for(int j = 0; j < 3; ++j)
for(int i = 0; i < 3; ++i)
{
T diff = m1[j][i] - m2[j][i];
result += diff * diff;
}
return result;
}
template <typename T>
inline T statDistanceGTX(const detail::tmat4x4<T>& m1, const detail::tmat4x4<T>& m2)
{
T result = T(0);
for(int j = 0; j < 4; ++j)
for(int i = 0; i < 4; ++i)
{
T diff = m1[j][i] - m2[j][i];
result += diff * diff;
}
return result;
}
template <typename T>
T expectedValueGTX(const detail::tmat4x4<T>& m)
{
T result = T(0);
for(int j = 0; j < 4; ++j)
for(int i = 0; i < 4; ++i)
result += m[j][i];
result *= T(0,0625);
return result;
}
template <typename T>
T varianceGTX(const detail::tmat4x4<T>& m)
{
T ExpectedValue = expectedValueGTX(m);
T ExpectedValueOfSquaredMatrix = expectedValueGTX(matrixCompMult(m));
return ExpectedValueOfSquaredMatrix - ExpectedValue * ExpectedValue;
}
template <typename T>
T standardDevitionGTX(const detail::tmat4x4<T>& m)
{
return sqrt(varianceGTX(m));
}
}

View File

@ -1,230 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-05-06
// Updated : 2009-05-06
// Licence : This source is under MIT License
// File : glm/gtx/type_ptr.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtx_type_ptr
#define glm_gtx_type_ptr
// Dependency:
#include "../glm.hpp"
namespace glm
{
namespace test{
void main_gtx_type_ptr();
}//namespace test
namespace gtx{
//! GLM_GTX_type_ptr extension: Get access to vectors & matrices value type address.
namespace type_ptr{
//! Get the const address of the vector content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType const * value_ptr(detail::tvec2<valType> const & vec)
{
return &(vec.x);
}
//! Get the address of the vector content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType * value_ptr(detail::tvec2<valType> & vec)
{
return &(vec.x);
}
//! Get the const address of the vector content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType const * value_ptr(detail::tvec3<valType> const & vec)
{
return &(vec.x);
}
//! Get the address of the vector content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType * value_ptr(detail::tvec3<valType> & vec)
{
return &(vec.x);
}
//! Get the const address of the vector content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType const * value_ptr(detail::tvec4<valType> const & vec)
{
return &(vec.x);
}
//! Get the address of the vector content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType * value_ptr(detail::tvec4<valType> & vec)
{
return &(vec.x);
}
//! Get the const address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType const * value_ptr(detail::tmat2x2<valType> const & mat)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType * value_ptr(detail::tmat2x2<valType> & mat)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType const * value_ptr(detail::tmat3x3<valType> const & mat)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType * value_ptr(detail::tmat3x3<valType> & mat)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType const * value_ptr(detail::tmat4x4<valType> const & mat)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType * value_ptr(detail::tmat4x4<valType> & mat)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType const * value_ptr(detail::tmat2x3<valType> const & mat)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType * value_ptr(detail::tmat2x3<valType> & mat)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType const * value_ptr(detail::tmat3x2<valType> const & mat)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType * value_ptr(detail::tmat3x2<valType> & mat)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType const * value_ptr(detail::tmat2x4<valType> const & mat)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType * value_ptr(detail::tmat2x4<valType> & mat)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType const * value_ptr(detail::tmat4x2<valType> const & mat)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType * value_ptr(detail::tmat4x2<valType> & mat)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType const * value_ptr(detail::tmat3x4<valType> const & mat)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType * value_ptr(detail::tmat3x4<valType> & mat)
{
return &(mat[0].x);
}
//! Get the const address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType const * value_ptr(detail::tmat4x3<valType> const & mat)
{
return &(mat[0].x);
}
//! Get the address of the matrix content.
//! From GLM_GTX_type_ptr extension.
template<typename valType>
inline valType * value_ptr(detail::tmat4x3<valType> & mat)
{
return &(mat[0].x);
}
}//namespace type_ptr
}//namespace gtx
}//namespace glm
#include "type_ptr.inl"
namespace glm{using namespace gtx::type_ptr;}
#endif//glm_gtx_type_ptr

View File

@ -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

View File

@ -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

View File

@ -183,10 +183,7 @@ namespace glm
}
}
#define GLM_VIRTREV_address namespace virtrev_glmext::address
#ifndef GLM_VIRTREV_GLOBAL
namespace glm {using GLM_VIRTREV_address;}
#endif//GLM_VIRTREV_GLOBAL
namespace glm{using namespace virtrev_glmext::address;}
#endif//GLM_EXT_VIRTREV_ADDRESS_HPP

View File

@ -62,7 +62,7 @@ namespace glm
}
}
namespace glm {namespace virtrev_glmext::equal_operator;}
namespace glm {using namespace virtrev_glmext::equal_operator;}
#endif//glm_virtrev_equal_operator

View File

@ -1,64 +0,0 @@
#ifndef GLM_EXT_VIRTREV_GL_HPP
#define GLM_EXT_VIRTREV_GL_HPP
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// Virtrev SDK copyright matrem (matrem84.free.fr)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-04-24
// Updated : 2008-10-07
// Licence : This source is under MIT License
// File : glm/ext/virtrev/gl.h
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
// - glew or glee or gl library header
///////////////////////////////////////////////////////////////////////////////////////////////////
#include "../glm.hpp"
#if !defined(GLM_DEPENDENCE) || !(GLM_DEPENDENCE & (GLM_DEPENDENCE_GLEW|GLM_DEPENDENCE_GLEE|GLM_DEPENDENCE_GL))
#error GLM_VIRTREV_gl requires OpenGL to build. GLM_DEPENDENCE doesn't define the dependence.
#endif//GLM_DEPENDENCE
namespace glm
{
namespace virtrev_glmext
{
//! GLM_VIRTREV_gl extension: Vector & matrix integration with OpenGL.
namespace gl
{
typedef detail::tvec2<GLfloat> gl_vec2; ///< vec2 for GLfloat OpenGL type
typedef detail::tvec3<GLfloat> gl_vec3; ///< vec3 for GLfloat OpenGL type
typedef detail::tvec4<GLfloat> gl_vec4; ///< vec4 for GLfloat OpenGL type
typedef detail::tvec2<GLshort> gl_svec2; ///< vec2 for GLshort OpenGL type
typedef detail::tvec3<GLshort> gl_svec3; ///< vec3 for GLshort OpenGL type
typedef detail::tvec4<GLshort> gl_svec4; ///< vec4 for GLshort OpenGL type
typedef detail::tvec2<GLint> gl_ivec2; ///< vec2 for GLint OpenGL type
typedef detail::tvec3<GLint> gl_ivec3; ///< vec3 for GLint OpenGL type
typedef detail::tvec4<GLint> gl_ivec4; ///< vec4 for GLint OpenGL type
typedef detail::tmat2x2<GLfloat> gl_mat2; ///< mat2x2 for GLfloat OpenGL type
typedef detail::tmat3x3<GLfloat> gl_mat3; ///< mat3x3 for GLfloat OpenGL type
typedef detail::tmat4x4<GLfloat> gl_mat4; ///< mat4x4 for GLfloat OpenGL type
typedef detail::tmat2x3<GLfloat> gl_mat2x3; ///< mat2x3 for GLfloat OpenGL type
typedef detail::tmat3x2<GLfloat> gl_mat3x2; ///< mat3x2 for GLfloat OpenGL type
typedef detail::tmat2x4<GLfloat> gl_mat2x4; ///< mat2x4 for GLfloat OpenGL type
typedef detail::tmat4x2<GLfloat> gl_mat4x2; ///< mat4x2 for GLfloat OpenGL type
typedef detail::tmat3x4<GLfloat> gl_mat3x4; ///< mat3x4 for GLfloat OpenGL type
typedef detail::tmat4x3<GLfloat> gl_mat4x3; ///< mat4x3 for GLfloat OpenGL type
}
}
}
#define GLM_VIRTREV_gl namespace glm::virtrev_glmext::gl
#ifndef GLM_VIRTREV_GLOBAL
namespace glm {using GLM_VIRTREV_gl;}
#endif//GLM_VIRTREV_GLOBAL
#endif//GLM_EXT_VIRTREV_GL_HPP

View File

@ -139,9 +139,6 @@ namespace glm
}
}
#define GLM_VIRTREV_xstream namespace glm::virtrev_glmext::xstream
#ifndef GLM_VIRTREV_GLOBAL
namespace glm {using GLM_VIRTREV_xstream;}
#endif//GLM_VIRTREV_GLOBAL
namespace glm{using namespace glm::virtrev_glmext::xstream;}
#endif
#endif//GLM_EXT_VIRTREV_XSTREAM_HPP