Initial commit: Final state of the master project
This commit is contained in:
185
Research/inc/glm/gtc/constants.hpp
Normal file
185
Research/inc/glm/gtc/constants.hpp
Normal file
@@ -0,0 +1,185 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_constants
|
||||
/// @file glm/gtc/constants.hpp
|
||||
/// @date 2011-09-30 / 2012-01-25
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_half_float (dependence)
|
||||
///
|
||||
/// @defgroup gtc_constants GLM_GTC_constants
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Provide a list of constants and precomputed useful values.
|
||||
///
|
||||
/// <glm/gtc/constants.hpp> need to be included to use these features.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_constants
|
||||
#define GLM_GTC_constants
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_constants extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_constants
|
||||
/// @{
|
||||
|
||||
/// Return the epsilon constant for floating point types.
|
||||
/// @todo Implement epsilon for half-precision floating point type.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType epsilon();
|
||||
|
||||
/// Return 0.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType zero();
|
||||
|
||||
/// Return 1.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType one();
|
||||
|
||||
/// Return the pi constant.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType pi();
|
||||
|
||||
/// Return square root of pi.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType root_pi();
|
||||
|
||||
/// Return pi / 2.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType half_pi();
|
||||
|
||||
/// Return pi / 4.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType quarter_pi();
|
||||
|
||||
/// Return 1 / pi.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType one_over_pi();
|
||||
|
||||
/// Return 2 / pi.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType two_over_pi();
|
||||
|
||||
/// Return 2 / sqrt(pi).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType two_over_root_pi();
|
||||
|
||||
/// Return 1 / sqrt(2).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType one_over_root_two();
|
||||
|
||||
/// Return sqrt(pi / 2).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType root_half_pi();
|
||||
|
||||
/// Return sqrt(2 * pi).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType root_two_pi();
|
||||
|
||||
/// Return sqrt(ln(4)).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType root_ln_four();
|
||||
|
||||
/// Return e constant.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType e();
|
||||
|
||||
/// Return Euler's constant.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType euler();
|
||||
|
||||
/// Return sqrt(2).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType root_two();
|
||||
|
||||
/// Return sqrt(3).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType root_three();
|
||||
|
||||
/// Return sqrt(5).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType root_five();
|
||||
|
||||
/// Return ln(2).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType ln_two();
|
||||
|
||||
/// Return ln(10).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType ln_ten();
|
||||
|
||||
/// Return ln(ln(2)).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType ln_ln_two();
|
||||
|
||||
/// Return 1 / 3.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType third();
|
||||
|
||||
/// Return 2 / 3.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType two_thirds();
|
||||
|
||||
/// Return the golden ratio constant.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType golden_ratio();
|
||||
|
||||
/// @}
|
||||
} //namespace glm
|
||||
|
||||
#include "constants.inl"
|
||||
|
||||
#endif//GLM_GTC_constants
|
||||
182
Research/inc/glm/gtc/constants.inl
Normal file
182
Research/inc/glm/gtc/constants.inl
Normal file
@@ -0,0 +1,182 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtx_constants
|
||||
/// @file glm/gtx/constants.inl
|
||||
/// @date 2011-10-14 / 2012-01-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType epsilon()
|
||||
{
|
||||
return std::numeric_limits<genType>::epsilon();
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType zero()
|
||||
{
|
||||
return genType(0);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType one()
|
||||
{
|
||||
return genType(1);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType pi()
|
||||
{
|
||||
return genType(3.14159265358979323846264338327950288);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType root_pi()
|
||||
{
|
||||
return genType(1.772453850905516027);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType half_pi()
|
||||
{
|
||||
return genType(1.57079632679489661923132169163975144);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType quarter_pi()
|
||||
{
|
||||
return genType(0.785398163397448309615660845819875721);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType one_over_pi()
|
||||
{
|
||||
return genType(0.318309886183790671537767526745028724);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType two_over_pi()
|
||||
{
|
||||
return genType(0.636619772367581343075535053490057448);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType two_over_root_pi()
|
||||
{
|
||||
return genType(1.12837916709551257389615890312154517);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType one_over_root_two()
|
||||
{
|
||||
return genType(0.707106781186547524400844362104849039);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType root_half_pi()
|
||||
{
|
||||
return genType(1.253314137315500251);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType root_two_pi()
|
||||
{
|
||||
return genType(2.506628274631000502);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType root_ln_four()
|
||||
{
|
||||
return genType(1.17741002251547469);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType e()
|
||||
{
|
||||
return genType(2.71828182845904523536);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType euler()
|
||||
{
|
||||
return genType(0.577215664901532860606);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType root_two()
|
||||
{
|
||||
return genType(1.41421356237309504880168872420969808);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType root_three()
|
||||
{
|
||||
return genType(1.73205080756887729352744634150587236);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType root_five()
|
||||
{
|
||||
return genType(2.23606797749978969640917366873127623);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType ln_two()
|
||||
{
|
||||
return genType(0.693147180559945309417232121458176568);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType ln_ten()
|
||||
{
|
||||
return genType(2.30258509299404568401799145468436421);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType ln_ln_two()
|
||||
{
|
||||
return genType(-0.3665129205816643);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType third()
|
||||
{
|
||||
return genType(0.3333333333333333333333333333333333333333);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType two_thirds()
|
||||
{
|
||||
return genType(0.666666666666666666666666666666666666667);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType golden_ratio()
|
||||
{
|
||||
return genType(1.61803398874989484820458683436563811);
|
||||
}
|
||||
} //namespace glm
|
||||
101
Research/inc/glm/gtc/epsilon.hpp
Normal file
101
Research/inc/glm/gtc/epsilon.hpp
Normal file
@@ -0,0 +1,101 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_epsilon
|
||||
/// @file glm/gtc/epsilon.hpp
|
||||
/// @date 2012-04-07 / 2012-04-07
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_half_float (dependence)
|
||||
/// @see gtc_quaternion (dependence)
|
||||
///
|
||||
/// @defgroup gtc_epsilon GLM_GTC_epsilon
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Comparison functions for a user defined epsilon values.
|
||||
///
|
||||
/// <glm/gtc/epsilon.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_epsilon
|
||||
#define GLM_GTC_epsilon
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/precision.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_epsilon extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_epsilon
|
||||
/// @{
|
||||
|
||||
/// Returns the component-wise comparison of |x - y| < epsilon.
|
||||
/// True if this expression is satisfied.
|
||||
///
|
||||
/// @see gtc_epsilon
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<bool, P> epsilonEqual(
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
T const & epsilon);
|
||||
|
||||
/// Returns the component-wise comparison of |x - y| < epsilon.
|
||||
/// True if this expression is satisfied.
|
||||
///
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL bool epsilonEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
genType const & epsilon);
|
||||
|
||||
/// Returns the component-wise comparison of |x - y| < epsilon.
|
||||
/// True if this expression is not satisfied.
|
||||
///
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL typename genType::boolType epsilonNotEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
typename genType::value_type const & epsilon);
|
||||
|
||||
/// Returns the component-wise comparison of |x - y| >= epsilon.
|
||||
/// True if this expression is not satisfied.
|
||||
///
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL bool epsilonNotEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
genType const & epsilon);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "epsilon.inl"
|
||||
|
||||
#endif//GLM_GTC_epsilon
|
||||
150
Research/inc/glm/gtc/epsilon.inl
Normal file
150
Research/inc/glm/gtc/epsilon.inl
Normal file
@@ -0,0 +1,150 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_epsilon
|
||||
/// @file glm/gtc/epsilon.inl
|
||||
/// @date 2012-04-07 / 2012-04-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Dependency:
|
||||
#include "quaternion.hpp"
|
||||
#include "../vector_relational.hpp"
|
||||
#include "../common.hpp"
|
||||
#include "../vec2.hpp"
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER bool epsilonEqual
|
||||
(
|
||||
float const & x,
|
||||
float const & y,
|
||||
float const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(x - y) < epsilon;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER bool epsilonEqual
|
||||
(
|
||||
double const & x,
|
||||
double const & y,
|
||||
double const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(x - y) < epsilon;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER bool epsilonNotEqual
|
||||
(
|
||||
float const & x,
|
||||
float const & y,
|
||||
float const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(x - y) >= epsilon;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER bool epsilonNotEqual
|
||||
(
|
||||
double const & x,
|
||||
double const & y,
|
||||
double const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(x - y) >= epsilon;
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
|
||||
(
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return lessThan(abs(x - y), vecType<T, P>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
|
||||
(
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
vecType<T, P> const & epsilon
|
||||
)
|
||||
{
|
||||
return lessThan(abs(x - y), vecType<T, P>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
|
||||
(
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
|
||||
(
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
vecType<T, P> const & epsilon
|
||||
)
|
||||
{
|
||||
return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> epsilonEqual
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
detail::tvec4<T, P> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
|
||||
return lessThan(abs(v), detail::tvec4<T, P>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> epsilonNotEqual
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
detail::tvec4<T, P> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
|
||||
return greaterThanEqual(abs(v), detail::tvec4<T, P>(epsilon));
|
||||
}
|
||||
}//namespace glm
|
||||
87
Research/inc/glm/gtc/matrix_access.hpp
Normal file
87
Research/inc/glm/gtc/matrix_access.hpp
Normal file
@@ -0,0 +1,87 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_matrix_access
|
||||
/// @file glm/gtc/matrix_access.hpp
|
||||
/// @date 2005-12-27 / 2011-05-16
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_matrix_access GLM_GTC_matrix_access
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// Defines functions to access rows or columns of a matrix easily.
|
||||
/// <glm/gtc/matrix_access.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_matrix_access
|
||||
#define GLM_GTC_matrix_access
|
||||
|
||||
// Dependency:
|
||||
#include "../detail/setup.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_matrix_access extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_matrix_access
|
||||
/// @{
|
||||
|
||||
/// Get a specific row of a matrix.
|
||||
/// @see gtc_matrix_access
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL typename genType::row_type row(
|
||||
genType const & m,
|
||||
length_t const & index);
|
||||
|
||||
/// Set a specific row to a matrix.
|
||||
/// @see gtc_matrix_access
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType row(
|
||||
genType const & m,
|
||||
length_t const & index,
|
||||
typename genType::row_type const & x);
|
||||
|
||||
/// Get a specific column of a matrix.
|
||||
/// @see gtc_matrix_access
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL typename genType::col_type column(
|
||||
genType const & m,
|
||||
length_t const & index);
|
||||
|
||||
/// Set a specific column to a matrix.
|
||||
/// @see gtc_matrix_access
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType column(
|
||||
genType const & m,
|
||||
length_t const & index,
|
||||
typename genType::col_type const & x);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "matrix_access.inl"
|
||||
|
||||
#endif//GLM_GTC_matrix_access
|
||||
88
Research/inc/glm/gtc/matrix_access.inl
Normal file
88
Research/inc/glm/gtc/matrix_access.inl
Normal file
@@ -0,0 +1,88 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_matrix_access
|
||||
/// @file glm/gtc/matrix_access.inl
|
||||
/// @date 2005-12-27 / 2011-06-05
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType row
|
||||
(
|
||||
genType const & m,
|
||||
length_t const & index,
|
||||
typename genType::row_type const & x
|
||||
)
|
||||
{
|
||||
assert(index >= 0 && index < m[0].length());
|
||||
|
||||
genType Result = m;
|
||||
for(length_t i = 0; i < m.length(); ++i)
|
||||
Result[i][index] = x[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::row_type row
|
||||
(
|
||||
genType const & m,
|
||||
length_t const & index
|
||||
)
|
||||
{
|
||||
assert(index >= 0 && index < m[0].length());
|
||||
|
||||
typename genType::row_type Result;
|
||||
for(length_t i = 0; i < m.length(); ++i)
|
||||
Result[i] = m[i][index];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType column
|
||||
(
|
||||
genType const & m,
|
||||
length_t const & index,
|
||||
typename genType::col_type const & x
|
||||
)
|
||||
{
|
||||
assert(index >= 0 && index < m.length());
|
||||
|
||||
genType Result = m;
|
||||
Result[index] = x;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::col_type column
|
||||
(
|
||||
genType const & m,
|
||||
length_t const & index
|
||||
)
|
||||
{
|
||||
assert(index >= 0 && index < m.length());
|
||||
|
||||
return m[index];
|
||||
}
|
||||
}//namespace glm
|
||||
514
Research/inc/glm/gtc/matrix_integer.hpp
Normal file
514
Research/inc/glm/gtc/matrix_integer.hpp
Normal file
@@ -0,0 +1,514 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_matrix_integer
|
||||
/// @file glm/gtc/matrix_integer.hpp
|
||||
/// @date 2011-01-20 / 2011-06-05
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_matrix_integer GLM_GTC_matrix_integer
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// Defines a number of matrices with integer types.
|
||||
/// <glm/gtc/matrix_integer.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_matrix_integer
|
||||
#define GLM_GTC_matrix_integer
|
||||
|
||||
// Dependency:
|
||||
#include "../mat2x2.hpp"
|
||||
#include "../mat2x3.hpp"
|
||||
#include "../mat2x4.hpp"
|
||||
#include "../mat3x2.hpp"
|
||||
#include "../mat3x3.hpp"
|
||||
#include "../mat3x4.hpp"
|
||||
#include "../mat4x2.hpp"
|
||||
#include "../mat4x3.hpp"
|
||||
#include "../mat4x4.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_matrix_integer extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_matrix_integer
|
||||
/// @{
|
||||
|
||||
/// High-precision signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x2<int, highp> highp_imat2;
|
||||
|
||||
/// High-precision signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x3<int, highp> highp_imat3;
|
||||
|
||||
/// High-precision signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x4<int, highp> highp_imat4;
|
||||
|
||||
/// High-precision signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x2<int, highp> highp_imat2x2;
|
||||
|
||||
/// High-precision signed integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x3<int, highp> highp_imat2x3;
|
||||
|
||||
/// High-precision signed integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x4<int, highp> highp_imat2x4;
|
||||
|
||||
/// High-precision signed integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x2<int, highp> highp_imat3x2;
|
||||
|
||||
/// High-precision signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x3<int, highp> highp_imat3x3;
|
||||
|
||||
/// High-precision signed integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x4<int, highp> highp_imat3x4;
|
||||
|
||||
/// High-precision signed integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x2<int, highp> highp_imat4x2;
|
||||
|
||||
/// High-precision signed integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x3<int, highp> highp_imat4x3;
|
||||
|
||||
/// High-precision signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x4<int, highp> highp_imat4x4;
|
||||
|
||||
|
||||
/// Medium-precision signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x2<int, mediump> mediump_imat2;
|
||||
|
||||
/// Medium-precision signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x3<int, mediump> mediump_imat3;
|
||||
|
||||
/// Medium-precision signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x4<int, mediump> mediump_imat4;
|
||||
|
||||
|
||||
/// Medium-precision signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x2<int, mediump> mediump_imat2x2;
|
||||
|
||||
/// Medium-precision signed integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x3<int, mediump> mediump_imat2x3;
|
||||
|
||||
/// Medium-precision signed integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x4<int, mediump> mediump_imat2x4;
|
||||
|
||||
/// Medium-precision signed integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x2<int, mediump> mediump_imat3x2;
|
||||
|
||||
/// Medium-precision signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x3<int, mediump> mediump_imat3x3;
|
||||
|
||||
/// Medium-precision signed integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x4<int, mediump> mediump_imat3x4;
|
||||
|
||||
/// Medium-precision signed integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x2<int, mediump> mediump_imat4x2;
|
||||
|
||||
/// Medium-precision signed integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x3<int, mediump> mediump_imat4x3;
|
||||
|
||||
/// Medium-precision signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x4<int, mediump> mediump_imat4x4;
|
||||
|
||||
|
||||
/// Low-precision signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x2<int, lowp> lowp_imat2;
|
||||
|
||||
/// Low-precision signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x3<int, lowp> lowp_imat3;
|
||||
|
||||
/// Low-precision signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x4<int, lowp> lowp_imat4;
|
||||
|
||||
|
||||
/// Low-precision signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x2<int, lowp> lowp_imat2x2;
|
||||
|
||||
/// Low-precision signed integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x3<int, lowp> lowp_imat2x3;
|
||||
|
||||
/// Low-precision signed integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x4<int, lowp> lowp_imat2x4;
|
||||
|
||||
/// Low-precision signed integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x2<int, lowp> lowp_imat3x2;
|
||||
|
||||
/// Low-precision signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x3<int, lowp> lowp_imat3x3;
|
||||
|
||||
/// Low-precision signed integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x4<int, lowp> lowp_imat3x4;
|
||||
|
||||
/// Low-precision signed integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x2<int, lowp> lowp_imat4x2;
|
||||
|
||||
/// Low-precision signed integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x3<int, lowp> lowp_imat4x3;
|
||||
|
||||
/// Low-precision signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x4<int, lowp> lowp_imat4x4;
|
||||
|
||||
|
||||
/// High-precision unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x2<uint, highp> highp_umat2;
|
||||
|
||||
/// High-precision unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x3<uint, highp> highp_umat3;
|
||||
|
||||
/// High-precision unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x4<uint, highp> highp_umat4;
|
||||
|
||||
/// High-precision unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x2<uint, highp> highp_umat2x2;
|
||||
|
||||
/// High-precision unsigned integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x3<uint, highp> highp_umat2x3;
|
||||
|
||||
/// High-precision unsigned integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x4<uint, highp> highp_umat2x4;
|
||||
|
||||
/// High-precision unsigned integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x2<uint, highp> highp_umat3x2;
|
||||
|
||||
/// High-precision unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x3<uint, highp> highp_umat3x3;
|
||||
|
||||
/// High-precision unsigned integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x4<uint, highp> highp_umat3x4;
|
||||
|
||||
/// High-precision unsigned integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x2<uint, highp> highp_umat4x2;
|
||||
|
||||
/// High-precision unsigned integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x3<uint, highp> highp_umat4x3;
|
||||
|
||||
/// High-precision unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x4<uint, highp> highp_umat4x4;
|
||||
|
||||
|
||||
/// Medium-precision unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x2<uint, mediump> mediump_umat2;
|
||||
|
||||
/// Medium-precision unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x3<uint, mediump> mediump_umat3;
|
||||
|
||||
/// Medium-precision unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x4<uint, mediump> mediump_umat4;
|
||||
|
||||
|
||||
/// Medium-precision unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x2<uint, mediump> mediump_umat2x2;
|
||||
|
||||
/// Medium-precision unsigned integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x3<uint, mediump> mediump_umat2x3;
|
||||
|
||||
/// Medium-precision unsigned integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x4<uint, mediump> mediump_umat2x4;
|
||||
|
||||
/// Medium-precision unsigned integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x2<uint, mediump> mediump_umat3x2;
|
||||
|
||||
/// Medium-precision unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x3<uint, mediump> mediump_umat3x3;
|
||||
|
||||
/// Medium-precision unsigned integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x4<uint, mediump> mediump_umat3x4;
|
||||
|
||||
/// Medium-precision unsigned integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x2<uint, mediump> mediump_umat4x2;
|
||||
|
||||
/// Medium-precision unsigned integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x3<uint, mediump> mediump_umat4x3;
|
||||
|
||||
/// Medium-precision unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x4<uint, mediump> mediump_umat4x4;
|
||||
|
||||
|
||||
/// Low-precision unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x2<uint, lowp> lowp_umat2;
|
||||
|
||||
/// Low-precision unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x3<uint, lowp> lowp_umat3;
|
||||
|
||||
/// Low-precision unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x4<uint, lowp> lowp_umat4;
|
||||
|
||||
|
||||
/// Low-precision unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x2<uint, lowp> lowp_umat2x2;
|
||||
|
||||
/// Low-precision unsigned integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x3<uint, lowp> lowp_umat2x3;
|
||||
|
||||
/// Low-precision unsigned integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat2x4<uint, lowp> lowp_umat2x4;
|
||||
|
||||
/// Low-precision unsigned integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x2<uint, lowp> lowp_umat3x2;
|
||||
|
||||
/// Low-precision unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x3<uint, lowp> lowp_umat3x3;
|
||||
|
||||
/// Low-precision unsigned integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat3x4<uint, lowp> lowp_umat3x4;
|
||||
|
||||
/// Low-precision unsigned integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x2<uint, lowp> lowp_umat4x2;
|
||||
|
||||
/// Low-precision unsigned integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x3<uint, lowp> lowp_umat4x3;
|
||||
|
||||
/// Low-precision unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef detail::tmat4x4<uint, lowp> lowp_umat4x4;
|
||||
|
||||
#if(defined(GLM_PRECISION_HIGHP_INT))
|
||||
typedef highp_imat2 imat2;
|
||||
typedef highp_imat3 imat3;
|
||||
typedef highp_imat4 imat4;
|
||||
typedef highp_imat2x2 imat2x2;
|
||||
typedef highp_imat2x3 imat2x3;
|
||||
typedef highp_imat2x4 imat2x4;
|
||||
typedef highp_imat3x2 imat3x2;
|
||||
typedef highp_imat3x3 imat3x3;
|
||||
typedef highp_imat3x4 imat3x4;
|
||||
typedef highp_imat4x2 imat4x2;
|
||||
typedef highp_imat4x3 imat4x3;
|
||||
typedef highp_imat4x4 imat4x4;
|
||||
#elif(defined(GLM_PRECISION_LOWP_INT))
|
||||
typedef lowp_imat2 imat2;
|
||||
typedef lowp_imat3 imat3;
|
||||
typedef lowp_imat4 imat4;
|
||||
typedef lowp_imat2x2 imat2x2;
|
||||
typedef lowp_imat2x3 imat2x3;
|
||||
typedef lowp_imat2x4 imat2x4;
|
||||
typedef lowp_imat3x2 imat3x2;
|
||||
typedef lowp_imat3x3 imat3x3;
|
||||
typedef lowp_imat3x4 imat3x4;
|
||||
typedef lowp_imat4x2 imat4x2;
|
||||
typedef lowp_imat4x3 imat4x3;
|
||||
typedef lowp_imat4x4 imat4x4;
|
||||
#else //if(defined(GLM_PRECISION_MEDIUMP_INT))
|
||||
|
||||
/// Signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_imat2 imat2;
|
||||
|
||||
/// Signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_imat3 imat3;
|
||||
|
||||
/// Signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_imat4 imat4;
|
||||
|
||||
/// Signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_imat2x2 imat2x2;
|
||||
|
||||
/// Signed integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_imat2x3 imat2x3;
|
||||
|
||||
/// Signed integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_imat2x4 imat2x4;
|
||||
|
||||
/// Signed integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_imat3x2 imat3x2;
|
||||
|
||||
/// Signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_imat3x3 imat3x3;
|
||||
|
||||
/// Signed integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_imat3x4 imat3x4;
|
||||
|
||||
/// Signed integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_imat4x2 imat4x2;
|
||||
|
||||
/// Signed integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_imat4x3 imat4x3;
|
||||
|
||||
/// Signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_imat4x4 imat4x4;
|
||||
#endif//GLM_PRECISION
|
||||
|
||||
#if(defined(GLM_PRECISION_HIGHP_UINT))
|
||||
typedef highp_umat2 umat2;
|
||||
typedef highp_umat3 umat3;
|
||||
typedef highp_umat4 umat4;
|
||||
typedef highp_umat2x2 umat2x2;
|
||||
typedef highp_umat2x3 umat2x3;
|
||||
typedef highp_umat2x4 umat2x4;
|
||||
typedef highp_umat3x2 umat3x2;
|
||||
typedef highp_umat3x3 umat3x3;
|
||||
typedef highp_umat3x4 umat3x4;
|
||||
typedef highp_umat4x2 umat4x2;
|
||||
typedef highp_umat4x3 umat4x3;
|
||||
typedef highp_umat4x4 umat4x4;
|
||||
#elif(defined(GLM_PRECISION_LOWP_UINT))
|
||||
typedef lowp_umat2 umat2;
|
||||
typedef lowp_umat3 umat3;
|
||||
typedef lowp_umat4 umat4;
|
||||
typedef lowp_umat2x2 umat2x2;
|
||||
typedef lowp_umat2x3 umat2x3;
|
||||
typedef lowp_umat2x4 umat2x4;
|
||||
typedef lowp_umat3x2 umat3x2;
|
||||
typedef lowp_umat3x3 umat3x3;
|
||||
typedef lowp_umat3x4 umat3x4;
|
||||
typedef lowp_umat4x2 umat4x2;
|
||||
typedef lowp_umat4x3 umat4x3;
|
||||
typedef lowp_umat4x4 umat4x4;
|
||||
#else //if(defined(GLM_PRECISION_MEDIUMP_UINT))
|
||||
|
||||
/// Unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_umat2 umat2;
|
||||
|
||||
/// Unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_umat3 umat3;
|
||||
|
||||
/// Unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_umat4 umat4;
|
||||
|
||||
/// Unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_umat2x2 umat2x2;
|
||||
|
||||
/// Unsigned integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_umat2x3 umat2x3;
|
||||
|
||||
/// Unsigned integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_umat2x4 umat2x4;
|
||||
|
||||
/// Unsigned integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_umat3x2 umat3x2;
|
||||
|
||||
/// Unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_umat3x3 umat3x3;
|
||||
|
||||
/// Unsigned integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_umat3x4 umat3x4;
|
||||
|
||||
/// Unsigned integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_umat4x2 umat4x2;
|
||||
|
||||
/// Unsigned integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_umat4x3 umat4x3;
|
||||
|
||||
/// Unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_umat4x4 umat4x4;
|
||||
#endif//GLM_PRECISION
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#endif//GLM_GTC_matrix_integer
|
||||
74
Research/inc/glm/gtc/matrix_inverse.hpp
Normal file
74
Research/inc/glm/gtc/matrix_inverse.hpp
Normal file
@@ -0,0 +1,74 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_matrix_inverse
|
||||
/// @file glm/gtc/matrix_inverse.hpp
|
||||
/// @date 2005-12-21 / 2011-06-05
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_matrix_inverse GLM_GTC_matrix_inverse
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// Defines additional matrix inverting functions.
|
||||
/// <glm/gtc/matrix_inverse.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_matrix_inverse
|
||||
#define GLM_GTC_matrix_inverse
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_matrix_inverse extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_matrix_inverse
|
||||
/// @{
|
||||
|
||||
/// Fast matrix inverse for affine matrix.
|
||||
///
|
||||
/// @param m Input matrix to invert.
|
||||
/// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-precision floating point value is highly innacurate.
|
||||
/// @see gtc_matrix_inverse
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType affineInverse(genType const & m);
|
||||
|
||||
/// Compute the inverse transpose of a matrix.
|
||||
///
|
||||
/// @param m Input matrix to invert transpose.
|
||||
/// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-precision floating point value is highly innacurate.
|
||||
/// @see gtc_matrix_inverse
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL typename genType::value_type inverseTranspose(
|
||||
genType const & m);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "matrix_inverse.inl"
|
||||
|
||||
#endif//GLM_GTC_matrix_inverse
|
||||
163
Research/inc/glm/gtc/matrix_inverse.inl
Normal file
163
Research/inc/glm/gtc/matrix_inverse.inl
Normal file
@@ -0,0 +1,163 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_matrix_inverse
|
||||
/// @file glm/gtc/matrix_inverse.inl
|
||||
/// @date 2005-12-21 / 2011-06-15
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../mat2x2.hpp"
|
||||
#include "../mat3x3.hpp"
|
||||
#include "../mat4x4.hpp"
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T, P> affineInverse
|
||||
(
|
||||
detail::tmat3x3<T, P> const & m
|
||||
)
|
||||
{
|
||||
detail::tmat3x3<T, P> Result(m);
|
||||
Result[2] = detail::tvec3<T, P>(0, 0, 1);
|
||||
Result = transpose(Result);
|
||||
detail::tvec3<T, P> Translation = Result * detail::tvec3<T, P>(-detail::tvec2<T, P>(m[2]), m[2][2]);
|
||||
Result[2] = Translation;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> affineInverse
|
||||
(
|
||||
detail::tmat4x4<T, P> const & m
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<T, P> Result(m);
|
||||
Result[3] = detail::tvec4<T, P>(0, 0, 0, 1);
|
||||
Result = transpose(Result);
|
||||
detail::tvec4<T, P> Translation = Result * detail::tvec4<T, P>(-detail::tvec3<T, P>(m[3]), m[3][3]);
|
||||
Result[3] = Translation;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<T, P> inverseTranspose
|
||||
(
|
||||
detail::tmat2x2<T, P> const & m
|
||||
)
|
||||
{
|
||||
T Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1];
|
||||
|
||||
detail::tmat2x2<T, P> Inverse(
|
||||
+ m[1][1] / Determinant,
|
||||
- m[0][1] / Determinant,
|
||||
- m[1][0] / Determinant,
|
||||
+ m[0][0] / Determinant);
|
||||
|
||||
return Inverse;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T, P> inverseTranspose
|
||||
(
|
||||
detail::tmat3x3<T, P> const & m
|
||||
)
|
||||
{
|
||||
T Determinant =
|
||||
+ m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
|
||||
- m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
|
||||
+ m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
|
||||
|
||||
detail::tmat3x3<T, P> Inverse;
|
||||
Inverse[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]);
|
||||
Inverse[0][1] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]);
|
||||
Inverse[0][2] = + (m[1][0] * m[2][1] - m[2][0] * m[1][1]);
|
||||
Inverse[1][0] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]);
|
||||
Inverse[1][1] = + (m[0][0] * m[2][2] - m[2][0] * m[0][2]);
|
||||
Inverse[1][2] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]);
|
||||
Inverse[2][0] = + (m[0][1] * m[1][2] - m[1][1] * m[0][2]);
|
||||
Inverse[2][1] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]);
|
||||
Inverse[2][2] = + (m[0][0] * m[1][1] - m[1][0] * m[0][1]);
|
||||
Inverse /= Determinant;
|
||||
|
||||
return Inverse;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> inverseTranspose
|
||||
(
|
||||
detail::tmat4x4<T, P> const & m
|
||||
)
|
||||
{
|
||||
T SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
|
||||
T SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
|
||||
T SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
|
||||
T SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
|
||||
T SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
|
||||
T SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
|
||||
T SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3];
|
||||
T SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
|
||||
T SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2];
|
||||
T SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3];
|
||||
T SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2];
|
||||
T SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
|
||||
T SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1];
|
||||
T SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3];
|
||||
T SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3];
|
||||
T SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2];
|
||||
T SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3];
|
||||
T SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2];
|
||||
T SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
|
||||
|
||||
detail::tmat4x4<T, P> Inverse;
|
||||
Inverse[0][0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02);
|
||||
Inverse[0][1] = - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04);
|
||||
Inverse[0][2] = + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05);
|
||||
Inverse[0][3] = - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05);
|
||||
|
||||
Inverse[1][0] = - (m[0][1] * SubFactor00 - m[0][2] * SubFactor01 + m[0][3] * SubFactor02);
|
||||
Inverse[1][1] = + (m[0][0] * SubFactor00 - m[0][2] * SubFactor03 + m[0][3] * SubFactor04);
|
||||
Inverse[1][2] = - (m[0][0] * SubFactor01 - m[0][1] * SubFactor03 + m[0][3] * SubFactor05);
|
||||
Inverse[1][3] = + (m[0][0] * SubFactor02 - m[0][1] * SubFactor04 + m[0][2] * SubFactor05);
|
||||
|
||||
Inverse[2][0] = + (m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08);
|
||||
Inverse[2][1] = - (m[0][0] * SubFactor06 - m[0][2] * SubFactor09 + m[0][3] * SubFactor10);
|
||||
Inverse[2][2] = + (m[0][0] * SubFactor11 - m[0][1] * SubFactor09 + m[0][3] * SubFactor12);
|
||||
Inverse[2][3] = - (m[0][0] * SubFactor08 - m[0][1] * SubFactor10 + m[0][2] * SubFactor12);
|
||||
|
||||
Inverse[3][0] = - (m[0][1] * SubFactor13 - m[0][2] * SubFactor14 + m[0][3] * SubFactor15);
|
||||
Inverse[3][1] = + (m[0][0] * SubFactor13 - m[0][2] * SubFactor16 + m[0][3] * SubFactor17);
|
||||
Inverse[3][2] = - (m[0][0] * SubFactor14 - m[0][1] * SubFactor16 + m[0][3] * SubFactor18);
|
||||
Inverse[3][3] = + (m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18);
|
||||
|
||||
T Determinant =
|
||||
+ m[0][0] * Inverse[0][0]
|
||||
+ m[0][1] * Inverse[0][1]
|
||||
+ m[0][2] * Inverse[0][2]
|
||||
+ m[0][3] * Inverse[0][3];
|
||||
|
||||
Inverse /= Determinant;
|
||||
|
||||
return Inverse;
|
||||
}
|
||||
}//namespace glm
|
||||
306
Research/inc/glm/gtc/matrix_transform.hpp
Normal file
306
Research/inc/glm/gtc/matrix_transform.hpp
Normal file
@@ -0,0 +1,306 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_matrix_transform
|
||||
/// @file glm/gtc/matrix_transform.hpp
|
||||
/// @date 2009-04-29 / 2011-05-16
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtx_transform
|
||||
/// @see gtx_transform2
|
||||
///
|
||||
/// @defgroup gtc_matrix_transform GLM_GTC_matrix_transform
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Defines functions that generate common transformation matrices.
|
||||
///
|
||||
/// The matrices generated by this extension use standard OpenGL fixed-function
|
||||
/// conventions. For example, the lookAt function generates a transform from world
|
||||
/// space into the specific eye space that the projective matrix functions
|
||||
/// (perspective, ortho, etc) are designed to expect. The OpenGL compatibility
|
||||
/// specifications defines the particular layout of this eye space.
|
||||
///
|
||||
/// <glm/gtc/matrix_transform.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_matrix_transform
|
||||
#define GLM_GTC_matrix_transform
|
||||
|
||||
// Dependency:
|
||||
#include "../mat4x4.hpp"
|
||||
#include "../vec2.hpp"
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
#include "../gtc/constants.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_matrix_transform extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_matrix_transform
|
||||
/// @{
|
||||
|
||||
/// Builds a translation 4 * 4 matrix created from a vector of 3 components.
|
||||
///
|
||||
/// @param m Input matrix multiplied by this translation matrix.
|
||||
/// @param v Coordinates of a translation vector.
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @code
|
||||
/// #include <glm/glm.hpp>
|
||||
/// #include <glm/gtc/matrix_transform.hpp>
|
||||
/// ...
|
||||
/// glm::mat4 m = glm::translate(glm::mat4(1.0f), glm::vec3(1.0f));
|
||||
/// // m[0][0] == 1.0f, m[0][1] == 0.0f, m[0][2] == 0.0f, m[0][3] == 0.0f
|
||||
/// // m[1][0] == 0.0f, m[1][1] == 1.0f, m[1][2] == 0.0f, m[1][3] == 0.0f
|
||||
/// // m[2][0] == 0.0f, m[2][1] == 0.0f, m[2][2] == 1.0f, m[2][3] == 0.0f
|
||||
/// // m[3][0] == 1.0f, m[3][1] == 1.0f, m[3][2] == 1.0f, m[3][3] == 1.0f
|
||||
/// @endcode
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see gtx_transform
|
||||
/// @see - translate(T x, T y, T z)
|
||||
/// @see - translate(detail::tmat4x4<T, P> const & m, T x, T y, T z)
|
||||
/// @see - translate(detail::tvec3<T, P> const & v)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, P> translate(
|
||||
detail::tmat4x4<T, P> const & m,
|
||||
detail::tvec3<T, P> const & v);
|
||||
|
||||
/// Builds a rotation 4 * 4 matrix created from an axis vector and an angle.
|
||||
///
|
||||
/// @param m Input matrix multiplied by this rotation matrix.
|
||||
/// @param angle Rotation angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||
/// @param axis Rotation axis, recommanded to be normalized.
|
||||
/// @tparam T Value type used to build the matrix. Supported: half, float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see gtx_transform
|
||||
/// @see - rotate(T angle, T x, T y, T z)
|
||||
/// @see - rotate(detail::tmat4x4<T, P> const & m, T angle, T x, T y, T z)
|
||||
/// @see - rotate(T angle, detail::tvec3<T, P> const & v)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, P> rotate(
|
||||
detail::tmat4x4<T, P> const & m,
|
||||
T const & angle,
|
||||
detail::tvec3<T, P> const & axis);
|
||||
|
||||
/// Builds a scale 4 * 4 matrix created from 3 scalars.
|
||||
///
|
||||
/// @param m Input matrix multiplied by this scale matrix.
|
||||
/// @param v Ratio of scaling for each axis.
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see gtx_transform
|
||||
/// @see - scale(T x, T y, T z) scale(T const & x, T const & y, T const & z)
|
||||
/// @see - scale(detail::tmat4x4<T, P> const & m, T x, T y, T z)
|
||||
/// @see - scale(detail::tvec3<T, P> const & v)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, P> scale(
|
||||
detail::tmat4x4<T, P> const & m,
|
||||
detail::tvec3<T, P> const & v);
|
||||
|
||||
/// Creates a matrix for an orthographic parallel viewing volume.
|
||||
///
|
||||
/// @param left
|
||||
/// @param right
|
||||
/// @param bottom
|
||||
/// @param top
|
||||
/// @param zNear
|
||||
/// @param zFar
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see - glm::ortho(T const & left, T const & right, T const & bottom, T const & top)
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> ortho(
|
||||
T const & left,
|
||||
T const & right,
|
||||
T const & bottom,
|
||||
T const & top,
|
||||
T const & zNear,
|
||||
T const & zFar);
|
||||
|
||||
/// Creates a matrix for projecting two-dimensional coordinates onto the screen.
|
||||
///
|
||||
/// @param left
|
||||
/// @param right
|
||||
/// @param bottom
|
||||
/// @param top
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see - glm::ortho(T const & left, T const & right, T const & bottom, T const & top, T const & zNear, T const & zFar)
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> ortho(
|
||||
T const & left,
|
||||
T const & right,
|
||||
T const & bottom,
|
||||
T const & top);
|
||||
|
||||
/// Creates a frustum matrix.
|
||||
///
|
||||
/// @param left
|
||||
/// @param right
|
||||
/// @param bottom
|
||||
/// @param top
|
||||
/// @param near
|
||||
/// @param far
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> frustum(
|
||||
T const & left,
|
||||
T const & right,
|
||||
T const & bottom,
|
||||
T const & top,
|
||||
T const & near,
|
||||
T const & far);
|
||||
|
||||
/// Creates a matrix for a symetric perspective-view frustum.
|
||||
///
|
||||
/// @param fovy Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||
/// @param aspect
|
||||
/// @param near
|
||||
/// @param far
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> perspective(
|
||||
T const & fovy,
|
||||
T const & aspect,
|
||||
T const & near,
|
||||
T const & far);
|
||||
|
||||
/// Builds a perspective projection matrix based on a field of view.
|
||||
///
|
||||
/// @param fov Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||
/// @param width
|
||||
/// @param height
|
||||
/// @param near
|
||||
/// @param far
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> perspectiveFov(
|
||||
T const & fov,
|
||||
T const & width,
|
||||
T const & height,
|
||||
T const & near,
|
||||
T const & far);
|
||||
|
||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite.
|
||||
///
|
||||
/// @param fovy Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||
/// @param aspect
|
||||
/// @param near
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> infinitePerspective(
|
||||
T fovy, T aspect, T near);
|
||||
|
||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
||||
///
|
||||
/// @param fovy Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||
/// @param aspect
|
||||
/// @param near
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> tweakedInfinitePerspective(
|
||||
T fovy, T aspect, T near);
|
||||
|
||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
||||
///
|
||||
/// @param fovy Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||
/// @param aspect
|
||||
/// @param near
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> tweakedInfinitePerspective(
|
||||
T fovy, T aspect, T near, T ep);
|
||||
|
||||
/// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
|
||||
///
|
||||
/// @param obj
|
||||
/// @param model
|
||||
/// @param proj
|
||||
/// @param viewport
|
||||
/// @tparam T Native type used for the computation. Currently supported: half (not recommanded), float or double.
|
||||
/// @tparam U Currently supported: Floating-point types and integer types.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T, typename U, precision P>
|
||||
GLM_FUNC_DECL detail::tvec3<T, P> project(
|
||||
detail::tvec3<T, P> const & obj,
|
||||
detail::tmat4x4<T, P> const & model,
|
||||
detail::tmat4x4<T, P> const & proj,
|
||||
detail::tvec4<U, P> const & viewport);
|
||||
|
||||
/// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
|
||||
///
|
||||
/// @param win
|
||||
/// @param model
|
||||
/// @param proj
|
||||
/// @param viewport
|
||||
/// @tparam T Native type used for the computation. Currently supported: half (not recommanded), float or double.
|
||||
/// @tparam U Currently supported: Floating-point types and integer types.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T, typename U, precision P>
|
||||
GLM_FUNC_DECL detail::tvec3<T, P> unProject(
|
||||
detail::tvec3<T, P> const & win,
|
||||
detail::tmat4x4<T, P> const & model,
|
||||
detail::tmat4x4<T, P> const & proj,
|
||||
detail::tvec4<U, P> const & viewport);
|
||||
|
||||
/// Define a picking region
|
||||
///
|
||||
/// @param center
|
||||
/// @param delta
|
||||
/// @param viewport
|
||||
/// @tparam T Native type used for the computation. Currently supported: half (not recommanded), float or double.
|
||||
/// @tparam U Currently supported: Floating-point types and integer types.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T, precision P, typename U>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, P> pickMatrix(
|
||||
detail::tvec2<T, P> const & center,
|
||||
detail::tvec2<T, P> const & delta,
|
||||
detail::tvec4<U, P> const & viewport);
|
||||
|
||||
/// Build a look at view matrix.
|
||||
///
|
||||
/// @param eye Position of the camera
|
||||
/// @param center Position where the camera is looking at
|
||||
/// @param up Normalized up vector, how the camera is oriented. Typically (0, 0, 1)
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see - frustum(T const & left, T const & right, T const & bottom, T const & top, T const & nearVal, T const & farVal) frustum(T const & left, T const & right, T const & bottom, T const & top, T const & nearVal, T const & farVal)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, P> lookAt(
|
||||
detail::tvec3<T, P> const & eye,
|
||||
detail::tvec3<T, P> const & center,
|
||||
detail::tvec3<T, P> const & up);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "matrix_transform.inl"
|
||||
|
||||
#endif//GLM_GTC_matrix_transform
|
||||
442
Research/inc/glm/gtc/matrix_transform.inl
Normal file
442
Research/inc/glm/gtc/matrix_transform.inl
Normal file
@@ -0,0 +1,442 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_matrix_transform
|
||||
/// @file glm/gtc/matrix_transform.inl
|
||||
/// @date 2009-04-29 / 2011-06-15
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../geometric.hpp"
|
||||
#include "../trigonometric.hpp"
|
||||
#include "../matrix.hpp"
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> translate
|
||||
(
|
||||
detail::tmat4x4<T, P> const & m,
|
||||
detail::tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<T, P> Result(m);
|
||||
Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> rotate
|
||||
(
|
||||
detail::tmat4x4<T, P> const & m,
|
||||
T const & angle,
|
||||
detail::tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
T a = angle;
|
||||
#else
|
||||
# pragma message("GLM: rotate function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||
T a = radians(angle);
|
||||
#endif
|
||||
T c = cos(a);
|
||||
T s = sin(a);
|
||||
|
||||
detail::tvec3<T, P> axis(normalize(v));
|
||||
detail::tvec3<T, P> temp((T(1) - c) * axis);
|
||||
|
||||
detail::tmat4x4<T, P> Rotate(detail::tmat4x4<T, P>::_null);
|
||||
Rotate[0][0] = c + temp[0] * axis[0];
|
||||
Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2];
|
||||
Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1];
|
||||
|
||||
Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2];
|
||||
Rotate[1][1] = c + temp[1] * axis[1];
|
||||
Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0];
|
||||
|
||||
Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1];
|
||||
Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0];
|
||||
Rotate[2][2] = c + temp[2] * axis[2];
|
||||
|
||||
detail::tmat4x4<T, P> Result(detail::tmat4x4<T, P>::_null);
|
||||
Result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2];
|
||||
Result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2];
|
||||
Result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2];
|
||||
Result[3] = m[3];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> rotate_slow
|
||||
(
|
||||
detail::tmat4x4<T, P> const & m,
|
||||
T const & angle,
|
||||
detail::tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
T const a = angle;
|
||||
#else
|
||||
# pragma message("GLM: rotate_slow function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||
T const a = radians(angle);
|
||||
#endif
|
||||
T c = cos(a);
|
||||
T s = sin(a);
|
||||
detail::tmat4x4<T, P> Result;
|
||||
|
||||
detail::tvec3<T, P> axis = normalize(v);
|
||||
|
||||
Result[0][0] = c + (1 - c) * axis.x * axis.x;
|
||||
Result[0][1] = (1 - c) * axis.x * axis.y + s * axis.z;
|
||||
Result[0][2] = (1 - c) * axis.x * axis.z - s * axis.y;
|
||||
Result[0][3] = 0;
|
||||
|
||||
Result[1][0] = (1 - c) * axis.y * axis.x - s * axis.z;
|
||||
Result[1][1] = c + (1 - c) * axis.y * axis.y;
|
||||
Result[1][2] = (1 - c) * axis.y * axis.z + s * axis.x;
|
||||
Result[1][3] = 0;
|
||||
|
||||
Result[2][0] = (1 - c) * axis.z * axis.x + s * axis.y;
|
||||
Result[2][1] = (1 - c) * axis.z * axis.y - s * axis.x;
|
||||
Result[2][2] = c + (1 - c) * axis.z * axis.z;
|
||||
Result[2][3] = 0;
|
||||
|
||||
Result[3] = detail::tvec4<T, P>(0, 0, 0, 1);
|
||||
return m * Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> scale
|
||||
(
|
||||
detail::tmat4x4<T, P> const & m,
|
||||
detail::tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<T, P> Result(detail::tmat4x4<T, P>::_null);
|
||||
Result[0] = m[0] * v[0];
|
||||
Result[1] = m[1] * v[1];
|
||||
Result[2] = m[2] * v[2];
|
||||
Result[3] = m[3];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> scale_slow
|
||||
(
|
||||
detail::tmat4x4<T, P> const & m,
|
||||
detail::tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<T, P> Result(T(1));
|
||||
Result[0][0] = v.x;
|
||||
Result[1][1] = v.y;
|
||||
Result[2][2] = v.z;
|
||||
return m * Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> ortho
|
||||
(
|
||||
T const & left,
|
||||
T const & right,
|
||||
T const & bottom,
|
||||
T const & top,
|
||||
T const & zNear,
|
||||
T const & zFar
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<T, defaultp> Result(1);
|
||||
Result[0][0] = static_cast<T>(2) / (right - left);
|
||||
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
||||
Result[2][2] = - T(2) / (zFar - zNear);
|
||||
Result[3][0] = - (right + left) / (right - left);
|
||||
Result[3][1] = - (top + bottom) / (top - bottom);
|
||||
Result[3][2] = - (zFar + zNear) / (zFar - zNear);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> ortho
|
||||
(
|
||||
T const & left,
|
||||
T const & right,
|
||||
T const & bottom,
|
||||
T const & top
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<T, defaultp> Result(1);
|
||||
Result[0][0] = static_cast<T>(2) / (right - left);
|
||||
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
||||
Result[2][2] = - T(1);
|
||||
Result[3][0] = - (right + left) / (right - left);
|
||||
Result[3][1] = - (top + bottom) / (top - bottom);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> frustum
|
||||
(
|
||||
T const & left,
|
||||
T const & right,
|
||||
T const & bottom,
|
||||
T const & top,
|
||||
T const & nearVal,
|
||||
T const & farVal
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<T, defaultp> Result(0);
|
||||
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
|
||||
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
|
||||
Result[2][0] = (right + left) / (right - left);
|
||||
Result[2][1] = (top + bottom) / (top - bottom);
|
||||
Result[2][2] = -(farVal + nearVal) / (farVal - nearVal);
|
||||
Result[2][3] = static_cast<T>(-1);
|
||||
Result[3][2] = -(static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> perspective
|
||||
(
|
||||
T const & fovy,
|
||||
T const & aspect,
|
||||
T const & zNear,
|
||||
T const & zFar
|
||||
)
|
||||
{
|
||||
assert(aspect != static_cast<T>(0));
|
||||
assert(zFar != zNear);
|
||||
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
T const rad = fovy;
|
||||
#else
|
||||
# pragma message("GLM: perspective function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||
T const rad = glm::radians(fovy);
|
||||
#endif
|
||||
|
||||
T tanHalfFovy = tan(rad / static_cast<T>(2));
|
||||
|
||||
detail::tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
||||
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
||||
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
||||
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
||||
Result[2][3] = - static_cast<T>(1);
|
||||
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> perspectiveFov
|
||||
(
|
||||
T const & fov,
|
||||
T const & width,
|
||||
T const & height,
|
||||
T const & zNear,
|
||||
T const & zFar
|
||||
)
|
||||
{
|
||||
assert(width > static_cast<T>(0));
|
||||
assert(height > static_cast<T>(0));
|
||||
assert(fov > static_cast<T>(0));
|
||||
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
T rad = fov;
|
||||
#else
|
||||
# pragma message("GLM: perspectiveFov function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||
T rad = glm::radians(fov);
|
||||
#endif
|
||||
T h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
|
||||
T w = h * height / width; ///todo max(width , Height) / min(width , Height)?
|
||||
|
||||
detail::tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
||||
Result[0][0] = w;
|
||||
Result[1][1] = h;
|
||||
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
||||
Result[2][3] = - static_cast<T>(1);
|
||||
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> infinitePerspective
|
||||
(
|
||||
T fovy,
|
||||
T aspect,
|
||||
T zNear
|
||||
)
|
||||
{
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
T const range = tan(fovy / T(2)) * zNear;
|
||||
#else
|
||||
# pragma message("GLM: infinitePerspective function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||
T const range = tan(radians(fovy / T(2))) * zNear;
|
||||
#endif
|
||||
T left = -range * aspect;
|
||||
T right = range * aspect;
|
||||
T bottom = -range;
|
||||
T top = range;
|
||||
|
||||
detail::tmat4x4<T, defaultp> Result(T(0));
|
||||
Result[0][0] = (T(2) * zNear) / (right - left);
|
||||
Result[1][1] = (T(2) * zNear) / (top - bottom);
|
||||
Result[2][2] = - T(1);
|
||||
Result[2][3] = - T(1);
|
||||
Result[3][2] = - T(2) * zNear;
|
||||
return Result;
|
||||
}
|
||||
|
||||
// Infinite projection matrix: http://www.terathon.com/gdc07_lengyel.pdf
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> tweakedInfinitePerspective
|
||||
(
|
||||
T fovy,
|
||||
T aspect,
|
||||
T zNear,
|
||||
T ep
|
||||
)
|
||||
{
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
T range = tan(fovy / T(2)) * zNear;
|
||||
#else
|
||||
# pragma message("GLM: tweakedInfinitePerspective function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||
T range = tan(radians(fovy / T(2))) * zNear;
|
||||
#endif
|
||||
T left = -range * aspect;
|
||||
T right = range * aspect;
|
||||
T bottom = -range;
|
||||
T top = range;
|
||||
|
||||
detail::tmat4x4<T, defaultp> Result(T(0));
|
||||
Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
|
||||
Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
|
||||
Result[2][2] = ep - static_cast<T>(1);
|
||||
Result[2][3] = static_cast<T>(-1);
|
||||
Result[3][2] = (ep - static_cast<T>(2)) * zNear;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> tweakedInfinitePerspective
|
||||
(
|
||||
T fovy,
|
||||
T aspect,
|
||||
T zNear
|
||||
)
|
||||
{
|
||||
return tweakedInfinitePerspective(fovy, aspect, zNear, epsilon<T>());
|
||||
}
|
||||
|
||||
template <typename T, typename U, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T, P> project
|
||||
(
|
||||
detail::tvec3<T, P> const & obj,
|
||||
detail::tmat4x4<T, P> const & model,
|
||||
detail::tmat4x4<T, P> const & proj,
|
||||
detail::tvec4<U, P> const & viewport
|
||||
)
|
||||
{
|
||||
detail::tvec4<T, P> tmp = detail::tvec4<T, P>(obj, T(1));
|
||||
tmp = model * tmp;
|
||||
tmp = proj * tmp;
|
||||
|
||||
tmp /= tmp.w;
|
||||
tmp = tmp * T(0.5) + T(0.5);
|
||||
tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]);
|
||||
tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]);
|
||||
|
||||
return detail::tvec3<T, P>(tmp);
|
||||
}
|
||||
|
||||
template <typename T, typename U, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T, P> unProject
|
||||
(
|
||||
detail::tvec3<T, P> const & win,
|
||||
detail::tmat4x4<T, P> const & model,
|
||||
detail::tmat4x4<T, P> const & proj,
|
||||
detail::tvec4<U, P> const & viewport
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<T, P> Inverse = inverse(proj * model);
|
||||
|
||||
detail::tvec4<T, P> tmp = detail::tvec4<T, P>(win, T(1));
|
||||
tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]);
|
||||
tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]);
|
||||
tmp = tmp * T(2) - T(1);
|
||||
|
||||
detail::tvec4<T, P> obj = Inverse * tmp;
|
||||
obj /= obj.w;
|
||||
|
||||
return detail::tvec3<T, P>(obj);
|
||||
}
|
||||
|
||||
template <typename T, precision P, typename U>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> pickMatrix
|
||||
(
|
||||
detail::tvec2<T, P> const & center,
|
||||
detail::tvec2<T, P> const & delta,
|
||||
detail::tvec4<U, P> const & viewport
|
||||
)
|
||||
{
|
||||
assert(delta.x > T(0) && delta.y > T(0));
|
||||
detail::tmat4x4<T, P> Result(1.0f);
|
||||
|
||||
if(!(delta.x > T(0) && delta.y > T(0)))
|
||||
return Result; // Error
|
||||
|
||||
detail::tvec3<T, P> Temp(
|
||||
(T(viewport[2]) - T(2) * (center.x - T(viewport[0]))) / delta.x,
|
||||
(T(viewport[3]) - T(2) * (center.y - T(viewport[1]))) / delta.y,
|
||||
T(0));
|
||||
|
||||
// Translate and scale the picked region to the entire window
|
||||
Result = translate(Result, Temp);
|
||||
return scale(Result, detail::tvec3<T, P>(T(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1)));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> lookAt
|
||||
(
|
||||
detail::tvec3<T, P> const & eye,
|
||||
detail::tvec3<T, P> const & center,
|
||||
detail::tvec3<T, P> const & up
|
||||
)
|
||||
{
|
||||
detail::tvec3<T, P> f(normalize(center - eye));
|
||||
detail::tvec3<T, P> s(normalize(cross(f, up)));
|
||||
detail::tvec3<T, P> u(cross(s, f));
|
||||
|
||||
detail::tmat4x4<T, P> Result(1);
|
||||
Result[0][0] = s.x;
|
||||
Result[1][0] = s.y;
|
||||
Result[2][0] = s.z;
|
||||
Result[0][1] = u.x;
|
||||
Result[1][1] = u.y;
|
||||
Result[2][1] = u.z;
|
||||
Result[0][2] =-f.x;
|
||||
Result[1][2] =-f.y;
|
||||
Result[2][2] =-f.z;
|
||||
Result[3][0] =-dot(s, eye);
|
||||
Result[3][1] =-dot(u, eye);
|
||||
Result[3][2] = dot(f, eye);
|
||||
return Result;
|
||||
}
|
||||
}//namespace glm
|
||||
81
Research/inc/glm/gtc/noise.hpp
Normal file
81
Research/inc/glm/gtc/noise.hpp
Normal file
@@ -0,0 +1,81 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_noise
|
||||
/// @file glm/gtc/noise.hpp
|
||||
/// @date 2011-04-21 / 2011-09-27
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_noise GLM_GTC_noise
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// Defines 2D, 3D and 4D procedural noise functions
|
||||
/// Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise":
|
||||
/// https://github.com/ashima/webgl-noise
|
||||
/// Following Stefan Gustavson's paper "Simplex noise demystified":
|
||||
/// http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
|
||||
/// <glm/gtc/noise.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_noise
|
||||
#define GLM_GTC_noise
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/precision.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_noise extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_noise
|
||||
/// @{
|
||||
|
||||
/// Classic perlin noise.
|
||||
/// @see gtc_noise
|
||||
template <typename T, precision P, template<typename, precision> class vecType>
|
||||
GLM_FUNC_DECL T perlin(
|
||||
vecType<T, P> const & p);
|
||||
|
||||
/// Periodic perlin noise.
|
||||
/// @see gtc_noise
|
||||
template <typename T, precision P, template<typename, precision> class vecType>
|
||||
GLM_FUNC_DECL T perlin(
|
||||
vecType<T, P> const & p,
|
||||
vecType<T, P> const & rep);
|
||||
|
||||
/// Simplex noise.
|
||||
/// @see gtc_noise
|
||||
template <typename T, precision P, template<typename, precision> class vecType>
|
||||
GLM_FUNC_DECL T simplex(
|
||||
vecType<T, P> const & p);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "noise.inl"
|
||||
|
||||
#endif//GLM_GTC_noise
|
||||
838
Research/inc/glm/gtc/noise.inl
Normal file
838
Research/inc/glm/gtc/noise.inl
Normal file
@@ -0,0 +1,838 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_noise
|
||||
/// @file glm/gtc/noise.inl
|
||||
/// @date 2011-04-21 / 2012-04-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise":
|
||||
// https://github.com/ashima/webgl-noise
|
||||
// Following Stefan Gustavson's paper "Simplex noise demystified":
|
||||
// http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../geometric.hpp"
|
||||
#include "../common.hpp"
|
||||
#include "../vector_relational.hpp"
|
||||
#include "../detail/_noise.hpp"
|
||||
|
||||
namespace glm{
|
||||
namespace gtc
|
||||
{
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T, P> grad4(T const & j, detail::tvec4<T, P> const & ip)
|
||||
{
|
||||
detail::tvec3<T, P> pXYZ = floor(fract(detail::tvec3<T, P>(j) * detail::tvec3<T, P>(ip)) * T(7)) * ip[2] - T(1);
|
||||
T pW = static_cast<T>(1.5) - dot(abs(pXYZ), detail::tvec3<T, P>(1));
|
||||
detail::tvec4<T, P> s = detail::tvec4<T, P>(lessThan(detail::tvec4<T, P>(pXYZ, pW), detail::tvec4<T, P>(0.0)));
|
||||
pXYZ = pXYZ + (detail::tvec3<T, P>(s) * T(2) - T(1)) * s.w;
|
||||
return detail::tvec4<T, P>(pXYZ, pW);
|
||||
}
|
||||
}//namespace gtc
|
||||
|
||||
// Classic Perlin noise
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T perlin(detail::tvec2<T, P> const & Position)
|
||||
{
|
||||
detail::tvec4<T, P> Pi = glm::floor(detail::tvec4<T, P>(Position.x, Position.y, Position.x, Position.y)) + detail::tvec4<T, P>(0.0, 0.0, 1.0, 1.0);
|
||||
detail::tvec4<T, P> Pf = glm::fract(detail::tvec4<T, P>(Position.x, Position.y, Position.x, Position.y)) - detail::tvec4<T, P>(0.0, 0.0, 1.0, 1.0);
|
||||
Pi = mod(Pi, detail::tvec4<T, P>(289)); // To avoid truncation effects in permutation
|
||||
detail::tvec4<T, P> ix(Pi.x, Pi.z, Pi.x, Pi.z);
|
||||
detail::tvec4<T, P> iy(Pi.y, Pi.y, Pi.w, Pi.w);
|
||||
detail::tvec4<T, P> fx(Pf.x, Pf.z, Pf.x, Pf.z);
|
||||
detail::tvec4<T, P> fy(Pf.y, Pf.y, Pf.w, Pf.w);
|
||||
|
||||
detail::tvec4<T, P> i = detail::permute(detail::permute(ix) + iy);
|
||||
|
||||
detail::tvec4<T, P> gx = static_cast<T>(2) * glm::fract(i / T(41)) - T(1);
|
||||
detail::tvec4<T, P> gy = glm::abs(gx) - T(0.5);
|
||||
detail::tvec4<T, P> tx = glm::floor(gx + T(0.5));
|
||||
gx = gx - tx;
|
||||
|
||||
detail::tvec2<T, P> g00(gx.x, gy.x);
|
||||
detail::tvec2<T, P> g10(gx.y, gy.y);
|
||||
detail::tvec2<T, P> g01(gx.z, gy.z);
|
||||
detail::tvec2<T, P> g11(gx.w, gy.w);
|
||||
|
||||
detail::tvec4<T, P> norm = taylorInvSqrt(detail::tvec4<T, P>(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
|
||||
g00 *= norm.x;
|
||||
g01 *= norm.y;
|
||||
g10 *= norm.z;
|
||||
g11 *= norm.w;
|
||||
|
||||
T n00 = dot(g00, detail::tvec2<T, P>(fx.x, fy.x));
|
||||
T n10 = dot(g10, detail::tvec2<T, P>(fx.y, fy.y));
|
||||
T n01 = dot(g01, detail::tvec2<T, P>(fx.z, fy.z));
|
||||
T n11 = dot(g11, detail::tvec2<T, P>(fx.w, fy.w));
|
||||
|
||||
detail::tvec2<T, P> fade_xy = fade(detail::tvec2<T, P>(Pf.x, Pf.y));
|
||||
detail::tvec2<T, P> n_x = mix(detail::tvec2<T, P>(n00, n01), detail::tvec2<T, P>(n10, n11), fade_xy.x);
|
||||
T n_xy = mix(n_x.x, n_x.y, fade_xy.y);
|
||||
return T(2.3) * n_xy;
|
||||
}
|
||||
|
||||
// Classic Perlin noise
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T, P> const & Position)
|
||||
{
|
||||
detail::tvec3<T, P> Pi0 = floor(Position); // Integer part for indexing
|
||||
detail::tvec3<T, P> Pi1 = Pi0 + T(1); // Integer part + 1
|
||||
Pi0 = mod289(Pi0);
|
||||
Pi1 = mod289(Pi1);
|
||||
detail::tvec3<T, P> Pf0 = fract(Position); // Fractional part for interpolation
|
||||
detail::tvec3<T, P> Pf1 = Pf0 - T(1); // Fractional part - 1.0
|
||||
detail::tvec4<T, P> ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
|
||||
detail::tvec4<T, P> iy = detail::tvec4<T, P>(detail::tvec2<T, P>(Pi0.y), detail::tvec2<T, P>(Pi1.y));
|
||||
detail::tvec4<T, P> iz0(Pi0.z);
|
||||
detail::tvec4<T, P> iz1(Pi1.z);
|
||||
|
||||
detail::tvec4<T, P> ixy = detail::permute(detail::permute(ix) + iy);
|
||||
detail::tvec4<T, P> ixy0 = detail::permute(ixy + iz0);
|
||||
detail::tvec4<T, P> ixy1 = detail::permute(ixy + iz1);
|
||||
|
||||
detail::tvec4<T, P> gx0 = ixy0 * T(1.0 / 7.0);
|
||||
detail::tvec4<T, P> gy0 = fract(floor(gx0) * T(1.0 / 7.0)) - T(0.5);
|
||||
gx0 = fract(gx0);
|
||||
detail::tvec4<T, P> gz0 = detail::tvec4<T, P>(0.5) - abs(gx0) - abs(gy0);
|
||||
detail::tvec4<T, P> sz0 = step(gz0, detail::tvec4<T, P>(0.0));
|
||||
gx0 -= sz0 * (step(T(0), gx0) - T(0.5));
|
||||
gy0 -= sz0 * (step(T(0), gy0) - T(0.5));
|
||||
|
||||
detail::tvec4<T, P> gx1 = ixy1 * T(1.0 / 7.0);
|
||||
detail::tvec4<T, P> gy1 = fract(floor(gx1) * T(1.0 / 7.0)) - T(0.5);
|
||||
gx1 = fract(gx1);
|
||||
detail::tvec4<T, P> gz1 = detail::tvec4<T, P>(0.5) - abs(gx1) - abs(gy1);
|
||||
detail::tvec4<T, P> sz1 = step(gz1, detail::tvec4<T, P>(0.0));
|
||||
gx1 -= sz1 * (step(T(0), gx1) - T(0.5));
|
||||
gy1 -= sz1 * (step(T(0), gy1) - T(0.5));
|
||||
|
||||
detail::tvec3<T, P> g000(gx0.x, gy0.x, gz0.x);
|
||||
detail::tvec3<T, P> g100(gx0.y, gy0.y, gz0.y);
|
||||
detail::tvec3<T, P> g010(gx0.z, gy0.z, gz0.z);
|
||||
detail::tvec3<T, P> g110(gx0.w, gy0.w, gz0.w);
|
||||
detail::tvec3<T, P> g001(gx1.x, gy1.x, gz1.x);
|
||||
detail::tvec3<T, P> g101(gx1.y, gy1.y, gz1.y);
|
||||
detail::tvec3<T, P> g011(gx1.z, gy1.z, gz1.z);
|
||||
detail::tvec3<T, P> g111(gx1.w, gy1.w, gz1.w);
|
||||
|
||||
detail::tvec4<T, P> norm0 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
|
||||
g000 *= norm0.x;
|
||||
g010 *= norm0.y;
|
||||
g100 *= norm0.z;
|
||||
g110 *= norm0.w;
|
||||
detail::tvec4<T, P> norm1 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
|
||||
g001 *= norm1.x;
|
||||
g011 *= norm1.y;
|
||||
g101 *= norm1.z;
|
||||
g111 *= norm1.w;
|
||||
|
||||
T n000 = dot(g000, Pf0);
|
||||
T n100 = dot(g100, detail::tvec3<T, P>(Pf1.x, Pf0.y, Pf0.z));
|
||||
T n010 = dot(g010, detail::tvec3<T, P>(Pf0.x, Pf1.y, Pf0.z));
|
||||
T n110 = dot(g110, detail::tvec3<T, P>(Pf1.x, Pf1.y, Pf0.z));
|
||||
T n001 = dot(g001, detail::tvec3<T, P>(Pf0.x, Pf0.y, Pf1.z));
|
||||
T n101 = dot(g101, detail::tvec3<T, P>(Pf1.x, Pf0.y, Pf1.z));
|
||||
T n011 = dot(g011, detail::tvec3<T, P>(Pf0.x, Pf1.y, Pf1.z));
|
||||
T n111 = dot(g111, Pf1);
|
||||
|
||||
detail::tvec3<T, P> fade_xyz = fade(Pf0);
|
||||
detail::tvec4<T, P> n_z = mix(detail::tvec4<T, P>(n000, n100, n010, n110), detail::tvec4<T, P>(n001, n101, n011, n111), fade_xyz.z);
|
||||
detail::tvec2<T, P> n_yz = mix(detail::tvec2<T, P>(n_z.x, n_z.y), detail::tvec2<T, P>(n_z.z, n_z.w), fade_xyz.y);
|
||||
T n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
|
||||
return T(2.2) * n_xyz;
|
||||
}
|
||||
/*
|
||||
// Classic Perlin noise
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T, P> const & P)
|
||||
{
|
||||
detail::tvec3<T, P> Pi0 = floor(P); // Integer part for indexing
|
||||
detail::tvec3<T, P> Pi1 = Pi0 + T(1); // Integer part + 1
|
||||
Pi0 = mod(Pi0, T(289));
|
||||
Pi1 = mod(Pi1, T(289));
|
||||
detail::tvec3<T, P> Pf0 = fract(P); // Fractional part for interpolation
|
||||
detail::tvec3<T, P> Pf1 = Pf0 - T(1); // Fractional part - 1.0
|
||||
detail::tvec4<T, P> ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
|
||||
detail::tvec4<T, P> iy(Pi0.y, Pi0.y, Pi1.y, Pi1.y);
|
||||
detail::tvec4<T, P> iz0(Pi0.z);
|
||||
detail::tvec4<T, P> iz1(Pi1.z);
|
||||
|
||||
detail::tvec4<T, P> ixy = permute(permute(ix) + iy);
|
||||
detail::tvec4<T, P> ixy0 = permute(ixy + iz0);
|
||||
detail::tvec4<T, P> ixy1 = permute(ixy + iz1);
|
||||
|
||||
detail::tvec4<T, P> gx0 = ixy0 / T(7);
|
||||
detail::tvec4<T, P> gy0 = fract(floor(gx0) / T(7)) - T(0.5);
|
||||
gx0 = fract(gx0);
|
||||
detail::tvec4<T, P> gz0 = detail::tvec4<T, P>(0.5) - abs(gx0) - abs(gy0);
|
||||
detail::tvec4<T, P> sz0 = step(gz0, detail::tvec4<T, P>(0.0));
|
||||
gx0 -= sz0 * (step(0.0, gx0) - T(0.5));
|
||||
gy0 -= sz0 * (step(0.0, gy0) - T(0.5));
|
||||
|
||||
detail::tvec4<T, P> gx1 = ixy1 / T(7);
|
||||
detail::tvec4<T, P> gy1 = fract(floor(gx1) / T(7)) - T(0.5);
|
||||
gx1 = fract(gx1);
|
||||
detail::tvec4<T, P> gz1 = detail::tvec4<T, P>(0.5) - abs(gx1) - abs(gy1);
|
||||
detail::tvec4<T, P> sz1 = step(gz1, detail::tvec4<T, P>(0.0));
|
||||
gx1 -= sz1 * (step(T(0), gx1) - T(0.5));
|
||||
gy1 -= sz1 * (step(T(0), gy1) - T(0.5));
|
||||
|
||||
detail::tvec3<T, P> g000(gx0.x, gy0.x, gz0.x);
|
||||
detail::tvec3<T, P> g100(gx0.y, gy0.y, gz0.y);
|
||||
detail::tvec3<T, P> g010(gx0.z, gy0.z, gz0.z);
|
||||
detail::tvec3<T, P> g110(gx0.w, gy0.w, gz0.w);
|
||||
detail::tvec3<T, P> g001(gx1.x, gy1.x, gz1.x);
|
||||
detail::tvec3<T, P> g101(gx1.y, gy1.y, gz1.y);
|
||||
detail::tvec3<T, P> g011(gx1.z, gy1.z, gz1.z);
|
||||
detail::tvec3<T, P> g111(gx1.w, gy1.w, gz1.w);
|
||||
|
||||
detail::tvec4<T, P> norm0 = taylorInvSqrt(detail::tvec4<T, P>(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
|
||||
g000 *= norm0.x;
|
||||
g010 *= norm0.y;
|
||||
g100 *= norm0.z;
|
||||
g110 *= norm0.w;
|
||||
detail::tvec4<T, P> norm1 = taylorInvSqrt(detail::tvec4<T, P>(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
|
||||
g001 *= norm1.x;
|
||||
g011 *= norm1.y;
|
||||
g101 *= norm1.z;
|
||||
g111 *= norm1.w;
|
||||
|
||||
T n000 = dot(g000, Pf0);
|
||||
T n100 = dot(g100, detail::tvec3<T, P>(Pf1.x, Pf0.y, Pf0.z));
|
||||
T n010 = dot(g010, detail::tvec3<T, P>(Pf0.x, Pf1.y, Pf0.z));
|
||||
T n110 = dot(g110, detail::tvec3<T, P>(Pf1.x, Pf1.y, Pf0.z));
|
||||
T n001 = dot(g001, detail::tvec3<T, P>(Pf0.x, Pf0.y, Pf1.z));
|
||||
T n101 = dot(g101, detail::tvec3<T, P>(Pf1.x, Pf0.y, Pf1.z));
|
||||
T n011 = dot(g011, detail::tvec3<T, P>(Pf0.x, Pf1.y, Pf1.z));
|
||||
T n111 = dot(g111, Pf1);
|
||||
|
||||
detail::tvec3<T, P> fade_xyz = fade(Pf0);
|
||||
detail::tvec4<T, P> n_z = mix(detail::tvec4<T, P>(n000, n100, n010, n110), detail::tvec4<T, P>(n001, n101, n011, n111), fade_xyz.z);
|
||||
detail::tvec2<T, P> n_yz = mix(
|
||||
detail::tvec2<T, P>(n_z.x, n_z.y),
|
||||
detail::tvec2<T, P>(n_z.z, n_z.w), fade_xyz.y);
|
||||
T n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
|
||||
return T(2.2) * n_xyz;
|
||||
}
|
||||
*/
|
||||
// Classic Perlin noise
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T perlin(detail::tvec4<T, P> const & Position)
|
||||
{
|
||||
detail::tvec4<T, P> Pi0 = floor(Position); // Integer part for indexing
|
||||
detail::tvec4<T, P> Pi1 = Pi0 + T(1); // Integer part + 1
|
||||
Pi0 = mod(Pi0, detail::tvec4<T, P>(289));
|
||||
Pi1 = mod(Pi1, detail::tvec4<T, P>(289));
|
||||
detail::tvec4<T, P> Pf0 = fract(Position); // Fractional part for interpolation
|
||||
detail::tvec4<T, P> Pf1 = Pf0 - T(1); // Fractional part - 1.0
|
||||
detail::tvec4<T, P> ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
|
||||
detail::tvec4<T, P> iy(Pi0.y, Pi0.y, Pi1.y, Pi1.y);
|
||||
detail::tvec4<T, P> iz0(Pi0.z);
|
||||
detail::tvec4<T, P> iz1(Pi1.z);
|
||||
detail::tvec4<T, P> iw0(Pi0.w);
|
||||
detail::tvec4<T, P> iw1(Pi1.w);
|
||||
|
||||
detail::tvec4<T, P> ixy = detail::permute(detail::permute(ix) + iy);
|
||||
detail::tvec4<T, P> ixy0 = detail::permute(ixy + iz0);
|
||||
detail::tvec4<T, P> ixy1 = detail::permute(ixy + iz1);
|
||||
detail::tvec4<T, P> ixy00 = detail::permute(ixy0 + iw0);
|
||||
detail::tvec4<T, P> ixy01 = detail::permute(ixy0 + iw1);
|
||||
detail::tvec4<T, P> ixy10 = detail::permute(ixy1 + iw0);
|
||||
detail::tvec4<T, P> ixy11 = detail::permute(ixy1 + iw1);
|
||||
|
||||
detail::tvec4<T, P> gx00 = ixy00 / T(7);
|
||||
detail::tvec4<T, P> gy00 = floor(gx00) / T(7);
|
||||
detail::tvec4<T, P> gz00 = floor(gy00) / T(6);
|
||||
gx00 = fract(gx00) - T(0.5);
|
||||
gy00 = fract(gy00) - T(0.5);
|
||||
gz00 = fract(gz00) - T(0.5);
|
||||
detail::tvec4<T, P> gw00 = detail::tvec4<T, P>(0.75) - abs(gx00) - abs(gy00) - abs(gz00);
|
||||
detail::tvec4<T, P> sw00 = step(gw00, detail::tvec4<T, P>(0.0));
|
||||
gx00 -= sw00 * (step(T(0), gx00) - T(0.5));
|
||||
gy00 -= sw00 * (step(T(0), gy00) - T(0.5));
|
||||
|
||||
detail::tvec4<T, P> gx01 = ixy01 / T(7);
|
||||
detail::tvec4<T, P> gy01 = floor(gx01) / T(7);
|
||||
detail::tvec4<T, P> gz01 = floor(gy01) / T(6);
|
||||
gx01 = fract(gx01) - T(0.5);
|
||||
gy01 = fract(gy01) - T(0.5);
|
||||
gz01 = fract(gz01) - T(0.5);
|
||||
detail::tvec4<T, P> gw01 = detail::tvec4<T, P>(0.75) - abs(gx01) - abs(gy01) - abs(gz01);
|
||||
detail::tvec4<T, P> sw01 = step(gw01, detail::tvec4<T, P>(0.0));
|
||||
gx01 -= sw01 * (step(T(0), gx01) - T(0.5));
|
||||
gy01 -= sw01 * (step(T(0), gy01) - T(0.5));
|
||||
|
||||
detail::tvec4<T, P> gx10 = ixy10 / T(7);
|
||||
detail::tvec4<T, P> gy10 = floor(gx10) / T(7);
|
||||
detail::tvec4<T, P> gz10 = floor(gy10) / T(6);
|
||||
gx10 = fract(gx10) - T(0.5);
|
||||
gy10 = fract(gy10) - T(0.5);
|
||||
gz10 = fract(gz10) - T(0.5);
|
||||
detail::tvec4<T, P> gw10 = detail::tvec4<T, P>(0.75) - abs(gx10) - abs(gy10) - abs(gz10);
|
||||
detail::tvec4<T, P> sw10 = step(gw10, detail::tvec4<T, P>(0));
|
||||
gx10 -= sw10 * (step(T(0), gx10) - T(0.5));
|
||||
gy10 -= sw10 * (step(T(0), gy10) - T(0.5));
|
||||
|
||||
detail::tvec4<T, P> gx11 = ixy11 / T(7);
|
||||
detail::tvec4<T, P> gy11 = floor(gx11) / T(7);
|
||||
detail::tvec4<T, P> gz11 = floor(gy11) / T(6);
|
||||
gx11 = fract(gx11) - T(0.5);
|
||||
gy11 = fract(gy11) - T(0.5);
|
||||
gz11 = fract(gz11) - T(0.5);
|
||||
detail::tvec4<T, P> gw11 = detail::tvec4<T, P>(0.75) - abs(gx11) - abs(gy11) - abs(gz11);
|
||||
detail::tvec4<T, P> sw11 = step(gw11, detail::tvec4<T, P>(0.0));
|
||||
gx11 -= sw11 * (step(T(0), gx11) - T(0.5));
|
||||
gy11 -= sw11 * (step(T(0), gy11) - T(0.5));
|
||||
|
||||
detail::tvec4<T, P> g0000(gx00.x, gy00.x, gz00.x, gw00.x);
|
||||
detail::tvec4<T, P> g1000(gx00.y, gy00.y, gz00.y, gw00.y);
|
||||
detail::tvec4<T, P> g0100(gx00.z, gy00.z, gz00.z, gw00.z);
|
||||
detail::tvec4<T, P> g1100(gx00.w, gy00.w, gz00.w, gw00.w);
|
||||
detail::tvec4<T, P> g0010(gx10.x, gy10.x, gz10.x, gw10.x);
|
||||
detail::tvec4<T, P> g1010(gx10.y, gy10.y, gz10.y, gw10.y);
|
||||
detail::tvec4<T, P> g0110(gx10.z, gy10.z, gz10.z, gw10.z);
|
||||
detail::tvec4<T, P> g1110(gx10.w, gy10.w, gz10.w, gw10.w);
|
||||
detail::tvec4<T, P> g0001(gx01.x, gy01.x, gz01.x, gw01.x);
|
||||
detail::tvec4<T, P> g1001(gx01.y, gy01.y, gz01.y, gw01.y);
|
||||
detail::tvec4<T, P> g0101(gx01.z, gy01.z, gz01.z, gw01.z);
|
||||
detail::tvec4<T, P> g1101(gx01.w, gy01.w, gz01.w, gw01.w);
|
||||
detail::tvec4<T, P> g0011(gx11.x, gy11.x, gz11.x, gw11.x);
|
||||
detail::tvec4<T, P> g1011(gx11.y, gy11.y, gz11.y, gw11.y);
|
||||
detail::tvec4<T, P> g0111(gx11.z, gy11.z, gz11.z, gw11.z);
|
||||
detail::tvec4<T, P> g1111(gx11.w, gy11.w, gz11.w, gw11.w);
|
||||
|
||||
detail::tvec4<T, P> norm00 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100)));
|
||||
g0000 *= norm00.x;
|
||||
g0100 *= norm00.y;
|
||||
g1000 *= norm00.z;
|
||||
g1100 *= norm00.w;
|
||||
|
||||
detail::tvec4<T, P> norm01 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101)));
|
||||
g0001 *= norm01.x;
|
||||
g0101 *= norm01.y;
|
||||
g1001 *= norm01.z;
|
||||
g1101 *= norm01.w;
|
||||
|
||||
detail::tvec4<T, P> norm10 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110)));
|
||||
g0010 *= norm10.x;
|
||||
g0110 *= norm10.y;
|
||||
g1010 *= norm10.z;
|
||||
g1110 *= norm10.w;
|
||||
|
||||
detail::tvec4<T, P> norm11 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111)));
|
||||
g0011 *= norm11.x;
|
||||
g0111 *= norm11.y;
|
||||
g1011 *= norm11.z;
|
||||
g1111 *= norm11.w;
|
||||
|
||||
T n0000 = dot(g0000, Pf0);
|
||||
T n1000 = dot(g1000, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf0.z, Pf0.w));
|
||||
T n0100 = dot(g0100, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf0.z, Pf0.w));
|
||||
T n1100 = dot(g1100, detail::tvec4<T, P>(Pf1.x, Pf1.y, Pf0.z, Pf0.w));
|
||||
T n0010 = dot(g0010, detail::tvec4<T, P>(Pf0.x, Pf0.y, Pf1.z, Pf0.w));
|
||||
T n1010 = dot(g1010, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf1.z, Pf0.w));
|
||||
T n0110 = dot(g0110, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf1.z, Pf0.w));
|
||||
T n1110 = dot(g1110, detail::tvec4<T, P>(Pf1.x, Pf1.y, Pf1.z, Pf0.w));
|
||||
T n0001 = dot(g0001, detail::tvec4<T, P>(Pf0.x, Pf0.y, Pf0.z, Pf1.w));
|
||||
T n1001 = dot(g1001, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf0.z, Pf1.w));
|
||||
T n0101 = dot(g0101, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf0.z, Pf1.w));
|
||||
T n1101 = dot(g1101, detail::tvec4<T, P>(Pf1.x, Pf1.y, Pf0.z, Pf1.w));
|
||||
T n0011 = dot(g0011, detail::tvec4<T, P>(Pf0.x, Pf0.y, Pf1.z, Pf1.w));
|
||||
T n1011 = dot(g1011, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf1.z, Pf1.w));
|
||||
T n0111 = dot(g0111, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf1.z, Pf1.w));
|
||||
T n1111 = dot(g1111, Pf1);
|
||||
|
||||
detail::tvec4<T, P> fade_xyzw = fade(Pf0);
|
||||
detail::tvec4<T, P> n_0w = mix(detail::tvec4<T, P>(n0000, n1000, n0100, n1100), detail::tvec4<T, P>(n0001, n1001, n0101, n1101), fade_xyzw.w);
|
||||
detail::tvec4<T, P> n_1w = mix(detail::tvec4<T, P>(n0010, n1010, n0110, n1110), detail::tvec4<T, P>(n0011, n1011, n0111, n1111), fade_xyzw.w);
|
||||
detail::tvec4<T, P> n_zw = mix(n_0w, n_1w, fade_xyzw.z);
|
||||
detail::tvec2<T, P> n_yzw = mix(detail::tvec2<T, P>(n_zw.x, n_zw.y), detail::tvec2<T, P>(n_zw.z, n_zw.w), fade_xyzw.y);
|
||||
T n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x);
|
||||
return T(2.2) * n_xyzw;
|
||||
}
|
||||
|
||||
// Classic Perlin noise, periodic variant
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T perlin(detail::tvec2<T, P> const & Position, detail::tvec2<T, P> const & rep)
|
||||
{
|
||||
detail::tvec4<T, P> Pi = floor(detail::tvec4<T, P>(Position.x, Position.y, Position.x, Position.y)) + detail::tvec4<T, P>(0.0, 0.0, 1.0, 1.0);
|
||||
detail::tvec4<T, P> Pf = fract(detail::tvec4<T, P>(Position.x, Position.y, Position.x, Position.y)) - detail::tvec4<T, P>(0.0, 0.0, 1.0, 1.0);
|
||||
Pi = mod(Pi, detail::tvec4<T, P>(rep.x, rep.y, rep.x, rep.y)); // To create noise with explicit period
|
||||
Pi = mod(Pi, detail::tvec4<T, P>(289)); // To avoid truncation effects in permutation
|
||||
detail::tvec4<T, P> ix(Pi.x, Pi.z, Pi.x, Pi.z);
|
||||
detail::tvec4<T, P> iy(Pi.y, Pi.y, Pi.w, Pi.w);
|
||||
detail::tvec4<T, P> fx(Pf.x, Pf.z, Pf.x, Pf.z);
|
||||
detail::tvec4<T, P> fy(Pf.y, Pf.y, Pf.w, Pf.w);
|
||||
|
||||
detail::tvec4<T, P> i = detail::permute(detail::permute(ix) + iy);
|
||||
|
||||
detail::tvec4<T, P> gx = static_cast<T>(2) * fract(i / T(41)) - T(1);
|
||||
detail::tvec4<T, P> gy = abs(gx) - T(0.5);
|
||||
detail::tvec4<T, P> tx = floor(gx + T(0.5));
|
||||
gx = gx - tx;
|
||||
|
||||
detail::tvec2<T, P> g00(gx.x, gy.x);
|
||||
detail::tvec2<T, P> g10(gx.y, gy.y);
|
||||
detail::tvec2<T, P> g01(gx.z, gy.z);
|
||||
detail::tvec2<T, P> g11(gx.w, gy.w);
|
||||
|
||||
detail::tvec4<T, P> norm = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
|
||||
g00 *= norm.x;
|
||||
g01 *= norm.y;
|
||||
g10 *= norm.z;
|
||||
g11 *= norm.w;
|
||||
|
||||
T n00 = dot(g00, detail::tvec2<T, P>(fx.x, fy.x));
|
||||
T n10 = dot(g10, detail::tvec2<T, P>(fx.y, fy.y));
|
||||
T n01 = dot(g01, detail::tvec2<T, P>(fx.z, fy.z));
|
||||
T n11 = dot(g11, detail::tvec2<T, P>(fx.w, fy.w));
|
||||
|
||||
detail::tvec2<T, P> fade_xy = fade(detail::tvec2<T, P>(Pf.x, Pf.y));
|
||||
detail::tvec2<T, P> n_x = mix(detail::tvec2<T, P>(n00, n01), detail::tvec2<T, P>(n10, n11), fade_xy.x);
|
||||
T n_xy = mix(n_x.x, n_x.y, fade_xy.y);
|
||||
return T(2.3) * n_xy;
|
||||
}
|
||||
|
||||
// Classic Perlin noise, periodic variant
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T, P> const & Position, detail::tvec3<T, P> const & rep)
|
||||
{
|
||||
detail::tvec3<T, P> Pi0 = mod(floor(Position), rep); // Integer part, modulo period
|
||||
detail::tvec3<T, P> Pi1 = mod(Pi0 + detail::tvec3<T, P>(T(1)), rep); // Integer part + 1, mod period
|
||||
Pi0 = mod(Pi0, detail::tvec3<T, P>(289));
|
||||
Pi1 = mod(Pi1, detail::tvec3<T, P>(289));
|
||||
detail::tvec3<T, P> Pf0 = fract(Position); // Fractional part for interpolation
|
||||
detail::tvec3<T, P> Pf1 = Pf0 - detail::tvec3<T, P>(T(1)); // Fractional part - 1.0
|
||||
detail::tvec4<T, P> ix = detail::tvec4<T, P>(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
|
||||
detail::tvec4<T, P> iy = detail::tvec4<T, P>(Pi0.y, Pi0.y, Pi1.y, Pi1.y);
|
||||
detail::tvec4<T, P> iz0(Pi0.z);
|
||||
detail::tvec4<T, P> iz1(Pi1.z);
|
||||
|
||||
detail::tvec4<T, P> ixy = detail::permute(detail::permute(ix) + iy);
|
||||
detail::tvec4<T, P> ixy0 = detail::permute(ixy + iz0);
|
||||
detail::tvec4<T, P> ixy1 = detail::permute(ixy + iz1);
|
||||
|
||||
detail::tvec4<T, P> gx0 = ixy0 / T(7);
|
||||
detail::tvec4<T, P> gy0 = fract(floor(gx0) / T(7)) - T(0.5);
|
||||
gx0 = fract(gx0);
|
||||
detail::tvec4<T, P> gz0 = detail::tvec4<T, P>(0.5) - abs(gx0) - abs(gy0);
|
||||
detail::tvec4<T, P> sz0 = step(gz0, detail::tvec4<T, P>(0));
|
||||
gx0 -= sz0 * (step(T(0), gx0) - T(0.5));
|
||||
gy0 -= sz0 * (step(T(0), gy0) - T(0.5));
|
||||
|
||||
detail::tvec4<T, P> gx1 = ixy1 / T(7);
|
||||
detail::tvec4<T, P> gy1 = fract(floor(gx1) / T(7)) - T(0.5);
|
||||
gx1 = fract(gx1);
|
||||
detail::tvec4<T, P> gz1 = detail::tvec4<T, P>(0.5) - abs(gx1) - abs(gy1);
|
||||
detail::tvec4<T, P> sz1 = step(gz1, detail::tvec4<T, P>(T(0)));
|
||||
gx1 -= sz1 * (step(T(0), gx1) - T(0.5));
|
||||
gy1 -= sz1 * (step(T(0), gy1) - T(0.5));
|
||||
|
||||
detail::tvec3<T, P> g000 = detail::tvec3<T, P>(gx0.x, gy0.x, gz0.x);
|
||||
detail::tvec3<T, P> g100 = detail::tvec3<T, P>(gx0.y, gy0.y, gz0.y);
|
||||
detail::tvec3<T, P> g010 = detail::tvec3<T, P>(gx0.z, gy0.z, gz0.z);
|
||||
detail::tvec3<T, P> g110 = detail::tvec3<T, P>(gx0.w, gy0.w, gz0.w);
|
||||
detail::tvec3<T, P> g001 = detail::tvec3<T, P>(gx1.x, gy1.x, gz1.x);
|
||||
detail::tvec3<T, P> g101 = detail::tvec3<T, P>(gx1.y, gy1.y, gz1.y);
|
||||
detail::tvec3<T, P> g011 = detail::tvec3<T, P>(gx1.z, gy1.z, gz1.z);
|
||||
detail::tvec3<T, P> g111 = detail::tvec3<T, P>(gx1.w, gy1.w, gz1.w);
|
||||
|
||||
detail::tvec4<T, P> norm0 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
|
||||
g000 *= norm0.x;
|
||||
g010 *= norm0.y;
|
||||
g100 *= norm0.z;
|
||||
g110 *= norm0.w;
|
||||
detail::tvec4<T, P> norm1 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
|
||||
g001 *= norm1.x;
|
||||
g011 *= norm1.y;
|
||||
g101 *= norm1.z;
|
||||
g111 *= norm1.w;
|
||||
|
||||
T n000 = dot(g000, Pf0);
|
||||
T n100 = dot(g100, detail::tvec3<T, P>(Pf1.x, Pf0.y, Pf0.z));
|
||||
T n010 = dot(g010, detail::tvec3<T, P>(Pf0.x, Pf1.y, Pf0.z));
|
||||
T n110 = dot(g110, detail::tvec3<T, P>(Pf1.x, Pf1.y, Pf0.z));
|
||||
T n001 = dot(g001, detail::tvec3<T, P>(Pf0.x, Pf0.y, Pf1.z));
|
||||
T n101 = dot(g101, detail::tvec3<T, P>(Pf1.x, Pf0.y, Pf1.z));
|
||||
T n011 = dot(g011, detail::tvec3<T, P>(Pf0.x, Pf1.y, Pf1.z));
|
||||
T n111 = dot(g111, Pf1);
|
||||
|
||||
detail::tvec3<T, P> fade_xyz = fade(Pf0);
|
||||
detail::tvec4<T, P> n_z = mix(detail::tvec4<T, P>(n000, n100, n010, n110), detail::tvec4<T, P>(n001, n101, n011, n111), fade_xyz.z);
|
||||
detail::tvec2<T, P> n_yz = mix(detail::tvec2<T, P>(n_z.x, n_z.y), detail::tvec2<T, P>(n_z.z, n_z.w), fade_xyz.y);
|
||||
T n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
|
||||
return T(2.2) * n_xyz;
|
||||
}
|
||||
|
||||
// Classic Perlin noise, periodic version
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T perlin(detail::tvec4<T, P> const & Position, detail::tvec4<T, P> const & rep)
|
||||
{
|
||||
detail::tvec4<T, P> Pi0 = mod(floor(Position), rep); // Integer part modulo rep
|
||||
detail::tvec4<T, P> Pi1 = mod(Pi0 + T(1), rep); // Integer part + 1 mod rep
|
||||
detail::tvec4<T, P> Pf0 = fract(Position); // Fractional part for interpolation
|
||||
detail::tvec4<T, P> Pf1 = Pf0 - T(1); // Fractional part - 1.0
|
||||
detail::tvec4<T, P> ix = detail::tvec4<T, P>(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
|
||||
detail::tvec4<T, P> iy = detail::tvec4<T, P>(Pi0.y, Pi0.y, Pi1.y, Pi1.y);
|
||||
detail::tvec4<T, P> iz0(Pi0.z);
|
||||
detail::tvec4<T, P> iz1(Pi1.z);
|
||||
detail::tvec4<T, P> iw0(Pi0.w);
|
||||
detail::tvec4<T, P> iw1(Pi1.w);
|
||||
|
||||
detail::tvec4<T, P> ixy = detail::permute(detail::permute(ix) + iy);
|
||||
detail::tvec4<T, P> ixy0 = detail::permute(ixy + iz0);
|
||||
detail::tvec4<T, P> ixy1 = detail::permute(ixy + iz1);
|
||||
detail::tvec4<T, P> ixy00 = detail::permute(ixy0 + iw0);
|
||||
detail::tvec4<T, P> ixy01 = detail::permute(ixy0 + iw1);
|
||||
detail::tvec4<T, P> ixy10 = detail::permute(ixy1 + iw0);
|
||||
detail::tvec4<T, P> ixy11 = detail::permute(ixy1 + iw1);
|
||||
|
||||
detail::tvec4<T, P> gx00 = ixy00 / T(7);
|
||||
detail::tvec4<T, P> gy00 = floor(gx00) / T(7);
|
||||
detail::tvec4<T, P> gz00 = floor(gy00) / T(6);
|
||||
gx00 = fract(gx00) - T(0.5);
|
||||
gy00 = fract(gy00) - T(0.5);
|
||||
gz00 = fract(gz00) - T(0.5);
|
||||
detail::tvec4<T, P> gw00 = detail::tvec4<T, P>(0.75) - abs(gx00) - abs(gy00) - abs(gz00);
|
||||
detail::tvec4<T, P> sw00 = step(gw00, detail::tvec4<T, P>(0));
|
||||
gx00 -= sw00 * (step(T(0), gx00) - T(0.5));
|
||||
gy00 -= sw00 * (step(T(0), gy00) - T(0.5));
|
||||
|
||||
detail::tvec4<T, P> gx01 = ixy01 / T(7);
|
||||
detail::tvec4<T, P> gy01 = floor(gx01) / T(7);
|
||||
detail::tvec4<T, P> gz01 = floor(gy01) / T(6);
|
||||
gx01 = fract(gx01) - T(0.5);
|
||||
gy01 = fract(gy01) - T(0.5);
|
||||
gz01 = fract(gz01) - T(0.5);
|
||||
detail::tvec4<T, P> gw01 = detail::tvec4<T, P>(0.75) - abs(gx01) - abs(gy01) - abs(gz01);
|
||||
detail::tvec4<T, P> sw01 = step(gw01, detail::tvec4<T, P>(0.0));
|
||||
gx01 -= sw01 * (step(T(0), gx01) - T(0.5));
|
||||
gy01 -= sw01 * (step(T(0), gy01) - T(0.5));
|
||||
|
||||
detail::tvec4<T, P> gx10 = ixy10 / T(7);
|
||||
detail::tvec4<T, P> gy10 = floor(gx10) / T(7);
|
||||
detail::tvec4<T, P> gz10 = floor(gy10) / T(6);
|
||||
gx10 = fract(gx10) - T(0.5);
|
||||
gy10 = fract(gy10) - T(0.5);
|
||||
gz10 = fract(gz10) - T(0.5);
|
||||
detail::tvec4<T, P> gw10 = detail::tvec4<T, P>(0.75) - abs(gx10) - abs(gy10) - abs(gz10);
|
||||
detail::tvec4<T, P> sw10 = step(gw10, detail::tvec4<T, P>(0.0));
|
||||
gx10 -= sw10 * (step(T(0), gx10) - T(0.5));
|
||||
gy10 -= sw10 * (step(T(0), gy10) - T(0.5));
|
||||
|
||||
detail::tvec4<T, P> gx11 = ixy11 / T(7);
|
||||
detail::tvec4<T, P> gy11 = floor(gx11) / T(7);
|
||||
detail::tvec4<T, P> gz11 = floor(gy11) / T(6);
|
||||
gx11 = fract(gx11) - T(0.5);
|
||||
gy11 = fract(gy11) - T(0.5);
|
||||
gz11 = fract(gz11) - T(0.5);
|
||||
detail::tvec4<T, P> gw11 = detail::tvec4<T, P>(0.75) - abs(gx11) - abs(gy11) - abs(gz11);
|
||||
detail::tvec4<T, P> sw11 = step(gw11, detail::tvec4<T, P>(T(0)));
|
||||
gx11 -= sw11 * (step(T(0), gx11) - T(0.5));
|
||||
gy11 -= sw11 * (step(T(0), gy11) - T(0.5));
|
||||
|
||||
detail::tvec4<T, P> g0000(gx00.x, gy00.x, gz00.x, gw00.x);
|
||||
detail::tvec4<T, P> g1000(gx00.y, gy00.y, gz00.y, gw00.y);
|
||||
detail::tvec4<T, P> g0100(gx00.z, gy00.z, gz00.z, gw00.z);
|
||||
detail::tvec4<T, P> g1100(gx00.w, gy00.w, gz00.w, gw00.w);
|
||||
detail::tvec4<T, P> g0010(gx10.x, gy10.x, gz10.x, gw10.x);
|
||||
detail::tvec4<T, P> g1010(gx10.y, gy10.y, gz10.y, gw10.y);
|
||||
detail::tvec4<T, P> g0110(gx10.z, gy10.z, gz10.z, gw10.z);
|
||||
detail::tvec4<T, P> g1110(gx10.w, gy10.w, gz10.w, gw10.w);
|
||||
detail::tvec4<T, P> g0001(gx01.x, gy01.x, gz01.x, gw01.x);
|
||||
detail::tvec4<T, P> g1001(gx01.y, gy01.y, gz01.y, gw01.y);
|
||||
detail::tvec4<T, P> g0101(gx01.z, gy01.z, gz01.z, gw01.z);
|
||||
detail::tvec4<T, P> g1101(gx01.w, gy01.w, gz01.w, gw01.w);
|
||||
detail::tvec4<T, P> g0011(gx11.x, gy11.x, gz11.x, gw11.x);
|
||||
detail::tvec4<T, P> g1011(gx11.y, gy11.y, gz11.y, gw11.y);
|
||||
detail::tvec4<T, P> g0111(gx11.z, gy11.z, gz11.z, gw11.z);
|
||||
detail::tvec4<T, P> g1111(gx11.w, gy11.w, gz11.w, gw11.w);
|
||||
|
||||
detail::tvec4<T, P> norm00 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100)));
|
||||
g0000 *= norm00.x;
|
||||
g0100 *= norm00.y;
|
||||
g1000 *= norm00.z;
|
||||
g1100 *= norm00.w;
|
||||
|
||||
detail::tvec4<T, P> norm01 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101)));
|
||||
g0001 *= norm01.x;
|
||||
g0101 *= norm01.y;
|
||||
g1001 *= norm01.z;
|
||||
g1101 *= norm01.w;
|
||||
|
||||
detail::tvec4<T, P> norm10 = taylorInvSqrt(detail::tvec4<T, P>(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110)));
|
||||
g0010 *= norm10.x;
|
||||
g0110 *= norm10.y;
|
||||
g1010 *= norm10.z;
|
||||
g1110 *= norm10.w;
|
||||
|
||||
detail::tvec4<T, P> norm11 = taylorInvSqrt(detail::tvec4<T, P>(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111)));
|
||||
g0011 *= norm11.x;
|
||||
g0111 *= norm11.y;
|
||||
g1011 *= norm11.z;
|
||||
g1111 *= norm11.w;
|
||||
|
||||
T n0000 = dot(g0000, Pf0);
|
||||
T n1000 = dot(g1000, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf0.z, Pf0.w));
|
||||
T n0100 = dot(g0100, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf0.z, Pf0.w));
|
||||
T n1100 = dot(g1100, detail::tvec4<T, P>(Pf1.x, Pf1.y, Pf0.z, Pf0.w));
|
||||
T n0010 = dot(g0010, detail::tvec4<T, P>(Pf0.x, Pf0.y, Pf1.z, Pf0.w));
|
||||
T n1010 = dot(g1010, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf1.z, Pf0.w));
|
||||
T n0110 = dot(g0110, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf1.z, Pf0.w));
|
||||
T n1110 = dot(g1110, detail::tvec4<T, P>(Pf1.x, Pf1.y, Pf1.z, Pf0.w));
|
||||
T n0001 = dot(g0001, detail::tvec4<T, P>(Pf0.x, Pf0.y, Pf0.z, Pf1.w));
|
||||
T n1001 = dot(g1001, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf0.z, Pf1.w));
|
||||
T n0101 = dot(g0101, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf0.z, Pf1.w));
|
||||
T n1101 = dot(g1101, detail::tvec4<T, P>(Pf1.x, Pf1.y, Pf0.z, Pf1.w));
|
||||
T n0011 = dot(g0011, detail::tvec4<T, P>(Pf0.x, Pf0.y, Pf1.z, Pf1.w));
|
||||
T n1011 = dot(g1011, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf1.z, Pf1.w));
|
||||
T n0111 = dot(g0111, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf1.z, Pf1.w));
|
||||
T n1111 = dot(g1111, Pf1);
|
||||
|
||||
detail::tvec4<T, P> fade_xyzw = fade(Pf0);
|
||||
detail::tvec4<T, P> n_0w = mix(detail::tvec4<T, P>(n0000, n1000, n0100, n1100), detail::tvec4<T, P>(n0001, n1001, n0101, n1101), fade_xyzw.w);
|
||||
detail::tvec4<T, P> n_1w = mix(detail::tvec4<T, P>(n0010, n1010, n0110, n1110), detail::tvec4<T, P>(n0011, n1011, n0111, n1111), fade_xyzw.w);
|
||||
detail::tvec4<T, P> n_zw = mix(n_0w, n_1w, fade_xyzw.z);
|
||||
detail::tvec2<T, P> n_yzw = mix(detail::tvec2<T, P>(n_zw.x, n_zw.y), detail::tvec2<T, P>(n_zw.z, n_zw.w), fade_xyzw.y);
|
||||
T n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x);
|
||||
return T(2.2) * n_xyzw;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T simplex(glm::detail::tvec2<T, P> const & v)
|
||||
{
|
||||
detail::tvec4<T, P> const C = detail::tvec4<T, P>(
|
||||
T( 0.211324865405187), // (3.0 - sqrt(3.0)) / 6.0
|
||||
T( 0.366025403784439), // 0.5 * (sqrt(3.0) - 1.0)
|
||||
T(-0.577350269189626), // -1.0 + 2.0 * C.x
|
||||
T( 0.024390243902439)); // 1.0 / 41.0
|
||||
|
||||
// First corner
|
||||
detail::tvec2<T, P> i = floor(v + dot(v, detail::tvec2<T, P>(C[1])));
|
||||
detail::tvec2<T, P> x0 = v - i + dot(i, detail::tvec2<T, P>(C[0]));
|
||||
|
||||
// Other corners
|
||||
//i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
|
||||
//i1.y = 1.0 - i1.x;
|
||||
detail::tvec2<T, P> i1 = (x0.x > x0.y) ? detail::tvec2<T, P>(1, 0) : detail::tvec2<T, P>(0, 1);
|
||||
// x0 = x0 - 0.0 + 0.0 * C.xx ;
|
||||
// x1 = x0 - i1 + 1.0 * C.xx ;
|
||||
// x2 = x0 - 1.0 + 2.0 * C.xx ;
|
||||
detail::tvec4<T, P> x12 = detail::tvec4<T, P>(x0.x, x0.y, x0.x, x0.y) + detail::tvec4<T, P>(C.x, C.x, C.z, C.z);
|
||||
x12 = detail::tvec4<T, P>(detail::tvec2<T, P>(x12) - i1, x12.z, x12.w);
|
||||
|
||||
// Permutations
|
||||
i = mod(i, detail::tvec2<T, P>(289)); // Avoid truncation effects in permutation
|
||||
detail::tvec3<T, P> p = detail::permute(
|
||||
detail::permute(i.y + detail::tvec3<T, P>(T(0), i1.y, T(1)))
|
||||
+ i.x + detail::tvec3<T, P>(T(0), i1.x, T(1)));
|
||||
|
||||
detail::tvec3<T, P> m = max(detail::tvec3<T, P>(0.5) - detail::tvec3<T, P>(
|
||||
dot(x0, x0),
|
||||
dot(detail::tvec2<T, P>(x12.x, x12.y), detail::tvec2<T, P>(x12.x, x12.y)),
|
||||
dot(detail::tvec2<T, P>(x12.z, x12.w), detail::tvec2<T, P>(x12.z, x12.w))), detail::tvec3<T, P>(0));
|
||||
m = m * m ;
|
||||
m = m * m ;
|
||||
|
||||
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
|
||||
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
|
||||
|
||||
detail::tvec3<T, P> x = static_cast<T>(2) * fract(p * C.w) - T(1);
|
||||
detail::tvec3<T, P> h = abs(x) - T(0.5);
|
||||
detail::tvec3<T, P> ox = floor(x + T(0.5));
|
||||
detail::tvec3<T, P> a0 = x - ox;
|
||||
|
||||
// Normalise gradients implicitly by scaling m
|
||||
// Inlined for speed: m *= taylorInvSqrt( a0*a0 + h*h );
|
||||
m *= static_cast<T>(1.79284291400159) - T(0.85373472095314) * (a0 * a0 + h * h);
|
||||
|
||||
// Compute final noise value at P
|
||||
detail::tvec3<T, P> g;
|
||||
g.x = a0.x * x0.x + h.x * x0.y;
|
||||
//g.yz = a0.yz * x12.xz + h.yz * x12.yw;
|
||||
g.y = a0.y * x12.x + h.y * x12.y;
|
||||
g.z = a0.z * x12.z + h.z * x12.w;
|
||||
return T(130) * dot(m, g);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T simplex(detail::tvec3<T, P> const & v)
|
||||
{
|
||||
detail::tvec2<T, P> const C(1.0 / 6.0, 1.0 / 3.0);
|
||||
detail::tvec4<T, P> const D(0.0, 0.5, 1.0, 2.0);
|
||||
|
||||
// First corner
|
||||
detail::tvec3<T, P> i(floor(v + dot(v, detail::tvec3<T, P>(C.y))));
|
||||
detail::tvec3<T, P> x0(v - i + dot(i, detail::tvec3<T, P>(C.x)));
|
||||
|
||||
// Other corners
|
||||
detail::tvec3<T, P> g(step(detail::tvec3<T, P>(x0.y, x0.z, x0.x), x0));
|
||||
detail::tvec3<T, P> l(T(1) - g);
|
||||
detail::tvec3<T, P> i1(min(g, detail::tvec3<T, P>(l.z, l.x, l.y)));
|
||||
detail::tvec3<T, P> i2(max(g, detail::tvec3<T, P>(l.z, l.x, l.y)));
|
||||
|
||||
// x0 = x0 - 0.0 + 0.0 * C.xxx;
|
||||
// x1 = x0 - i1 + 1.0 * C.xxx;
|
||||
// x2 = x0 - i2 + 2.0 * C.xxx;
|
||||
// x3 = x0 - 1.0 + 3.0 * C.xxx;
|
||||
detail::tvec3<T, P> x1(x0 - i1 + C.x);
|
||||
detail::tvec3<T, P> x2(x0 - i2 + C.y); // 2.0*C.x = 1/3 = C.y
|
||||
detail::tvec3<T, P> x3(x0 - D.y); // -1.0+3.0*C.x = -0.5 = -D.y
|
||||
|
||||
// Permutations
|
||||
i = mod289(i);
|
||||
detail::tvec4<T, P> p(detail::permute(detail::permute(detail::permute(
|
||||
i.z + detail::tvec4<T, P>(T(0), i1.z, i2.z, T(1))) +
|
||||
i.y + detail::tvec4<T, P>(T(0), i1.y, i2.y, T(1))) +
|
||||
i.x + detail::tvec4<T, P>(T(0), i1.x, i2.x, T(1))));
|
||||
|
||||
// Gradients: 7x7 points over a square, mapped onto an octahedron.
|
||||
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
|
||||
T n_ = static_cast<T>(0.142857142857); // 1.0/7.0
|
||||
detail::tvec3<T, P> ns(n_ * detail::tvec3<T, P>(D.w, D.y, D.z) - detail::tvec3<T, P>(D.x, D.z, D.x));
|
||||
|
||||
detail::tvec4<T, P> j(p - T(49) * floor(p * ns.z * ns.z)); // mod(p,7*7)
|
||||
|
||||
detail::tvec4<T, P> x_(floor(j * ns.z));
|
||||
detail::tvec4<T, P> y_(floor(j - T(7) * x_)); // mod(j,N)
|
||||
|
||||
detail::tvec4<T, P> x(x_ * ns.x + ns.y);
|
||||
detail::tvec4<T, P> y(y_ * ns.x + ns.y);
|
||||
detail::tvec4<T, P> h(T(1) - abs(x) - abs(y));
|
||||
|
||||
detail::tvec4<T, P> b0(x.x, x.y, y.x, y.y);
|
||||
detail::tvec4<T, P> b1(x.z, x.w, y.z, y.w);
|
||||
|
||||
// vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;
|
||||
// vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;
|
||||
detail::tvec4<T, P> s0(floor(b0) * T(2) + T(1));
|
||||
detail::tvec4<T, P> s1(floor(b1) * T(2) + T(1));
|
||||
detail::tvec4<T, P> sh(-step(h, detail::tvec4<T, P>(0.0)));
|
||||
|
||||
detail::tvec4<T, P> a0 = detail::tvec4<T, P>(b0.x, b0.z, b0.y, b0.w) + detail::tvec4<T, P>(s0.x, s0.z, s0.y, s0.w) * detail::tvec4<T, P>(sh.x, sh.x, sh.y, sh.y);
|
||||
detail::tvec4<T, P> a1 = detail::tvec4<T, P>(b1.x, b1.z, b1.y, b1.w) + detail::tvec4<T, P>(s1.x, s1.z, s1.y, s1.w) * detail::tvec4<T, P>(sh.z, sh.z, sh.w, sh.w);
|
||||
|
||||
detail::tvec3<T, P> p0(a0.x, a0.y, h.x);
|
||||
detail::tvec3<T, P> p1(a0.z, a0.w, h.y);
|
||||
detail::tvec3<T, P> p2(a1.x, a1.y, h.z);
|
||||
detail::tvec3<T, P> p3(a1.z, a1.w, h.w);
|
||||
|
||||
// Normalise gradients
|
||||
detail::tvec4<T, P> norm = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));
|
||||
p0 *= norm.x;
|
||||
p1 *= norm.y;
|
||||
p2 *= norm.z;
|
||||
p3 *= norm.w;
|
||||
|
||||
// Mix final noise value
|
||||
detail::tvec4<T, P> m = max(T(0.6) - detail::tvec4<T, P>(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), detail::tvec4<T, P>(0));
|
||||
m = m * m;
|
||||
return T(42) * dot(m * m, detail::tvec4<T, P>(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T simplex(detail::tvec4<T, P> const & v)
|
||||
{
|
||||
detail::tvec4<T, P> const C(
|
||||
0.138196601125011, // (5 - sqrt(5))/20 G4
|
||||
0.276393202250021, // 2 * G4
|
||||
0.414589803375032, // 3 * G4
|
||||
-0.447213595499958); // -1 + 4 * G4
|
||||
|
||||
// (sqrt(5) - 1)/4 = F4, used once below
|
||||
T const F4 = static_cast<T>(0.309016994374947451);
|
||||
|
||||
// First corner
|
||||
detail::tvec4<T, P> i = floor(v + dot(v, vec4(F4)));
|
||||
detail::tvec4<T, P> x0 = v - i + dot(i, vec4(C.x));
|
||||
|
||||
// Other corners
|
||||
|
||||
// Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI)
|
||||
detail::tvec4<T, P> i0;
|
||||
detail::tvec3<T, P> isX = step(detail::tvec3<T, P>(x0.y, x0.z, x0.w), detail::tvec3<T, P>(x0.x));
|
||||
detail::tvec3<T, P> isYZ = step(detail::tvec3<T, P>(x0.z, x0.w, x0.w), detail::tvec3<T, P>(x0.y, x0.y, x0.z));
|
||||
// i0.x = dot(isX, vec3(1.0));
|
||||
//i0.x = isX.x + isX.y + isX.z;
|
||||
//i0.yzw = static_cast<T>(1) - isX;
|
||||
i0 = detail::tvec4<T, P>(isX.x + isX.y + isX.z, T(1) - isX);
|
||||
// i0.y += dot(isYZ.xy, vec2(1.0));
|
||||
i0.y += isYZ.x + isYZ.y;
|
||||
//i0.zw += 1.0 - detail::tvec2<T, P>(isYZ.x, isYZ.y);
|
||||
i0.z += static_cast<T>(1) - isYZ.x;
|
||||
i0.w += static_cast<T>(1) - isYZ.y;
|
||||
i0.z += isYZ.z;
|
||||
i0.w += static_cast<T>(1) - isYZ.z;
|
||||
|
||||
// i0 now contains the unique values 0,1,2,3 in each channel
|
||||
detail::tvec4<T, P> i3 = clamp(i0, T(0), T(1));
|
||||
detail::tvec4<T, P> i2 = clamp(i0 - T(1), T(0), T(1));
|
||||
detail::tvec4<T, P> i1 = clamp(i0 - T(2), T(0), T(1));
|
||||
|
||||
// x0 = x0 - 0.0 + 0.0 * C.xxxx
|
||||
// x1 = x0 - i1 + 0.0 * C.xxxx
|
||||
// x2 = x0 - i2 + 0.0 * C.xxxx
|
||||
// x3 = x0 - i3 + 0.0 * C.xxxx
|
||||
// x4 = x0 - 1.0 + 4.0 * C.xxxx
|
||||
detail::tvec4<T, P> x1 = x0 - i1 + C.x;
|
||||
detail::tvec4<T, P> x2 = x0 - i2 + C.y;
|
||||
detail::tvec4<T, P> x3 = x0 - i3 + C.z;
|
||||
detail::tvec4<T, P> x4 = x0 + C.w;
|
||||
|
||||
// Permutations
|
||||
i = mod(i, detail::tvec4<T, P>(289));
|
||||
T j0 = detail::permute(detail::permute(detail::permute(detail::permute(i.w) + i.z) + i.y) + i.x);
|
||||
detail::tvec4<T, P> j1 = detail::permute(detail::permute(detail::permute(detail::permute(
|
||||
i.w + detail::tvec4<T, P>(i1.w, i2.w, i3.w, T(1))) +
|
||||
i.z + detail::tvec4<T, P>(i1.z, i2.z, i3.z, T(1))) +
|
||||
i.y + detail::tvec4<T, P>(i1.y, i2.y, i3.y, T(1))) +
|
||||
i.x + detail::tvec4<T, P>(i1.x, i2.x, i3.x, T(1)));
|
||||
|
||||
// Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope
|
||||
// 7*7*6 = 294, which is close to the ring size 17*17 = 289.
|
||||
detail::tvec4<T, P> ip = detail::tvec4<T, P>(T(1) / T(294), T(1) / T(49), T(1) / T(7), T(0));
|
||||
|
||||
detail::tvec4<T, P> p0 = gtc::grad4(j0, ip);
|
||||
detail::tvec4<T, P> p1 = gtc::grad4(j1.x, ip);
|
||||
detail::tvec4<T, P> p2 = gtc::grad4(j1.y, ip);
|
||||
detail::tvec4<T, P> p3 = gtc::grad4(j1.z, ip);
|
||||
detail::tvec4<T, P> p4 = gtc::grad4(j1.w, ip);
|
||||
|
||||
// Normalise gradients
|
||||
detail::tvec4<T, P> norm = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));
|
||||
p0 *= norm.x;
|
||||
p1 *= norm.y;
|
||||
p2 *= norm.z;
|
||||
p3 *= norm.w;
|
||||
p4 *= detail::taylorInvSqrt(dot(p4, p4));
|
||||
|
||||
// Mix contributions from the five corners
|
||||
detail::tvec3<T, P> m0 = max(T(0.6) - detail::tvec3<T, P>(dot(x0, x0), dot(x1, x1), dot(x2, x2)), detail::tvec3<T, P>(0));
|
||||
detail::tvec2<T, P> m1 = max(T(0.6) - detail::tvec2<T, P>(dot(x3, x3), dot(x4, x4) ), detail::tvec2<T, P>(0));
|
||||
m0 = m0 * m0;
|
||||
m1 = m1 * m1;
|
||||
return T(49) *
|
||||
(dot(m0 * m0, detail::tvec3<T, P>(dot(p0, x0), dot(p1, x1), dot(p2, x2))) +
|
||||
dot(m1 * m1, detail::tvec2<T, P>(dot(p3, x3), dot(p4, x4))));
|
||||
}
|
||||
}//namespace glm
|
||||
478
Research/inc/glm/gtc/packing.hpp
Normal file
478
Research/inc/glm/gtc/packing.hpp
Normal file
@@ -0,0 +1,478 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_packing
|
||||
/// @file glm/gtc/packing.hpp
|
||||
/// @date 2013-08-08 / 2013-08-08
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_packing GLM_GTC_packing
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief This extension provides a set of function to convert vertors to packed
|
||||
/// formats.
|
||||
///
|
||||
/// <glm/gtc/packing.hpp> need to be included to use these features.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_packing
|
||||
#define GLM_GTC_packing
|
||||
|
||||
// Dependency:
|
||||
#include "type_precision.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_packing extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_packing
|
||||
/// @{
|
||||
|
||||
/// First, converts the normalized floating-point value v into a 8-bit integer value.
|
||||
/// Then, the results are packed into the returned 8-bit unsigned integer.
|
||||
///
|
||||
/// The conversion for component c of v to fixed point is done as follows:
|
||||
/// packUnorm1x8: round(clamp(c, 0, +1) * 255.0)
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packUnorm2x8(vec2 const & v)
|
||||
/// @see uint32 packUnorm4x8(vec4 const & v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint8 packUnorm1x8(float v);
|
||||
|
||||
/// Convert a single 8-bit integer to a normalized floating-point value.
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackUnorm4x8: f / 255.0
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec2 unpackUnorm2x8(uint16 p)
|
||||
/// @see vec4 unpackUnorm4x8(uint32 p)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL float unpackUnorm1x8(uint8 p);
|
||||
|
||||
/// First, converts each component of the normalized floating-point value v into 8-bit integer values.
|
||||
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
||||
///
|
||||
/// The conversion for component c of v to fixed point is done as follows:
|
||||
/// packUnorm2x8: round(clamp(c, 0, +1) * 255.0)
|
||||
///
|
||||
/// The first component of the vector will be written to the least significant bits of the output;
|
||||
/// the last component will be written to the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint8 packUnorm1x8(float const & v)
|
||||
/// @see uint32 packUnorm4x8(vec4 const & v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint16 packUnorm2x8(vec2 const & v);
|
||||
|
||||
/// First, unpacks a single 16-bit unsigned integer p into a pair of 8-bit unsigned integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned two-component vector.
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackUnorm4x8: f / 255.0
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see float unpackUnorm1x8(uint8 v)
|
||||
/// @see vec4 unpackUnorm4x8(uint32 p)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL vec2 unpackUnorm2x8(uint16 p);
|
||||
|
||||
/// First, converts the normalized floating-point value v into 8-bit integer value.
|
||||
/// Then, the results are packed into the returned 8-bit unsigned integer.
|
||||
///
|
||||
/// The conversion to fixed point is done as follows:
|
||||
/// packSnorm1x8: round(clamp(s, -1, +1) * 127.0)
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packSnorm2x8(vec2 const & v)
|
||||
/// @see uint32 packSnorm4x8(vec4 const & v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint8 packSnorm1x8(float s);
|
||||
|
||||
/// First, unpacks a single 8-bit unsigned integer p into a single 8-bit signed integers.
|
||||
/// Then, the value is converted to a normalized floating-point value to generate the returned scalar.
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackSnorm1x8: clamp(f / 127.0, -1, +1)
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec2 unpackSnorm2x8(uint16 p)
|
||||
/// @see vec4 unpackSnorm4x8(uint32 p)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL float unpackSnorm1x8(uint8 p);
|
||||
|
||||
/// First, converts each component of the normalized floating-point value v into 8-bit integer values.
|
||||
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
||||
///
|
||||
/// The conversion for component c of v to fixed point is done as follows:
|
||||
/// packSnorm2x8: round(clamp(c, -1, +1) * 127.0)
|
||||
///
|
||||
/// The first component of the vector will be written to the least significant bits of the output;
|
||||
/// the last component will be written to the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint8 packSnorm1x8(float const & v)
|
||||
/// @see uint32 packSnorm4x8(vec4 const & v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint16 packSnorm2x8(vec2 const & v);
|
||||
|
||||
/// First, unpacks a single 16-bit unsigned integer p into a pair of 8-bit signed integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned two-component vector.
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackSnorm2x8: clamp(f / 127.0, -1, +1)
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see float unpackSnorm1x8(uint8 p)
|
||||
/// @see vec4 unpackSnorm4x8(uint32 p)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL vec2 unpackSnorm2x8(uint16 p);
|
||||
|
||||
/// First, converts the normalized floating-point value v into a 16-bit integer value.
|
||||
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
||||
///
|
||||
/// The conversion for component c of v to fixed point is done as follows:
|
||||
/// packUnorm1x16: round(clamp(c, 0, +1) * 65535.0)
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packSnorm1x16(float const & v)
|
||||
/// @see uint64 packSnorm4x16(vec4 const & v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint16 packUnorm1x16(float v);
|
||||
|
||||
/// First, unpacks a single 16-bit unsigned integer p into a of 16-bit unsigned integers.
|
||||
/// Then, the value is converted to a normalized floating-point value to generate the returned scalar.
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackUnorm1x16: f / 65535.0
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec2 unpackUnorm2x16(uint32 p)
|
||||
/// @see vec4 unpackUnorm4x16(uint64 p)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL float unpackUnorm1x16(uint16 p);
|
||||
|
||||
/// First, converts each component of the normalized floating-point value v into 16-bit integer values.
|
||||
/// Then, the results are packed into the returned 64-bit unsigned integer.
|
||||
///
|
||||
/// The conversion for component c of v to fixed point is done as follows:
|
||||
/// packUnorm4x16: round(clamp(c, 0, +1) * 65535.0)
|
||||
///
|
||||
/// The first component of the vector will be written to the least significant bits of the output;
|
||||
/// the last component will be written to the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packUnorm1x16(float const & v)
|
||||
/// @see uint32 packUnorm2x16(vec2 const & v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint64 packUnorm4x16(vec4 const & v);
|
||||
|
||||
/// First, unpacks a single 64-bit unsigned integer p into four 16-bit unsigned integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackUnormx4x16: f / 65535.0
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see float unpackUnorm1x16(uint16 p)
|
||||
/// @see vec2 unpackUnorm2x16(uint32 p)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL vec4 unpackUnorm4x16(uint64 p);
|
||||
|
||||
/// First, converts the normalized floating-point value v into 16-bit integer value.
|
||||
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
||||
///
|
||||
/// The conversion to fixed point is done as follows:
|
||||
/// packSnorm1x8: round(clamp(s, -1, +1) * 32767.0)
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packSnorm2x16(vec2 const & v)
|
||||
/// @see uint64 packSnorm4x16(vec4 const & v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint16 packSnorm1x16(float v);
|
||||
|
||||
/// First, unpacks a single 16-bit unsigned integer p into a single 16-bit signed integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned scalar.
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackSnorm1x16: clamp(f / 32767.0, -1, +1)
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec2 unpackSnorm2x16(uint32 p)
|
||||
/// @see vec4 unpackSnorm4x16(uint64 p)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm1x16.xml">GLSL unpackSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL float unpackSnorm1x16(uint16 p);
|
||||
|
||||
/// First, converts each component of the normalized floating-point value v into 16-bit integer values.
|
||||
/// Then, the results are packed into the returned 64-bit unsigned integer.
|
||||
///
|
||||
/// The conversion for component c of v to fixed point is done as follows:
|
||||
/// packSnorm2x8: round(clamp(c, -1, +1) * 32767.0)
|
||||
///
|
||||
/// The first component of the vector will be written to the least significant bits of the output;
|
||||
/// the last component will be written to the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packSnorm1x16(float const & v)
|
||||
/// @see uint32 packSnorm2x16(vec2 const & v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint64 packSnorm4x16(vec4 const & v);
|
||||
|
||||
/// First, unpacks a single 64-bit unsigned integer p into four 16-bit signed integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackSnorm4x16: clamp(f / 32767.0, -1, +1)
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see float unpackSnorm1x16(uint16 p)
|
||||
/// @see vec2 unpackSnorm2x16(uint32 p)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm2x16.xml">GLSL unpackSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL vec4 unpackSnorm4x16(uint64 const & p);
|
||||
|
||||
/// Returns an unsigned integer obtained by converting the components of a floating-point scalar
|
||||
/// to the 16-bit floating-point representation found in the OpenGL Specification,
|
||||
/// and then packing this 16-bit value into a 16-bit unsigned integer.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packHalf2x16(vec2 const & v)
|
||||
/// @see uint64 packHalf4x16(vec4 const & v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packHalf2x16.xml">GLSL packHalf2x16 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint16 packHalf1x16(float v);
|
||||
|
||||
/// Returns a floating-point scalar with components obtained by unpacking a 16-bit unsigned integer into a 16-bit value,
|
||||
/// interpreted as a 16-bit floating-point number according to the OpenGL Specification,
|
||||
/// and converting it to 32-bit floating-point values.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec2 unpackHalf2x16(uint32 const & v)
|
||||
/// @see vec4 unpackHalf4x16(uint64 const & v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackHalf2x16.xml">GLSL unpackHalf2x16 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL float unpackHalf1x16(uint16 v);
|
||||
|
||||
/// Returns an unsigned integer obtained by converting the components of a four-component floating-point vector
|
||||
/// to the 16-bit floating-point representation found in the OpenGL Specification,
|
||||
/// and then packing these four 16-bit values into a 64-bit unsigned integer.
|
||||
/// The first vector component specifies the 16 least-significant bits of the result;
|
||||
/// the forth component specifies the 16 most-significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packHalf1x16(float const & v)
|
||||
/// @see uint32 packHalf2x16(vec2 const & v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packHalf2x16.xml">GLSL packHalf2x16 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint64 packHalf4x16(vec4 const & v);
|
||||
|
||||
/// Returns a four-component floating-point vector with components obtained by unpacking a 64-bit unsigned integer into four 16-bit values,
|
||||
/// interpreting those values as 16-bit floating-point numbers according to the OpenGL Specification,
|
||||
/// and converting them to 32-bit floating-point values.
|
||||
/// The first component of the vector is obtained from the 16 least-significant bits of v;
|
||||
/// the forth component is obtained from the 16 most-significant bits of v.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see float unpackHalf1x16(uint16 const & v)
|
||||
/// @see vec2 unpackHalf2x16(uint32 const & v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackHalf2x16.xml">GLSL unpackHalf2x16 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL vec4 unpackHalf4x16(uint64 p);
|
||||
|
||||
/// Returns an unsigned integer obtained by converting the components of a four-component signed integer vector
|
||||
/// to the 10-10-10-2-bit signed integer representation found in the OpenGL Specification,
|
||||
/// and then packing these four values into a 32-bit unsigned integer.
|
||||
/// The first vector component specifies the 10 least-significant bits of the result;
|
||||
/// the forth component specifies the 2 most-significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packI3x10_1x2(uvec4 const & v)
|
||||
/// @see uint32 packSnorm3x10_1x2(vec4 const & v)
|
||||
/// @see uint32 packUnorm3x10_1x2(vec4 const & v)
|
||||
/// @see ivec4 unpackI3x10_1x2(uint32 const & p)
|
||||
GLM_FUNC_DECL uint32 packI3x10_1x2(ivec4 const & v);
|
||||
|
||||
/// Unpacks a single 32-bit unsigned integer p into three 10-bit and one 2-bit signed integers.
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packU3x10_1x2(uvec4 const & v)
|
||||
/// @see vec4 unpackSnorm3x10_1x2(uint32 const & p);
|
||||
/// @see uvec4 unpackI3x10_1x2(uint32 const & p);
|
||||
GLM_FUNC_DECL ivec4 unpackI3x10_1x2(uint32 p);
|
||||
|
||||
/// Returns an unsigned integer obtained by converting the components of a four-component unsigned integer vector
|
||||
/// to the 10-10-10-2-bit unsigned integer representation found in the OpenGL Specification,
|
||||
/// and then packing these four values into a 32-bit unsigned integer.
|
||||
/// The first vector component specifies the 10 least-significant bits of the result;
|
||||
/// the forth component specifies the 2 most-significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packI3x10_1x2(ivec4 const & v)
|
||||
/// @see uint32 packSnorm3x10_1x2(vec4 const & v)
|
||||
/// @see uint32 packUnorm3x10_1x2(vec4 const & v)
|
||||
/// @see ivec4 unpackU3x10_1x2(uint32 const & p)
|
||||
GLM_FUNC_DECL uint32 packU3x10_1x2(uvec4 const & v);
|
||||
|
||||
/// Unpacks a single 32-bit unsigned integer p into three 10-bit and one 2-bit unsigned integers.
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packU3x10_1x2(uvec4 const & v)
|
||||
/// @see vec4 unpackSnorm3x10_1x2(uint32 const & p);
|
||||
/// @see uvec4 unpackI3x10_1x2(uint32 const & p);
|
||||
GLM_FUNC_DECL uvec4 unpackU3x10_1x2(uint32 p);
|
||||
|
||||
/// First, converts the first three components of the normalized floating-point value v into 10-bit signed integer values.
|
||||
/// Then, converts the forth component of the normalized floating-point value v into 2-bit signed integer values.
|
||||
/// Then, the results are packed into the returned 32-bit unsigned integer.
|
||||
///
|
||||
/// The conversion for component c of v to fixed point is done as follows:
|
||||
/// packSnorm3x10_1x2(xyz): round(clamp(c, -1, +1) * 511.0)
|
||||
/// packSnorm3x10_1x2(w): round(clamp(c, -1, +1) * 1.0)
|
||||
///
|
||||
/// The first vector component specifies the 10 least-significant bits of the result;
|
||||
/// the forth component specifies the 2 most-significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec4 unpackSnorm3x10_1x2(uint32 const & p)
|
||||
/// @see uint32 packUnorm3x10_1x2(vec4 const & v)
|
||||
/// @see uint32 packU3x10_1x2(uvec4 const & v)
|
||||
/// @see uint32 packI3x10_1x2(ivec4 const & v)
|
||||
GLM_FUNC_DECL uint32 packSnorm3x10_1x2(vec4 const & v);
|
||||
|
||||
/// First, unpacks a single 32-bit unsigned integer p into four 16-bit signed integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackSnorm3x10_1x2(xyz): clamp(f / 511.0, -1, +1)
|
||||
/// unpackSnorm3x10_1x2(w): clamp(f / 511.0, -1, +1)
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packSnorm3x10_1x2(vec4 const & v)
|
||||
/// @see vec4 unpackUnorm3x10_1x2(uint32 const & p))
|
||||
/// @see uvec4 unpackI3x10_1x2(uint32 const & p)
|
||||
/// @see uvec4 unpackU3x10_1x2(uint32 const & p)
|
||||
GLM_FUNC_DECL vec4 unpackSnorm3x10_1x2(uint32 p);
|
||||
|
||||
/// First, converts the first three components of the normalized floating-point value v into 10-bit unsigned integer values.
|
||||
/// Then, converts the forth component of the normalized floating-point value v into 2-bit signed uninteger values.
|
||||
/// Then, the results are packed into the returned 32-bit unsigned integer.
|
||||
///
|
||||
/// The conversion for component c of v to fixed point is done as follows:
|
||||
/// packUnorm3x10_1x2(xyz): round(clamp(c, 0, +1) * 1023.0)
|
||||
/// packUnorm3x10_1x2(w): round(clamp(c, 0, +1) * 3.0)
|
||||
///
|
||||
/// The first vector component specifies the 10 least-significant bits of the result;
|
||||
/// the forth component specifies the 2 most-significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec4 unpackUnorm3x10_1x2(uint32 const & p)
|
||||
/// @see uint32 packUnorm3x10_1x2(vec4 const & v)
|
||||
/// @see uint32 packU3x10_1x2(uvec4 const & v)
|
||||
/// @see uint32 packI3x10_1x2(ivec4 const & v)
|
||||
GLM_FUNC_DECL uint32 packUnorm3x10_1x2(vec4 const & v);
|
||||
|
||||
/// First, unpacks a single 32-bit unsigned integer p into four 16-bit signed integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackSnorm3x10_1x2(xyz): clamp(f / 1023.0, 0, +1)
|
||||
/// unpackSnorm3x10_1x2(w): clamp(f / 3.0, 0, +1)
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packSnorm3x10_1x2(vec4 const & v)
|
||||
/// @see vec4 unpackInorm3x10_1x2(uint32 const & p))
|
||||
/// @see uvec4 unpackI3x10_1x2(uint32 const & p)
|
||||
/// @see uvec4 unpackU3x10_1x2(uint32 const & p)
|
||||
GLM_FUNC_DECL vec4 unpackUnorm3x10_1x2(uint32 p);
|
||||
|
||||
/// First, converts the first two components of the normalized floating-point value v into 11-bit signless floating-point values.
|
||||
/// Then, converts the third component of the normalized floating-point value v into a 10-bit signless floating-point value.
|
||||
/// Then, the results are packed into the returned 32-bit unsigned integer.
|
||||
///
|
||||
/// The first vector component specifies the 11 least-significant bits of the result;
|
||||
/// the last component specifies the 10 most-significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec3 unpackF2x11_1x10(uint32 const & p)
|
||||
GLM_FUNC_DECL uint32 packF2x11_1x10(vec3 const & v);
|
||||
|
||||
/// First, unpacks a single 32-bit unsigned integer p into two 11-bit signless floating-point values and one 10-bit signless floating-point value .
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned three-component vector.
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packF2x11_1x10(vec3 const & v)
|
||||
GLM_FUNC_DECL vec3 unpackF2x11_1x10(uint32 p);
|
||||
|
||||
/// @}
|
||||
}// namespace glm
|
||||
|
||||
#include "packing.inl"
|
||||
|
||||
#endif//GLM_GTC_packing
|
||||
|
||||
496
Research/inc/glm/gtc/packing.inl
Normal file
496
Research/inc/glm/gtc/packing.inl
Normal file
@@ -0,0 +1,496 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_packing
|
||||
/// @file glm/gtc/packing.inl
|
||||
/// @date 2013-08-08 / 2013-08-08
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../common.hpp"
|
||||
#include "../vec2.hpp"
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
#include "../detail/type_half.hpp"
|
||||
#include <cstring>
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
GLM_FUNC_QUALIFIER glm::uint16 float2half(glm::uint32 f)
|
||||
{
|
||||
// 10 bits => EE EEEFFFFF
|
||||
// 11 bits => EEE EEFFFFFF
|
||||
// Half bits => SEEEEEFF FFFFFFFF
|
||||
// Float bits => SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF
|
||||
|
||||
// 0x00007c00 => 00000000 00000000 01111100 00000000
|
||||
// 0x000003ff => 00000000 00000000 00000011 11111111
|
||||
// 0x38000000 => 00111000 00000000 00000000 00000000
|
||||
// 0x7f800000 => 01111111 10000000 00000000 00000000
|
||||
// 0x00008000 => 00000000 00000000 10000000 00000000
|
||||
return
|
||||
((f >> 16) & 0x8000) | // sign
|
||||
((((f & 0x7f800000) - 0x38000000) >> 13) & 0x7c00) | // exponential
|
||||
((f >> 13) & 0x03ff); // Mantissa
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::uint32 float2packed11(glm::uint32 f)
|
||||
{
|
||||
// 10 bits => EE EEEFFFFF
|
||||
// 11 bits => EEE EEFFFFFF
|
||||
// Half bits => SEEEEEFF FFFFFFFF
|
||||
// Float bits => SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF
|
||||
|
||||
// 0x000007c0 => 00000000 00000000 00000111 11000000
|
||||
// 0x00007c00 => 00000000 00000000 01111100 00000000
|
||||
// 0x000003ff => 00000000 00000000 00000011 11111111
|
||||
// 0x38000000 => 00111000 00000000 00000000 00000000
|
||||
// 0x7f800000 => 01111111 10000000 00000000 00000000
|
||||
// 0x00008000 => 00000000 00000000 10000000 00000000
|
||||
return
|
||||
((((f & 0x7f800000) - 0x38000000) >> 17) & 0x07c0) | // exponential
|
||||
((f >> 17) & 0x003f); // Mantissa
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::uint32 packed11ToFloat(glm::uint32 p)
|
||||
{
|
||||
// 10 bits => EE EEEFFFFF
|
||||
// 11 bits => EEE EEFFFFFF
|
||||
// Half bits => SEEEEEFF FFFFFFFF
|
||||
// Float bits => SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF
|
||||
|
||||
// 0x000007c0 => 00000000 00000000 00000111 11000000
|
||||
// 0x00007c00 => 00000000 00000000 01111100 00000000
|
||||
// 0x000003ff => 00000000 00000000 00000011 11111111
|
||||
// 0x38000000 => 00111000 00000000 00000000 00000000
|
||||
// 0x7f800000 => 01111111 10000000 00000000 00000000
|
||||
// 0x00008000 => 00000000 00000000 10000000 00000000
|
||||
return
|
||||
((((p & 0x07c0) << 17) + 0x38000000) & 0x7f800000) | // exponential
|
||||
((p & 0x003f) << 17); // Mantissa
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::uint32 float2packed10(glm::uint32 f)
|
||||
{
|
||||
// 10 bits => EE EEEFFFFF
|
||||
// 11 bits => EEE EEFFFFFF
|
||||
// Half bits => SEEEEEFF FFFFFFFF
|
||||
// Float bits => SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF
|
||||
|
||||
// 0x0000001F => 00000000 00000000 00000000 00011111
|
||||
// 0x0000003F => 00000000 00000000 00000000 00111111
|
||||
// 0x000003E0 => 00000000 00000000 00000011 11100000
|
||||
// 0x000007C0 => 00000000 00000000 00000111 11000000
|
||||
// 0x00007C00 => 00000000 00000000 01111100 00000000
|
||||
// 0x000003FF => 00000000 00000000 00000011 11111111
|
||||
// 0x38000000 => 00111000 00000000 00000000 00000000
|
||||
// 0x7f800000 => 01111111 10000000 00000000 00000000
|
||||
// 0x00008000 => 00000000 00000000 10000000 00000000
|
||||
return
|
||||
((((f & 0x7f800000) - 0x38000000) >> 18) & 0x03E0) | // exponential
|
||||
((f >> 18) & 0x001f); // Mantissa
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::uint32 packed10ToFloat(glm::uint32 p)
|
||||
{
|
||||
// 10 bits => EE EEEFFFFF
|
||||
// 11 bits => EEE EEFFFFFF
|
||||
// Half bits => SEEEEEFF FFFFFFFF
|
||||
// Float bits => SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF
|
||||
|
||||
// 0x0000001F => 00000000 00000000 00000000 00011111
|
||||
// 0x0000003F => 00000000 00000000 00000000 00111111
|
||||
// 0x000003E0 => 00000000 00000000 00000011 11100000
|
||||
// 0x000007C0 => 00000000 00000000 00000111 11000000
|
||||
// 0x00007C00 => 00000000 00000000 01111100 00000000
|
||||
// 0x000003FF => 00000000 00000000 00000011 11111111
|
||||
// 0x38000000 => 00111000 00000000 00000000 00000000
|
||||
// 0x7f800000 => 01111111 10000000 00000000 00000000
|
||||
// 0x00008000 => 00000000 00000000 10000000 00000000
|
||||
return
|
||||
((((p & 0x03E0) << 18) + 0x38000000) & 0x7f800000) | // exponential
|
||||
((p & 0x001f) << 18); // Mantissa
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::uint half2float(glm::uint h)
|
||||
{
|
||||
return ((h & 0x8000) << 16) | ((( h & 0x7c00) + 0x1C000) << 13) | ((h & 0x03FF) << 13);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::uint floatTo11bit(float x)
|
||||
{
|
||||
if(x == 0.0f)
|
||||
return 0;
|
||||
else if(glm::isnan(x))
|
||||
return ~0;
|
||||
else if(glm::isinf(x))
|
||||
return 0x1f << 6;
|
||||
|
||||
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG)
|
||||
uint Pack = 0;
|
||||
memcpy(&Pack, &x, sizeof(Pack));
|
||||
# else
|
||||
uint Pack = reinterpret_cast<uint&>(x);
|
||||
# endif
|
||||
|
||||
return float2packed11(Pack);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float packed11bitToFloat(glm::uint x)
|
||||
{
|
||||
if(x == 0)
|
||||
return 0.0f;
|
||||
else if(x == ((1 << 11) - 1))
|
||||
return ~0;//NaN
|
||||
else if(x == (0x1f << 6))
|
||||
return ~0;//Inf
|
||||
|
||||
uint Result = packed11ToFloat(x);
|
||||
|
||||
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG)
|
||||
float Temp = 0;
|
||||
memcpy(&Temp, &Result, sizeof(Temp));
|
||||
return Temp;
|
||||
# else
|
||||
return reinterpret_cast<float&>(Result);
|
||||
# endif
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::uint floatTo10bit(float x)
|
||||
{
|
||||
if(x == 0.0f)
|
||||
return 0;
|
||||
else if(glm::isnan(x))
|
||||
return ~0;
|
||||
else if(glm::isinf(x))
|
||||
return 0x1f << 5;
|
||||
|
||||
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG)
|
||||
uint Pack = 0;
|
||||
memcpy(&Pack, &x, sizeof(Pack));
|
||||
# else
|
||||
uint Pack = reinterpret_cast<uint&>(x);
|
||||
# endif
|
||||
|
||||
return float2packed10(Pack);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float packed10bitToFloat(glm::uint x)
|
||||
{
|
||||
if(x == 0)
|
||||
return 0.0f;
|
||||
else if(x == ((1 << 10) - 1))
|
||||
return ~0;//NaN
|
||||
else if(x == (0x1f << 5))
|
||||
return ~0;//Inf
|
||||
|
||||
uint Result = packed10ToFloat(x);
|
||||
|
||||
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG)
|
||||
float Temp = 0;
|
||||
memcpy(&Temp, &Result, sizeof(Temp));
|
||||
return Temp;
|
||||
# else
|
||||
return reinterpret_cast<float&>(Result);
|
||||
# endif
|
||||
}
|
||||
|
||||
// GLM_FUNC_QUALIFIER glm::uint f11_f11_f10(float x, float y, float z)
|
||||
// {
|
||||
// return ((floatTo11bit(x) & ((1 << 11) - 1)) << 0) | ((floatTo11bit(y) & ((1 << 11) - 1)) << 11) | ((floatTo10bit(z) & ((1 << 10) - 1)) << 22);
|
||||
// }
|
||||
|
||||
union u10u10u10u2
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint x : 10;
|
||||
uint y : 10;
|
||||
uint z : 10;
|
||||
uint w : 2;
|
||||
} data;
|
||||
uint32 pack;
|
||||
};
|
||||
|
||||
union i10i10i10i2
|
||||
{
|
||||
struct
|
||||
{
|
||||
int x : 10;
|
||||
int y : 10;
|
||||
int z : 10;
|
||||
int w : 2;
|
||||
} data;
|
||||
uint32 pack;
|
||||
};
|
||||
|
||||
}//namespace detail
|
||||
|
||||
GLM_FUNC_QUALIFIER uint8 packUnorm1x8(float v)
|
||||
{
|
||||
return static_cast<uint8>(round(clamp(v, 0.0f, 1.0f) * 255.0f));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float unpackUnorm1x8(uint8 p)
|
||||
{
|
||||
float Unpack(static_cast<float>(p));
|
||||
return Unpack * static_cast<float>(0.0039215686274509803921568627451); // 1 / 255
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packUnorm2x8(vec2 const & v)
|
||||
{
|
||||
u8vec2 Topack(round(clamp(v, 0.0f, 1.0f) * 255.0f));
|
||||
uint16* Packed = reinterpret_cast<uint16*>(&Topack);
|
||||
return *Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec2 unpackUnorm2x8(uint16 p)
|
||||
{
|
||||
u8vec2* Unpacked = reinterpret_cast<u8vec2*>(const_cast<uint16*>(&p));
|
||||
return vec2(*Unpacked) * float(0.0039215686274509803921568627451); // 1 / 255
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint8 packSnorm1x8(float v)
|
||||
{
|
||||
int8 Topack(static_cast<int8>(round(clamp(v ,-1.0f, 1.0f) * 127.0f)));
|
||||
uint8* Packed = reinterpret_cast<uint8*>(&Topack);
|
||||
return *Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float unpackSnorm1x8(uint8 p)
|
||||
{
|
||||
float Unpack(static_cast<float>(*const_cast<uint8*>(&p)));
|
||||
return clamp(
|
||||
Unpack * 0.00787401574803149606299212598425f, // 1.0f / 127.0f
|
||||
-1.0f, 1.0f);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packSnorm2x8(vec2 const & v)
|
||||
{
|
||||
i8vec2 Topack(round(clamp(v ,-1.0f, 1.0f) * 127.0f));
|
||||
uint16* Packed = reinterpret_cast<uint16*>(&Topack);
|
||||
return *Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec2 unpackSnorm2x8(uint16 p)
|
||||
{
|
||||
i8vec2* Unpack = reinterpret_cast<i8vec2*>(const_cast<uint16*>(&p));
|
||||
return clamp(
|
||||
vec2(*Unpack) * 0.00787401574803149606299212598425f, // 1.0f / 127.0f
|
||||
-1.0f, 1.0f);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packUnorm1x16(float s)
|
||||
{
|
||||
return static_cast<uint16>(round(clamp(s, 0.0f, 1.0f) * 65535.0f));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float unpackUnorm1x16(uint16 p)
|
||||
{
|
||||
float Unpack = static_cast<float>(*const_cast<uint16*>(&p));
|
||||
return Unpack * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint64 packUnorm4x16(vec4 const & v)
|
||||
{
|
||||
u16vec4 Topack(round(clamp(v , 0.0f, 1.0f) * 65535.0f));
|
||||
uint64* Packed = reinterpret_cast<uint64*>(&Topack);
|
||||
return *Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec4 unpackUnorm4x16(uint64 p)
|
||||
{
|
||||
u16vec4* Unpack = reinterpret_cast<u16vec4*>(const_cast<uint64*>(&p));
|
||||
return vec4(*Unpack) * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packSnorm1x16(float v)
|
||||
{
|
||||
int16 Topack = static_cast<int16>(round(clamp(v ,-1.0f, 1.0f) * 32767.0f));
|
||||
uint16* Packed = reinterpret_cast<uint16*>(&Topack);
|
||||
return *Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float unpackSnorm1x16(uint16 p)
|
||||
{
|
||||
float Unpack = static_cast<float>(*const_cast<uint16*>(&p));
|
||||
return clamp(
|
||||
Unpack * 3.0518509475997192297128208258309e-5f, //1.0f / 32767.0f,
|
||||
-1.0f, 1.0f);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint64 packSnorm4x16(vec4 const & v)
|
||||
{
|
||||
i16vec4 Topack = static_cast<i16vec4>(round(clamp(v ,-1.0f, 1.0f) * 32767.0f));
|
||||
uint64* Packed = reinterpret_cast<uint64*>(&Topack);
|
||||
return *Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec4 unpackSnorm4x16(uint64 p)
|
||||
{
|
||||
i16vec4* Unpack(reinterpret_cast<i16vec4*>(const_cast<uint64*>(&p)));
|
||||
return clamp(
|
||||
vec4(*Unpack) * 3.0518509475997192297128208258309e-5f, //1.0f / 32767.0f,
|
||||
-1.0f, 1.0f);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packHalf1x16(float v)
|
||||
{
|
||||
int16 Topack = detail::toFloat16(v);
|
||||
uint16* Packed = reinterpret_cast<uint16*>(&Topack);
|
||||
return *Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float unpackHalf1x16(uint16 v)
|
||||
{
|
||||
int16* Unpack = reinterpret_cast<int16*>(const_cast<uint16*>(&v));
|
||||
return detail::toFloat32(*Unpack);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint64 packHalf4x16(glm::vec4 const & v)
|
||||
{
|
||||
i16vec4 Unpack(
|
||||
detail::toFloat16(v.x),
|
||||
detail::toFloat16(v.y),
|
||||
detail::toFloat16(v.z),
|
||||
detail::toFloat16(v.w));
|
||||
|
||||
uint64* Packed = reinterpret_cast<uint64*>(&Unpack);
|
||||
return *Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::vec4 unpackHalf4x16(uint64 v)
|
||||
{
|
||||
i16vec4* p = reinterpret_cast<i16vec4*>(const_cast<uint64*>(&v));
|
||||
i16vec4 Unpack(*p);
|
||||
|
||||
return vec4(
|
||||
detail::toFloat32(Unpack.x),
|
||||
detail::toFloat32(Unpack.y),
|
||||
detail::toFloat32(Unpack.z),
|
||||
detail::toFloat32(Unpack.w));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 packI3x10_1x2(ivec4 const & v)
|
||||
{
|
||||
detail::i10i10i10i2 Result;
|
||||
Result.data.x = v.x;
|
||||
Result.data.y = v.y;
|
||||
Result.data.z = v.z;
|
||||
Result.data.w = v.w;
|
||||
return Result.pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER ivec4 unpackI3x10_1x2(uint32 v)
|
||||
{
|
||||
detail::i10i10i10i2 Unpack;
|
||||
Unpack.pack = v;
|
||||
return ivec4(
|
||||
Unpack.data.x,
|
||||
Unpack.data.y,
|
||||
Unpack.data.z,
|
||||
Unpack.data.w);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 packU3x10_1x2(uvec4 const & v)
|
||||
{
|
||||
detail::u10u10u10u2 Result;
|
||||
Result.data.x = v.x;
|
||||
Result.data.y = v.y;
|
||||
Result.data.z = v.z;
|
||||
Result.data.w = v.w;
|
||||
return Result.pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uvec4 unpackU3x10_1x2(uint32 v)
|
||||
{
|
||||
detail::u10u10u10u2 Unpack;
|
||||
Unpack.pack = v;
|
||||
return uvec4(
|
||||
Unpack.data.x,
|
||||
Unpack.data.y,
|
||||
Unpack.data.z,
|
||||
Unpack.data.w);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 packSnorm3x10_1x2(vec4 const & v)
|
||||
{
|
||||
detail::i10i10i10i2 Result;
|
||||
Result.data.x = int(round(clamp(v.x,-1.0f, 1.0f) * 511.f));
|
||||
Result.data.y = int(round(clamp(v.y,-1.0f, 1.0f) * 511.f));
|
||||
Result.data.z = int(round(clamp(v.z,-1.0f, 1.0f) * 511.f));
|
||||
Result.data.w = int(round(clamp(v.w,-1.0f, 1.0f) * 1.f));
|
||||
return Result.pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec4 unpackSnorm3x10_1x2(uint32 v)
|
||||
{
|
||||
detail::i10i10i10i2 Unpack;
|
||||
Unpack.pack = v;
|
||||
vec4 Result;
|
||||
Result.x = clamp(float(Unpack.data.x) / 511.f, -1.0f, 1.0f);
|
||||
Result.y = clamp(float(Unpack.data.y) / 511.f, -1.0f, 1.0f);
|
||||
Result.z = clamp(float(Unpack.data.z) / 511.f, -1.0f, 1.0f);
|
||||
Result.w = clamp(float(Unpack.data.w) / 1.f, -1.0f, 1.0f);
|
||||
return Result;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 packUnorm3x10_1x2(vec4 const & v)
|
||||
{
|
||||
detail::i10i10i10i2 Result;
|
||||
Result.data.x = int(round(clamp(v.x, 0.0f, 1.0f) * 1023.f));
|
||||
Result.data.y = int(round(clamp(v.y, 0.0f, 1.0f) * 1023.f));
|
||||
Result.data.z = int(round(clamp(v.z, 0.0f, 1.0f) * 1023.f));
|
||||
Result.data.w = int(round(clamp(v.w, 0.0f, 1.0f) * 3.f));
|
||||
return Result.pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec4 unpackUnorm3x10_1x2(uint32 v)
|
||||
{
|
||||
detail::i10i10i10i2 Unpack;
|
||||
Unpack.pack = v;
|
||||
vec4 Result;
|
||||
Result.x = float(Unpack.data.x) / 1023.f;
|
||||
Result.y = float(Unpack.data.y) / 1023.f;
|
||||
Result.z = float(Unpack.data.z) / 1023.f;
|
||||
Result.w = float(Unpack.data.w) / 3.f;
|
||||
return Result;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 packF2x11_1x10(vec3 const & v)
|
||||
{
|
||||
return
|
||||
((detail::floatTo11bit(v.x) & ((1 << 11) - 1)) << 0) |
|
||||
((detail::floatTo11bit(v.y) & ((1 << 11) - 1)) << 11) |
|
||||
((detail::floatTo10bit(v.z) & ((1 << 10) - 1)) << 22);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec3 unpackF2x11_1x10(uint32 v)
|
||||
{
|
||||
return vec3(
|
||||
detail::packed11bitToFloat(v >> 0),
|
||||
detail::packed11bitToFloat(v >> 11),
|
||||
detail::packed10bitToFloat(v >> 22));
|
||||
}
|
||||
|
||||
}//namespace glm
|
||||
404
Research/inc/glm/gtc/quaternion.hpp
Normal file
404
Research/inc/glm/gtc/quaternion.hpp
Normal file
@@ -0,0 +1,404 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_quaternion
|
||||
/// @file glm/gtc/quaternion.hpp
|
||||
/// @date 2009-05-21 / 2012-12-20
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_half_float (dependence)
|
||||
/// @see gtc_constants (dependence)
|
||||
///
|
||||
/// @defgroup gtc_quaternion GLM_GTC_quaternion
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Defines a templated quaternion type and several quaternion operations.
|
||||
///
|
||||
/// <glm/gtc/quaternion.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_quaternion
|
||||
#define GLM_GTC_quaternion
|
||||
|
||||
// Dependency:
|
||||
#include "../mat3x3.hpp"
|
||||
#include "../mat4x4.hpp"
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
#include "../gtc/constants.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_quaternion extension included")
|
||||
#endif
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, precision P>
|
||||
struct tquat
|
||||
{
|
||||
enum ctor{null};
|
||||
|
||||
typedef T value_type;
|
||||
typedef tvec4<bool, P> bool_type;
|
||||
|
||||
public:
|
||||
T x, y, z, w;
|
||||
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
||||
|
||||
// Constructors
|
||||
GLM_FUNC_DECL tquat();
|
||||
template <typename U, precision Q>
|
||||
GLM_FUNC_DECL explicit tquat(
|
||||
tquat<U, Q> const & q);
|
||||
GLM_FUNC_DECL tquat(
|
||||
T const & s,
|
||||
tvec3<T, P> const & v);
|
||||
GLM_FUNC_DECL tquat(
|
||||
T const & w,
|
||||
T const & x,
|
||||
T const & y,
|
||||
T const & z);
|
||||
|
||||
// Convertions
|
||||
|
||||
/// Create a quaternion from two normalized axis
|
||||
///
|
||||
/// @param u A first normalized axis
|
||||
/// @param v A second normalized axis
|
||||
/// @see gtc_quaternion
|
||||
/// @see http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors
|
||||
GLM_FUNC_DECL explicit tquat(
|
||||
detail::tvec3<T, P> const & u,
|
||||
detail::tvec3<T, P> const & v);
|
||||
/// Build a quaternion from euler angles (pitch, yaw, roll), in radians.
|
||||
GLM_FUNC_DECL explicit tquat(
|
||||
tvec3<T, P> const & eulerAngles);
|
||||
GLM_FUNC_DECL explicit tquat(
|
||||
tmat3x3<T, P> const & m);
|
||||
GLM_FUNC_DECL explicit tquat(
|
||||
tmat4x4<T, P> const & m);
|
||||
|
||||
// Accesses
|
||||
GLM_FUNC_DECL T & operator[](length_t i);
|
||||
GLM_FUNC_DECL T const & operator[](length_t i) const;
|
||||
|
||||
// Operators
|
||||
GLM_FUNC_DECL tquat<T, P> & operator+=(tquat<T, P> const & q);
|
||||
GLM_FUNC_DECL tquat<T, P> & operator*=(tquat<T, P> const & q);
|
||||
GLM_FUNC_DECL tquat<T, P> & operator*=(T const & s);
|
||||
GLM_FUNC_DECL tquat<T, P> & operator/=(T const & s);
|
||||
};
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> operator- (
|
||||
detail::tquat<T, P> const & q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> operator+ (
|
||||
detail::tquat<T, P> const & q,
|
||||
detail::tquat<T, P> const & p);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> operator* (
|
||||
detail::tquat<T, P> const & q,
|
||||
detail::tquat<T, P> const & p);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec3<T, P> operator* (
|
||||
detail::tquat<T, P> const & q,
|
||||
detail::tvec3<T, P> const & v);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec3<T, P> operator* (
|
||||
detail::tvec3<T, P> const & v,
|
||||
detail::tquat<T, P> const & q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<T, P> operator* (
|
||||
detail::tquat<T, P> const & q,
|
||||
detail::tvec4<T, P> const & v);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<T, P> operator* (
|
||||
detail::tvec4<T, P> const & v,
|
||||
detail::tquat<T, P> const & q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> operator* (
|
||||
detail::tquat<T, P> const & q,
|
||||
T const & s);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> operator* (
|
||||
T const & s,
|
||||
detail::tquat<T, P> const & q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> operator/ (
|
||||
detail::tquat<T, P> const & q,
|
||||
T const & s);
|
||||
|
||||
} //namespace detail
|
||||
|
||||
/// @addtogroup gtc_quaternion
|
||||
/// @{
|
||||
|
||||
/// Returns the length of the quaternion.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL T length(
|
||||
detail::tquat<T, P> const & q);
|
||||
|
||||
/// Returns the normalized quaternion.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> normalize(
|
||||
detail::tquat<T, P> const & q);
|
||||
|
||||
/// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ...
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P, template <typename, precision> class quatType>
|
||||
GLM_FUNC_DECL T dot(
|
||||
quatType<T, P> const & x,
|
||||
quatType<T, P> const & y);
|
||||
|
||||
/// Spherical linear interpolation of two quaternions.
|
||||
/// The interpolation is oriented and the rotation is performed at constant speed.
|
||||
/// For short path spherical linear interpolation, use the slerp function.
|
||||
///
|
||||
/// @param x A quaternion
|
||||
/// @param y A quaternion
|
||||
/// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
|
||||
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
|
||||
/// @see gtc_quaternion
|
||||
/// @see - slerp(detail::tquat<T, P> const & x, detail::tquat<T, P> const & y, T const & a)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> mix(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y,
|
||||
T const & a);
|
||||
|
||||
/// Linear interpolation of two quaternions.
|
||||
/// The interpolation is oriented.
|
||||
///
|
||||
/// @param x A quaternion
|
||||
/// @param y A quaternion
|
||||
/// @param a Interpolation factor. The interpolation is defined in the range [0, 1].
|
||||
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> lerp(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y,
|
||||
T const & a);
|
||||
|
||||
/// Spherical linear interpolation of two quaternions.
|
||||
/// The interpolation always take the short path and the rotation is performed at constant speed.
|
||||
///
|
||||
/// @param x A quaternion
|
||||
/// @param y A quaternion
|
||||
/// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
|
||||
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> slerp(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y,
|
||||
T const & a);
|
||||
|
||||
/// Returns the q conjugate.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> conjugate(
|
||||
detail::tquat<T, P> const & q);
|
||||
|
||||
/// Returns the q inverse.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> inverse(
|
||||
detail::tquat<T, P> const & q);
|
||||
|
||||
/// Rotates a quaternion from a vector of 3 components axis and an angle.
|
||||
///
|
||||
/// @param q Source orientation
|
||||
/// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||
/// @param axis Axis of the rotation
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> rotate(
|
||||
detail::tquat<T, P> const & q,
|
||||
T const & angle,
|
||||
detail::tvec3<T, P> const & axis);
|
||||
|
||||
/// Returns euler angles, yitch as x, yaw as y, roll as z.
|
||||
/// The result is expressed in radians if GLM_FORCE_RADIANS is defined or degrees otherwise.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec3<T, P> eulerAngles(
|
||||
detail::tquat<T, P> const & x);
|
||||
|
||||
/// Returns roll value of euler angles expressed in radians if GLM_FORCE_RADIANS is defined or degrees otherwise.
|
||||
///
|
||||
/// @see gtx_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL T roll(detail::tquat<T, P> const & x);
|
||||
|
||||
/// Returns pitch value of euler angles expressed in radians if GLM_FORCE_RADIANS is defined or degrees otherwise.
|
||||
///
|
||||
/// @see gtx_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL T pitch(detail::tquat<T, P> const & x);
|
||||
|
||||
/// Returns yaw value of euler angles expressed in radians if GLM_FORCE_RADIANS is defined or degrees otherwise.
|
||||
///
|
||||
/// @see gtx_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL T yaw(detail::tquat<T, P> const & x);
|
||||
|
||||
/// Converts a quaternion to a 3 * 3 matrix.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tmat3x3<T, P> mat3_cast(
|
||||
detail::tquat<T, P> const & x);
|
||||
|
||||
/// Converts a quaternion to a 4 * 4 matrix.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, P> mat4_cast(
|
||||
detail::tquat<T, P> const & x);
|
||||
|
||||
/// Converts a 3 * 3 matrix to a quaternion.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> quat_cast(
|
||||
detail::tmat3x3<T, P> const & x);
|
||||
|
||||
/// Converts a 4 * 4 matrix to a quaternion.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> quat_cast(
|
||||
detail::tmat4x4<T, P> const & x);
|
||||
|
||||
/// Returns the quaternion rotation angle.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL T angle(detail::tquat<T, P> const & x);
|
||||
|
||||
/// Returns the q rotation axis.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec3<T, P> axis(
|
||||
detail::tquat<T, P> const & x);
|
||||
|
||||
/// Build a quaternion from an angle and a normalized axis.
|
||||
///
|
||||
/// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||
/// @param axis Axis of the quaternion, must be normalized.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tquat<T, P> angleAxis(
|
||||
T const & angle,
|
||||
detail::tvec3<T, P> const & axis);
|
||||
|
||||
/// Returns the component-wise comparison result of x < y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<bool, P> lessThan(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x <= y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<bool, P> lessThanEqual(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x > y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<bool, P> greaterThan(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x >= y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<bool, P> greaterThanEqual(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x == y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<bool, P> equal(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x != y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<bool, P> notEqual(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y);
|
||||
|
||||
/// @}
|
||||
} //namespace glm
|
||||
|
||||
#include "quaternion.inl"
|
||||
|
||||
#endif//GLM_GTC_quaternion
|
||||
925
Research/inc/glm/gtc/quaternion.inl
Normal file
925
Research/inc/glm/gtc/quaternion.inl
Normal file
@@ -0,0 +1,925 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_quaternion
|
||||
/// @file glm/gtc/quaternion.inl
|
||||
/// @date 2009-05-21 / 2011-06-15
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../trigonometric.hpp"
|
||||
#include "../geometric.hpp"
|
||||
#include "../exponential.hpp"
|
||||
#include <limits>
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tquat<T, P>::length() const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat() :
|
||||
x(0),
|
||||
y(0),
|
||||
z(0),
|
||||
w(1)
|
||||
{}
|
||||
|
||||
template <typename T, precision P>
|
||||
template <typename U, precision Q>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
||||
(
|
||||
tquat<U, Q> const & q
|
||||
) :
|
||||
x(q.x),
|
||||
y(q.y),
|
||||
z(q.z),
|
||||
w(q.w)
|
||||
{}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
||||
(
|
||||
T const & s,
|
||||
tvec3<T, P> const & v
|
||||
) :
|
||||
x(v.x),
|
||||
y(v.y),
|
||||
z(v.z),
|
||||
w(s)
|
||||
{}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
||||
(
|
||||
T const & w,
|
||||
T const & x,
|
||||
T const & y,
|
||||
T const & z
|
||||
) :
|
||||
x(x),
|
||||
y(y),
|
||||
z(z),
|
||||
w(w)
|
||||
{}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// tquat conversions
|
||||
|
||||
//template <typename valType>
|
||||
//GLM_FUNC_QUALIFIER tquat<valType>::tquat
|
||||
//(
|
||||
// valType const & pitch,
|
||||
// valType const & yaw,
|
||||
// valType const & roll
|
||||
//)
|
||||
//{
|
||||
// tvec3<valType> eulerAngle(pitch * valType(0.5), yaw * valType(0.5), roll * valType(0.5));
|
||||
// tvec3<valType> c = glm::cos(eulerAngle * valType(0.5));
|
||||
// tvec3<valType> s = glm::sin(eulerAngle * valType(0.5));
|
||||
//
|
||||
// this->w = c.x * c.y * c.z + s.x * s.y * s.z;
|
||||
// this->x = s.x * c.y * c.z - c.x * s.y * s.z;
|
||||
// this->y = c.x * s.y * c.z + s.x * c.y * s.z;
|
||||
// this->z = c.x * c.y * s.z - s.x * s.y * c.z;
|
||||
//}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
||||
(
|
||||
detail::tvec3<T, P> const & u,
|
||||
detail::tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
detail::tvec3<T, P> w = cross(u, v);
|
||||
T Dot = detail::compute_dot<detail::tvec3, T, P>::call(u, v);
|
||||
detail::tquat<T, P> q(T(1) + Dot, w.x, w.y, w.z);
|
||||
|
||||
*this = normalize(q);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
||||
(
|
||||
tvec3<T, P> const & eulerAngle
|
||||
)
|
||||
{
|
||||
tvec3<T, P> c = glm::cos(eulerAngle * T(0.5));
|
||||
tvec3<T, P> s = glm::sin(eulerAngle * T(0.5));
|
||||
|
||||
this->w = c.x * c.y * c.z + s.x * s.y * s.z;
|
||||
this->x = s.x * c.y * c.z - c.x * s.y * s.z;
|
||||
this->y = c.x * s.y * c.z + s.x * c.y * s.z;
|
||||
this->z = c.x * c.y * s.z - s.x * s.y * c.z;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
||||
(
|
||||
tmat3x3<T, P> const & m
|
||||
)
|
||||
{
|
||||
*this = quat_cast(m);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
||||
(
|
||||
tmat4x4<T, P> const & m
|
||||
)
|
||||
{
|
||||
*this = quat_cast(m);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// tquat<T, P> accesses
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T & tquat<T, P>::operator[] (length_t i)
|
||||
{
|
||||
assert(i >= 0 && i < this->length());
|
||||
return (&x)[i];
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const & tquat<T, P>::operator[] (length_t i) const
|
||||
{
|
||||
assert(i >= 0 && i < this->length());
|
||||
return (&x)[i];
|
||||
}
|
||||
}//namespace detail
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> conjugate
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return detail::tquat<T, P>(q.w, -q.x, -q.y, -q.z);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> inverse
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return conjugate(q) / dot(q, q);
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
//////////////////////////////////////////////////////////////
|
||||
// tquat<valType> operators
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator +=
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
this->w += q.w;
|
||||
this->x += q.x;
|
||||
this->y += q.y;
|
||||
this->z += q.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator *=
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
tquat<T, P> const p(*this);
|
||||
|
||||
this->w = p.w * q.w - p.x * q.x - p.y * q.y - p.z * q.z;
|
||||
this->x = p.w * q.x + p.x * q.w + p.y * q.z - p.z * q.y;
|
||||
this->y = p.w * q.y + p.y * q.w + p.z * q.x - p.x * q.z;
|
||||
this->z = p.w * q.z + p.z * q.w + p.x * q.y - p.y * q.x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator *=
|
||||
(
|
||||
T const & s
|
||||
)
|
||||
{
|
||||
this->w *= s;
|
||||
this->x *= s;
|
||||
this->y *= s;
|
||||
this->z *= s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator /=
|
||||
(
|
||||
T const & s
|
||||
)
|
||||
{
|
||||
this->w /= s;
|
||||
this->x /= s;
|
||||
this->y /= s;
|
||||
this->z /= s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// tquat<T, P> external functions
|
||||
|
||||
template <typename T, precision P>
|
||||
struct compute_dot<tquat, T, P>
|
||||
{
|
||||
static GLM_FUNC_QUALIFIER T call(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
{
|
||||
tvec4<T, P> tmp(x.x * y.x, x.y * y.y, x.z * y.z, x.w * y.w);
|
||||
return (tmp.x + tmp.y) + (tmp.z + tmp.w);
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// tquat<T, P> external operators
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> operator-
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return detail::tquat<T, P>(-q.w, -q.x, -q.y, -q.z);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> operator+
|
||||
(
|
||||
detail::tquat<T, P> const & q,
|
||||
detail::tquat<T, P> const & p
|
||||
)
|
||||
{
|
||||
return detail::tquat<T, P>(q) += p;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> operator*
|
||||
(
|
||||
detail::tquat<T, P> const & q,
|
||||
detail::tquat<T, P> const & p
|
||||
)
|
||||
{
|
||||
return detail::tquat<T, P>(q) *= p;
|
||||
}
|
||||
|
||||
// Transformation
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T, P> operator*
|
||||
(
|
||||
detail::tquat<T, P> const & q,
|
||||
detail::tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
detail::tvec3<T, P> const QuatVector(q.x, q.y, q.z);
|
||||
detail::tvec3<T, P> const uv(glm::cross(QuatVector, v));
|
||||
detail::tvec3<T, P> const uuv(glm::cross(QuatVector, uv));
|
||||
|
||||
return v + ((uv * q.w) + uuv) * static_cast<T>(2);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T, P> operator*
|
||||
(
|
||||
detail::tvec3<T, P> const & v,
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return glm::inverse(q) * v;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T, P> operator*
|
||||
(
|
||||
detail::tquat<T, P> const & q,
|
||||
detail::tvec4<T, P> const & v
|
||||
)
|
||||
{
|
||||
return detail::tvec4<T, P>(q * detail::tvec3<T, P>(v), v.w);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T, P> operator*
|
||||
(
|
||||
detail::tvec4<T, P> const & v,
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return glm::inverse(q) * v;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> operator*
|
||||
(
|
||||
detail::tquat<T, P> const & q,
|
||||
T const & s
|
||||
)
|
||||
{
|
||||
return detail::tquat<T, P>(
|
||||
q.w * s, q.x * s, q.y * s, q.z * s);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> operator*
|
||||
(
|
||||
T const & s,
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return q * s;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> operator/
|
||||
(
|
||||
detail::tquat<T, P> const & q,
|
||||
T const & s
|
||||
)
|
||||
{
|
||||
return detail::tquat<T, P>(
|
||||
q.w / s, q.x / s, q.y / s, q.z / s);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Boolean operators
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER bool operator==
|
||||
(
|
||||
detail::tquat<T, P> const & q1,
|
||||
detail::tquat<T, P> const & q2
|
||||
)
|
||||
{
|
||||
return (q1.x == q2.x) && (q1.y == q2.y) && (q1.z == q2.z) && (q1.w == q2.w);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER bool operator!=
|
||||
(
|
||||
detail::tquat<T, P> const & q1,
|
||||
detail::tquat<T, P> const & q2
|
||||
)
|
||||
{
|
||||
return (q1.x != q2.x) || (q1.y != q2.y) || (q1.z != q2.z) || (q1.w != q2.w);
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T length
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return glm::sqrt(dot(q, q));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> normalize
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
T len = length(q);
|
||||
if(len <= T(0)) // Problem
|
||||
return detail::tquat<T, P>(1, 0, 0, 0);
|
||||
T oneOverLen = T(1) / len;
|
||||
return detail::tquat<T, P>(q.w * oneOverLen, q.x * oneOverLen, q.y * oneOverLen, q.z * oneOverLen);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> cross
|
||||
(
|
||||
detail::tquat<T, P> const & q1,
|
||||
detail::tquat<T, P> const & q2
|
||||
)
|
||||
{
|
||||
return detail::tquat<T, P>(
|
||||
q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z,
|
||||
q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y,
|
||||
q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z,
|
||||
q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x);
|
||||
}
|
||||
/*
|
||||
// (x * sin(1 - a) * angle / sin(angle)) + (y * sin(a) * angle / sin(angle))
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> mix
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
if(a <= T(0)) return x;
|
||||
if(a >= T(1)) return y;
|
||||
|
||||
float fCos = dot(x, y);
|
||||
detail::tquat<T, P> y2(y); //BUG!!! tquat<T, P> y2;
|
||||
if(fCos < T(0))
|
||||
{
|
||||
y2 = -y;
|
||||
fCos = -fCos;
|
||||
}
|
||||
|
||||
//if(fCos > 1.0f) // problem
|
||||
float k0, k1;
|
||||
if(fCos > T(0.9999))
|
||||
{
|
||||
k0 = T(1) - a;
|
||||
k1 = T(0) + a; //BUG!!! 1.0f + a;
|
||||
}
|
||||
else
|
||||
{
|
||||
T fSin = sqrt(T(1) - fCos * fCos);
|
||||
T fAngle = atan(fSin, fCos);
|
||||
T fOneOverSin = static_cast<T>(1) / fSin;
|
||||
k0 = sin((T(1) - a) * fAngle) * fOneOverSin;
|
||||
k1 = sin((T(0) + a) * fAngle) * fOneOverSin;
|
||||
}
|
||||
|
||||
return detail::tquat<T, P>(
|
||||
k0 * x.w + k1 * y2.w,
|
||||
k0 * x.x + k1 * y2.x,
|
||||
k0 * x.y + k1 * y2.y,
|
||||
k0 * x.z + k1 * y2.z);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> mix2
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
bool flip = false;
|
||||
if(a <= static_cast<T>(0)) return x;
|
||||
if(a >= static_cast<T>(1)) return y;
|
||||
|
||||
T cos_t = dot(x, y);
|
||||
if(cos_t < T(0))
|
||||
{
|
||||
cos_t = -cos_t;
|
||||
flip = true;
|
||||
}
|
||||
|
||||
T alpha(0), beta(0);
|
||||
|
||||
if(T(1) - cos_t < 1e-7)
|
||||
beta = static_cast<T>(1) - alpha;
|
||||
else
|
||||
{
|
||||
T theta = acos(cos_t);
|
||||
T sin_t = sin(theta);
|
||||
beta = sin(theta * (T(1) - alpha)) / sin_t;
|
||||
alpha = sin(alpha * theta) / sin_t;
|
||||
}
|
||||
|
||||
if(flip)
|
||||
alpha = -alpha;
|
||||
|
||||
return normalize(beta * x + alpha * y);
|
||||
}
|
||||
*/
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> mix
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
T cosTheta = dot(x, y);
|
||||
|
||||
// Perform a linear interpolation when cosTheta is close to 1 to avoid side effect of sin(angle) becoming a zero denominator
|
||||
if(cosTheta > T(1) - epsilon<T>())
|
||||
{
|
||||
// Linear interpolation
|
||||
return detail::tquat<T, P>(
|
||||
mix(x.w, y.w, a),
|
||||
mix(x.x, y.x, a),
|
||||
mix(x.y, y.y, a),
|
||||
mix(x.z, y.z, a));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Essential Mathematics, page 467
|
||||
T angle = acos(cosTheta);
|
||||
return (sin((T(1) - a) * angle) * x + sin(a * angle) * y) / sin(angle);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> lerp
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
// Lerp is only defined in [0, 1]
|
||||
assert(a >= static_cast<T>(0));
|
||||
assert(a <= static_cast<T>(1));
|
||||
|
||||
return x * (T(1) - a) + (y * a);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> slerp
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
detail::tquat<T, P> z = y;
|
||||
|
||||
T cosTheta = dot(x, y);
|
||||
|
||||
// If cosTheta < 0, the interpolation will take the long way around the sphere.
|
||||
// To fix this, one quat must be negated.
|
||||
if (cosTheta < T(0))
|
||||
{
|
||||
z = -y;
|
||||
cosTheta = -cosTheta;
|
||||
}
|
||||
|
||||
// Perform a linear interpolation when cosTheta is close to 1 to avoid side effect of sin(angle) becoming a zero denominator
|
||||
if(cosTheta > T(1) - epsilon<T>())
|
||||
{
|
||||
// Linear interpolation
|
||||
return detail::tquat<T, P>(
|
||||
mix(x.w, z.w, a),
|
||||
mix(x.x, z.x, a),
|
||||
mix(x.y, z.y, a),
|
||||
mix(x.z, z.z, a));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Essential Mathematics, page 467
|
||||
T angle = acos(cosTheta);
|
||||
return (sin((T(1) - a) * angle) * x + sin(a * angle) * z) / sin(angle);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> rotate
|
||||
(
|
||||
detail::tquat<T, P> const & q,
|
||||
T const & angle,
|
||||
detail::tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
detail::tvec3<T, P> Tmp = v;
|
||||
|
||||
// Axis of rotation must be normalised
|
||||
T len = glm::length(Tmp);
|
||||
if(abs(len - T(1)) > T(0.001))
|
||||
{
|
||||
T oneOverLen = static_cast<T>(1) / len;
|
||||
Tmp.x *= oneOverLen;
|
||||
Tmp.y *= oneOverLen;
|
||||
Tmp.z *= oneOverLen;
|
||||
}
|
||||
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
T const AngleRad(angle);
|
||||
#else
|
||||
# pragma message("GLM: rotate function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||
T const AngleRad = radians(angle);
|
||||
#endif
|
||||
T const Sin = sin(AngleRad * T(0.5));
|
||||
|
||||
return q * detail::tquat<T, P>(cos(AngleRad * T(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin);
|
||||
//return gtc::quaternion::cross(q, detail::tquat<T, P>(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T, P> eulerAngles
|
||||
(
|
||||
detail::tquat<T, P> const & x
|
||||
)
|
||||
{
|
||||
return detail::tvec3<T, P>(pitch(x), yaw(x), roll(x));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T roll
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
return T(atan(T(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z));
|
||||
#else
|
||||
# pragma message("GLM: roll function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||
return glm::degrees(atan(T(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T pitch
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
return T(atan(T(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z));
|
||||
#else
|
||||
# pragma message("GLM: pitch function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||
return glm::degrees(atan(T(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T yaw
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
return asin(T(-2) * (q.x * q.z - q.w * q.y));
|
||||
#else
|
||||
# pragma message("GLM: yaw function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||
return glm::degrees(asin(T(-2) * (q.x * q.z - q.w * q.y)));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T, P> mat3_cast
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
detail::tmat3x3<T, P> Result(T(1));
|
||||
T qxx(q.x * q.x);
|
||||
T qyy(q.y * q.y);
|
||||
T qzz(q.z * q.z);
|
||||
T qxz(q.x * q.z);
|
||||
T qxy(q.x * q.y);
|
||||
T qyz(q.y * q.z);
|
||||
T qwx(q.w * q.x);
|
||||
T qwy(q.w * q.y);
|
||||
T qwz(q.w * q.z);
|
||||
|
||||
Result[0][0] = 1 - 2 * (qyy + qzz);
|
||||
Result[0][1] = 2 * (qxy + qwz);
|
||||
Result[0][2] = 2 * (qxz - qwy);
|
||||
|
||||
Result[1][0] = 2 * (qxy - qwz);
|
||||
Result[1][1] = 1 - 2 * (qxx + qzz);
|
||||
Result[1][2] = 2 * (qyz + qwx);
|
||||
|
||||
Result[2][0] = 2 * (qxz + qwy);
|
||||
Result[2][1] = 2 * (qyz - qwx);
|
||||
Result[2][2] = 1 - 2 * (qxx + qyy);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> mat4_cast
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return detail::tmat4x4<T, P>(mat3_cast(q));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> quat_cast
|
||||
(
|
||||
detail::tmat3x3<T, P> const & m
|
||||
)
|
||||
{
|
||||
T fourXSquaredMinus1 = m[0][0] - m[1][1] - m[2][2];
|
||||
T fourYSquaredMinus1 = m[1][1] - m[0][0] - m[2][2];
|
||||
T fourZSquaredMinus1 = m[2][2] - m[0][0] - m[1][1];
|
||||
T fourWSquaredMinus1 = m[0][0] + m[1][1] + m[2][2];
|
||||
|
||||
int biggestIndex = 0;
|
||||
T fourBiggestSquaredMinus1 = fourWSquaredMinus1;
|
||||
if(fourXSquaredMinus1 > fourBiggestSquaredMinus1)
|
||||
{
|
||||
fourBiggestSquaredMinus1 = fourXSquaredMinus1;
|
||||
biggestIndex = 1;
|
||||
}
|
||||
if(fourYSquaredMinus1 > fourBiggestSquaredMinus1)
|
||||
{
|
||||
fourBiggestSquaredMinus1 = fourYSquaredMinus1;
|
||||
biggestIndex = 2;
|
||||
}
|
||||
if(fourZSquaredMinus1 > fourBiggestSquaredMinus1)
|
||||
{
|
||||
fourBiggestSquaredMinus1 = fourZSquaredMinus1;
|
||||
biggestIndex = 3;
|
||||
}
|
||||
|
||||
T biggestVal = sqrt(fourBiggestSquaredMinus1 + T(1)) * T(0.5);
|
||||
T mult = static_cast<T>(0.25) / biggestVal;
|
||||
|
||||
detail::tquat<T, P> Result;
|
||||
switch(biggestIndex)
|
||||
{
|
||||
case 0:
|
||||
Result.w = biggestVal;
|
||||
Result.x = (m[1][2] - m[2][1]) * mult;
|
||||
Result.y = (m[2][0] - m[0][2]) * mult;
|
||||
Result.z = (m[0][1] - m[1][0]) * mult;
|
||||
break;
|
||||
case 1:
|
||||
Result.w = (m[1][2] - m[2][1]) * mult;
|
||||
Result.x = biggestVal;
|
||||
Result.y = (m[0][1] + m[1][0]) * mult;
|
||||
Result.z = (m[2][0] + m[0][2]) * mult;
|
||||
break;
|
||||
case 2:
|
||||
Result.w = (m[2][0] - m[0][2]) * mult;
|
||||
Result.x = (m[0][1] + m[1][0]) * mult;
|
||||
Result.y = biggestVal;
|
||||
Result.z = (m[1][2] + m[2][1]) * mult;
|
||||
break;
|
||||
case 3:
|
||||
Result.w = (m[0][1] - m[1][0]) * mult;
|
||||
Result.x = (m[2][0] + m[0][2]) * mult;
|
||||
Result.y = (m[1][2] + m[2][1]) * mult;
|
||||
Result.z = biggestVal;
|
||||
break;
|
||||
|
||||
default: // Silence a -Wswitch-default warning in GCC. Should never actually get here. Assert is just for sanity.
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> quat_cast
|
||||
(
|
||||
detail::tmat4x4<T, P> const & m4
|
||||
)
|
||||
{
|
||||
return quat_cast(detail::tmat3x3<T, P>(m4));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T angle
|
||||
(
|
||||
detail::tquat<T, P> const & x
|
||||
)
|
||||
{
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
return acos(x.w) * T(2);
|
||||
#else
|
||||
# pragma message("GLM: angle function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||
return glm::degrees(acos(x.w) * T(2));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T, P> axis
|
||||
(
|
||||
detail::tquat<T, P> const & x
|
||||
)
|
||||
{
|
||||
T tmp1 = static_cast<T>(1) - x.w * x.w;
|
||||
if(tmp1 <= static_cast<T>(0))
|
||||
return detail::tvec3<T, P>(0, 0, 1);
|
||||
T tmp2 = static_cast<T>(1) / sqrt(tmp1);
|
||||
return detail::tvec3<T, P>(x.x * tmp2, x.y * tmp2, x.z * tmp2);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> angleAxis
|
||||
(
|
||||
T const & angle,
|
||||
detail::tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
detail::tquat<T, P> result;
|
||||
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
T const a(angle);
|
||||
#else
|
||||
# pragma message("GLM: angleAxis function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||
T const a(glm::radians(angle));
|
||||
#endif
|
||||
T s = glm::sin(a * T(0.5));
|
||||
|
||||
result.w = glm::cos(a * T(0.5));
|
||||
result.x = v.x * s;
|
||||
result.y = v.y * s;
|
||||
result.z = v.z * s;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> lessThan
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y
|
||||
)
|
||||
{
|
||||
detail::tvec4<bool, P> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] < y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> lessThanEqual
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y
|
||||
)
|
||||
{
|
||||
detail::tvec4<bool, P> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] <= y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> greaterThan
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y
|
||||
)
|
||||
{
|
||||
detail::tvec4<bool, P> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] > y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> greaterThanEqual
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y
|
||||
)
|
||||
{
|
||||
detail::tvec4<bool, P> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] >= y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> equal
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y
|
||||
)
|
||||
{
|
||||
detail::tvec4<bool, P> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] == y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> notEqual
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y
|
||||
)
|
||||
{
|
||||
detail::tvec4<bool, P> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] != y[i];
|
||||
return Result;
|
||||
}
|
||||
}//namespace glm
|
||||
114
Research/inc/glm/gtc/random.hpp
Normal file
114
Research/inc/glm/gtc/random.hpp
Normal file
@@ -0,0 +1,114 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_random
|
||||
/// @file glm/gtc/random.hpp
|
||||
/// @date 2011-09-18 / 2011-09-18
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_half_float (dependence)
|
||||
/// @see gtx_random (extended)
|
||||
///
|
||||
/// @defgroup gtc_random GLM_GTC_random
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Generate random number from various distribution methods.
|
||||
///
|
||||
/// <glm/gtc/random.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_random
|
||||
#define GLM_GTC_random
|
||||
|
||||
// Dependency:
|
||||
#include "../vec2.hpp"
|
||||
#include "../vec3.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_random extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_random
|
||||
/// @{
|
||||
|
||||
/// Generate random numbers in the interval [Min, Max], according a linear distribution
|
||||
///
|
||||
/// @param Min
|
||||
/// @param Max
|
||||
/// @tparam genType Value type. Currently supported: half (not recommanded), float or double scalars and vectors.
|
||||
/// @see gtc_random
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType linearRand(
|
||||
genType const & Min,
|
||||
genType const & Max);
|
||||
|
||||
/// Generate random numbers in the interval [Min, Max], according a gaussian distribution
|
||||
///
|
||||
/// @param Mean
|
||||
/// @param Deviation
|
||||
/// @see gtc_random
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType gaussRand(
|
||||
genType const & Mean,
|
||||
genType const & Deviation);
|
||||
|
||||
/// Generate a random 2D vector which coordinates are regulary distributed on a circle of a given radius
|
||||
///
|
||||
/// @param Radius
|
||||
/// @see gtc_random
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL detail::tvec2<T, defaultp> circularRand(
|
||||
T const & Radius);
|
||||
|
||||
/// Generate a random 3D vector which coordinates are regulary distributed on a sphere of a given radius
|
||||
///
|
||||
/// @param Radius
|
||||
/// @see gtc_random
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL detail::tvec3<T, defaultp> sphericalRand(
|
||||
T const & Radius);
|
||||
|
||||
/// Generate a random 2D vector which coordinates are regulary distributed within the area of a disk of a given radius
|
||||
///
|
||||
/// @param Radius
|
||||
/// @see gtc_random
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL detail::tvec2<T, defaultp> diskRand(
|
||||
T const & Radius);
|
||||
|
||||
/// Generate a random 3D vector which coordinates are regulary distributed within the volume of a ball of a given radius
|
||||
///
|
||||
/// @param Radius
|
||||
/// @see gtc_random
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL detail::tvec3<T, defaultp> ballRand(
|
||||
T const & Radius);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "random.inl"
|
||||
|
||||
#endif//GLM_GTC_random
|
||||
171
Research/inc/glm/gtc/random.inl
Normal file
171
Research/inc/glm/gtc/random.inl
Normal file
@@ -0,0 +1,171 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_random
|
||||
/// @file glm/gtc/random.inl
|
||||
/// @date 2011-09-19 / 2012-04-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../geometric.hpp"
|
||||
#include "../exponential.hpp"
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <cassert>
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
struct compute_linearRand
|
||||
{
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T operator() (T const & Min, T const & Max) const;
|
||||
/*
|
||||
{
|
||||
GLM_STATIC_ASSERT(0, "'linearRand' invalid template parameter type. GLM_GTC_random only supports floating-point template types.");
|
||||
return Min;
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER float compute_linearRand::operator()<float> (float const & Min, float const & Max) const
|
||||
{
|
||||
return float(std::rand()) / float(RAND_MAX) * (Max - Min) + Min;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER double compute_linearRand::operator()<double> (double const & Min, double const & Max) const
|
||||
{
|
||||
return double(std::rand()) / double(RAND_MAX) * (Max - Min) + Min;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER long double compute_linearRand::operator()<long double> (long double const & Min, long double const & Max) const
|
||||
{
|
||||
return (long double)(std::rand()) / (long double)(RAND_MAX) * (Max - Min) + Min;
|
||||
}
|
||||
}//namespace detail
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType linearRand
|
||||
(
|
||||
genType const & Min,
|
||||
genType const & Max
|
||||
)
|
||||
{
|
||||
return detail::compute_linearRand()(Min, Max);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC_VEC(linearRand)
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType gaussRand
|
||||
(
|
||||
genType const & Mean,
|
||||
genType const & Deviation
|
||||
)
|
||||
{
|
||||
genType w, x1, x2;
|
||||
|
||||
do
|
||||
{
|
||||
x1 = linearRand(genType(-1), genType(1));
|
||||
x2 = linearRand(genType(-1), genType(1));
|
||||
|
||||
w = x1 * x1 + x2 * x2;
|
||||
} while(w > genType(1));
|
||||
|
||||
return x2 * Deviation * Deviation * sqrt((genType(-2) * log(w)) / w) + Mean;
|
||||
}
|
||||
|
||||
VECTORIZE_VEC_VEC(gaussRand)
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T, defaultp> diskRand
|
||||
(
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
detail::tvec2<T, defaultp> Result(T(0));
|
||||
T LenRadius(T(0));
|
||||
|
||||
do
|
||||
{
|
||||
Result = linearRand(
|
||||
detail::tvec2<T, defaultp>(-Radius),
|
||||
detail::tvec2<T, defaultp>(Radius));
|
||||
LenRadius = length(Result);
|
||||
}
|
||||
while(LenRadius > Radius);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T, defaultp> ballRand
|
||||
(
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
detail::tvec3<T, defaultp> Result(T(0));
|
||||
T LenRadius(T(0));
|
||||
|
||||
do
|
||||
{
|
||||
Result = linearRand(
|
||||
detail::tvec3<T, defaultp>(-Radius),
|
||||
detail::tvec3<T, defaultp>(Radius));
|
||||
LenRadius = length(Result);
|
||||
}
|
||||
while(LenRadius > Radius);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T, defaultp> circularRand
|
||||
(
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
|
||||
return detail::tvec2<T, defaultp>(cos(a), sin(a)) * Radius;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T, defaultp> sphericalRand
|
||||
(
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
T z = linearRand(T(-1), T(1));
|
||||
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
|
||||
|
||||
T r = sqrt(T(1) - z * z);
|
||||
|
||||
T x = r * cos(a);
|
||||
T y = r * sin(a);
|
||||
|
||||
return detail::tvec3<T, defaultp>(x, y, z) * Radius;
|
||||
}
|
||||
}//namespace glm
|
||||
133
Research/inc/glm/gtc/reciprocal.hpp
Normal file
133
Research/inc/glm/gtc/reciprocal.hpp
Normal file
@@ -0,0 +1,133 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_reciprocal
|
||||
/// @file glm/gtc/reciprocal.hpp
|
||||
/// @date 2008-10-09 / 2012-01-25
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_reciprocal GLM_GTC_reciprocal
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Define secant, cosecant and cotangent functions.
|
||||
///
|
||||
/// <glm/gtc/reciprocal.hpp> need to be included to use these features.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_reciprocal
|
||||
#define GLM_GTC_reciprocal
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_reciprocal extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_reciprocal
|
||||
/// @{
|
||||
|
||||
/// Secant function.
|
||||
/// hypotenuse / adjacent or 1 / cos(x)
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType sec(genType const & angle);
|
||||
|
||||
/// Cosecant function.
|
||||
/// hypotenuse / opposite or 1 / sin(x)
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType csc(genType const & angle);
|
||||
|
||||
/// Cotangent function.
|
||||
/// adjacent / opposite or 1 / tan(x)
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType cot(genType const & angle);
|
||||
|
||||
/// Inverse secant function.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType asec(genType const & x);
|
||||
|
||||
/// Inverse cosecant function.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType acsc(genType const & x);
|
||||
|
||||
/// Inverse cotangent function.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType acot(genType const & x);
|
||||
|
||||
/// Secant hyperbolic function.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType sech(genType const & angle);
|
||||
|
||||
/// Cosecant hyperbolic function.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType csch(genType const & angle);
|
||||
|
||||
/// Cotangent hyperbolic function.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType coth(genType const & angle);
|
||||
|
||||
/// Inverse secant hyperbolic function.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType asech(genType const & x);
|
||||
|
||||
/// Inverse cosecant hyperbolic function.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType acsch(genType const & x);
|
||||
|
||||
/// Inverse cotangent hyperbolic function.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType acoth(genType const & x);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "reciprocal.inl"
|
||||
|
||||
#endif//GLM_GTC_reciprocal
|
||||
202
Research/inc/glm/gtc/reciprocal.inl
Normal file
202
Research/inc/glm/gtc/reciprocal.inl
Normal file
@@ -0,0 +1,202 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_reciprocal
|
||||
/// @file glm/gtc/reciprocal.inl
|
||||
/// @date 2008-10-09 / 2012-04-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../trigonometric.hpp"
|
||||
#include <limits>
|
||||
|
||||
namespace glm
|
||||
{
|
||||
// sec
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType sec
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sec' only accept floating-point values");
|
||||
|
||||
return genType(1) / glm::cos(angle);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(sec)
|
||||
|
||||
// csc
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType csc
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csc' only accept floating-point values");
|
||||
|
||||
return genType(1) / glm::sin(angle);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(csc)
|
||||
|
||||
// cot
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType cot
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'cot' only accept floating-point values");
|
||||
|
||||
return genType(1) / glm::tan(angle);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(cot)
|
||||
|
||||
// asec
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType asec
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asec' only accept floating-point values");
|
||||
|
||||
return acos(genType(1) / x);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(asec)
|
||||
|
||||
// acsc
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acsc
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsc' only accept floating-point values");
|
||||
|
||||
return asin(genType(1) / x);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(acsc)
|
||||
|
||||
// acot
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acot
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acot' only accept floating-point values");
|
||||
|
||||
genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0);
|
||||
return pi_over_2 - atan(x);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(acot)
|
||||
|
||||
// sech
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType sech
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sech' only accept floating-point values");
|
||||
|
||||
return genType(1) / glm::cosh(angle);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(sech)
|
||||
|
||||
// csch
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType csch
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csch' only accept floating-point values");
|
||||
|
||||
return genType(1) / glm::sinh(angle);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(csch)
|
||||
|
||||
// coth
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType coth
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'coth' only accept floating-point values");
|
||||
|
||||
return glm::cosh(angle) / glm::sinh(angle);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(coth)
|
||||
|
||||
// asech
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType asech
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asech' only accept floating-point values");
|
||||
|
||||
return acosh(genType(1) / x);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(asech)
|
||||
|
||||
// acsch
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acsch
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsch' only accept floating-point values");
|
||||
|
||||
return asinh(genType(1) / x);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(acsch)
|
||||
|
||||
// acoth
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acoth
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acoth' only accept floating-point values");
|
||||
|
||||
return atanh(genType(1) / x);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(acoth)
|
||||
}//namespace glm
|
||||
874
Research/inc/glm/gtc/type_precision.hpp
Normal file
874
Research/inc/glm/gtc/type_precision.hpp
Normal file
@@ -0,0 +1,874 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_type_precision
|
||||
/// @file glm/gtc/type_precision.hpp
|
||||
/// @date 2009-06-04 / 2011-12-07
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_half_float (dependence)
|
||||
/// @see gtc_quaternion (dependence)
|
||||
///
|
||||
/// @defgroup gtc_type_precision GLM_GTC_type_precision
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Defines specific C++-based precision types.
|
||||
///
|
||||
/// @ref core_precision defines types based on GLSL's precision qualifiers. This
|
||||
/// extension defines types based on explicitly-sized C++ data types.
|
||||
///
|
||||
/// <glm/gtc/type_precision.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_type_precision
|
||||
#define GLM_GTC_type_precision
|
||||
|
||||
// Dependency:
|
||||
#include "../gtc/quaternion.hpp"
|
||||
#include "../vec2.hpp"
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
#include "../mat2x2.hpp"
|
||||
#include "../mat2x3.hpp"
|
||||
#include "../mat2x4.hpp"
|
||||
#include "../mat3x2.hpp"
|
||||
#include "../mat3x3.hpp"
|
||||
#include "../mat3x4.hpp"
|
||||
#include "../mat4x2.hpp"
|
||||
#include "../mat4x3.hpp"
|
||||
#include "../mat4x4.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_type_precision extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
///////////////////////////
|
||||
// Signed int vector types
|
||||
|
||||
/// @addtogroup gtc_type_precision
|
||||
/// @{
|
||||
|
||||
/// Low precision 8 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int8 lowp_int8;
|
||||
|
||||
/// Low precision 16 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int16 lowp_int16;
|
||||
|
||||
/// Low precision 32 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int32 lowp_int32;
|
||||
|
||||
/// Low precision 64 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int64 lowp_int64;
|
||||
|
||||
/// Low precision 8 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int8 lowp_int8_t;
|
||||
|
||||
/// Low precision 16 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int16 lowp_int16_t;
|
||||
|
||||
/// Low precision 32 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int32 lowp_int32_t;
|
||||
|
||||
/// Low precision 64 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int64 lowp_int64_t;
|
||||
|
||||
/// Low precision 8 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int8 lowp_i8;
|
||||
|
||||
/// Low precision 16 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int16 lowp_i16;
|
||||
|
||||
/// Low precision 32 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int32 lowp_i32;
|
||||
|
||||
/// Low precision 64 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int64 lowp_i64;
|
||||
|
||||
/// Medium precision 8 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int8 mediump_int8;
|
||||
|
||||
/// Medium precision 16 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int16 mediump_int16;
|
||||
|
||||
/// Medium precision 32 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int32 mediump_int32;
|
||||
|
||||
/// Medium precision 64 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int64 mediump_int64;
|
||||
|
||||
/// Medium precision 8 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int8 mediump_int8_t;
|
||||
|
||||
/// Medium precision 16 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int16 mediump_int16_t;
|
||||
|
||||
/// Medium precision 32 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int32 mediump_int32_t;
|
||||
|
||||
/// Medium precision 64 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int64 mediump_int64_t;
|
||||
|
||||
/// Medium precision 8 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int8 mediump_i8;
|
||||
|
||||
/// Medium precision 16 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int16 mediump_i16;
|
||||
|
||||
/// Medium precision 32 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int32 mediump_i32;
|
||||
|
||||
/// Medium precision 64 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int64 mediump_i64;
|
||||
|
||||
/// High precision 8 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int8 highp_int8;
|
||||
|
||||
/// High precision 16 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int16 highp_int16;
|
||||
|
||||
/// High precision 32 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int32 highp_int32;
|
||||
|
||||
/// High precision 64 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int64 highp_int64;
|
||||
|
||||
/// High precision 8 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int8 highp_int8_t;
|
||||
|
||||
/// High precision 16 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int16 highp_int16_t;
|
||||
|
||||
/// 32 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int32 highp_int32_t;
|
||||
|
||||
/// High precision 64 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int64 highp_int64_t;
|
||||
|
||||
/// High precision 8 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int8 highp_i8;
|
||||
|
||||
/// High precision 16 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int16 highp_i16;
|
||||
|
||||
/// High precision 32 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int32 highp_i32;
|
||||
|
||||
/// High precision 64 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int64 highp_i64;
|
||||
|
||||
|
||||
/// 8 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int8 int8;
|
||||
|
||||
/// 16 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int16 int16;
|
||||
|
||||
/// 32 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int32 int32;
|
||||
|
||||
/// 64 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int64 int64;
|
||||
|
||||
/// 8 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int8 int8_t;
|
||||
|
||||
/// 16 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int16 int16_t;
|
||||
|
||||
/// 32 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int32 int32_t;
|
||||
|
||||
/// 64 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int64 int64_t;
|
||||
|
||||
/// 8 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int8 i8;
|
||||
|
||||
/// 16 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int16 i16;
|
||||
|
||||
/// 32 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int32 i32;
|
||||
|
||||
/// 64 bit signed integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::int64 i64;
|
||||
|
||||
|
||||
/// 8 bit signed integer scalar type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec1<i8, defaultp> i8vec1;
|
||||
|
||||
/// 8 bit signed integer vector of 2 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec2<i8, defaultp> i8vec2;
|
||||
|
||||
/// 8 bit signed integer vector of 3 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec3<i8, defaultp> i8vec3;
|
||||
|
||||
/// 8 bit signed integer vector of 4 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec4<i8, defaultp> i8vec4;
|
||||
|
||||
|
||||
/// 16 bit signed integer scalar type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec1<i16, defaultp> i16vec1;
|
||||
|
||||
/// 16 bit signed integer vector of 2 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec2<i16, defaultp> i16vec2;
|
||||
|
||||
/// 16 bit signed integer vector of 3 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec3<i16, defaultp> i16vec3;
|
||||
|
||||
/// 16 bit signed integer vector of 4 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec4<i16, defaultp> i16vec4;
|
||||
|
||||
|
||||
/// 32 bit signed integer scalar type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec1<i32, defaultp> i32vec1;
|
||||
|
||||
/// 32 bit signed integer vector of 2 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec2<i32, defaultp> i32vec2;
|
||||
|
||||
/// 32 bit signed integer vector of 3 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec3<i32, defaultp> i32vec3;
|
||||
|
||||
/// 32 bit signed integer vector of 4 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec4<i32, defaultp> i32vec4;
|
||||
|
||||
|
||||
/// 64 bit signed integer scalar type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec1<i64, defaultp> i64vec1;
|
||||
|
||||
/// 64 bit signed integer vector of 2 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec2<i64, defaultp> i64vec2;
|
||||
|
||||
/// 64 bit signed integer vector of 3 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec3<i64, defaultp> i64vec3;
|
||||
|
||||
/// 64 bit signed integer vector of 4 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec4<i64, defaultp> i64vec4;
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Unsigned int vector types
|
||||
|
||||
/// Low precision 8 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint8 lowp_uint8;
|
||||
|
||||
/// Low precision 16 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint16 lowp_uint16;
|
||||
|
||||
/// Low precision 32 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint32 lowp_uint32;
|
||||
|
||||
/// Low precision 64 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint64 lowp_uint64;
|
||||
|
||||
/// Low precision 8 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint8 lowp_uint8_t;
|
||||
|
||||
/// Low precision 16 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint16 lowp_uint16_t;
|
||||
|
||||
/// Low precision 32 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint32 lowp_uint32_t;
|
||||
|
||||
/// Low precision 64 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint64 lowp_uint64_t;
|
||||
|
||||
/// Low precision 8 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint8 lowp_u8;
|
||||
|
||||
/// Low precision 16 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint16 lowp_u16;
|
||||
|
||||
/// Low precision 32 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint32 lowp_u32;
|
||||
|
||||
/// Low precision 64 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint64 lowp_u64;
|
||||
|
||||
/// Medium precision 8 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint8 mediump_uint8;
|
||||
|
||||
/// Medium precision 16 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint16 mediump_uint16;
|
||||
|
||||
/// Medium precision 32 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint32 mediump_uint32;
|
||||
|
||||
/// Medium precision 64 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint64 mediump_uint64;
|
||||
|
||||
/// Medium precision 8 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint8 mediump_uint8_t;
|
||||
|
||||
/// Medium precision 16 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint16 mediump_uint16_t;
|
||||
|
||||
/// Medium precision 32 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint32 mediump_uint32_t;
|
||||
|
||||
/// Medium precision 64 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint64 mediump_uint64_t;
|
||||
|
||||
/// Medium precision 8 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint8 mediump_u8;
|
||||
|
||||
/// Medium precision 16 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint16 mediump_u16;
|
||||
|
||||
/// Medium precision 32 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint32 mediump_u32;
|
||||
|
||||
/// Medium precision 64 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint64 mediump_u64;
|
||||
|
||||
/// High precision 8 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint8 highp_uint8;
|
||||
|
||||
/// High precision 16 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint16 highp_uint16;
|
||||
|
||||
/// High precision 32 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint32 highp_uint32;
|
||||
|
||||
/// High precision 64 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint64 highp_uint64;
|
||||
|
||||
/// High precision 8 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint8 highp_uint8_t;
|
||||
|
||||
/// High precision 16 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint16 highp_uint16_t;
|
||||
|
||||
/// High precision 32 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint32 highp_uint32_t;
|
||||
|
||||
/// High precision 64 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint64 highp_uint64_t;
|
||||
|
||||
/// High precision 8 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint8 highp_u8;
|
||||
|
||||
/// High precision 16 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint16 highp_u16;
|
||||
|
||||
/// High precision 32 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint32 highp_u32;
|
||||
|
||||
/// High precision 64 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint64 highp_u64;
|
||||
|
||||
/// Default precision 8 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint8 uint8;
|
||||
|
||||
/// Default precision 16 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint16 uint16;
|
||||
|
||||
/// Default precision 32 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint32 uint32;
|
||||
|
||||
/// Default precision 64 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint64 uint64;
|
||||
|
||||
/// Default precision 8 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint8 uint8_t;
|
||||
|
||||
/// Default precision 16 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint16 uint16_t;
|
||||
|
||||
/// Default precision 32 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint32 uint32_t;
|
||||
|
||||
/// Default precision 64 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint64 uint64_t;
|
||||
|
||||
/// Default precision 8 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint8 u8;
|
||||
|
||||
/// Default precision 16 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint16 u16;
|
||||
|
||||
/// Default precision 32 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint32 u32;
|
||||
|
||||
/// Default precision 64 bit unsigned integer type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::uint64 u64;
|
||||
|
||||
|
||||
|
||||
/// Default precision 8 bit unsigned integer scalar type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec1<u8, defaultp> u8vec1;
|
||||
|
||||
/// Default precision 8 bit unsigned integer vector of 2 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec2<u8, defaultp> u8vec2;
|
||||
|
||||
/// Default precision 8 bit unsigned integer vector of 3 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec3<u8, defaultp> u8vec3;
|
||||
|
||||
/// Default precision 8 bit unsigned integer vector of 4 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec4<u8, defaultp> u8vec4;
|
||||
|
||||
|
||||
/// Default precision 16 bit unsigned integer scalar type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec1<u16, defaultp> u16vec1;
|
||||
|
||||
/// Default precision 16 bit unsigned integer vector of 2 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec2<u16, defaultp> u16vec2;
|
||||
|
||||
/// Default precision 16 bit unsigned integer vector of 3 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec3<u16, defaultp> u16vec3;
|
||||
|
||||
/// Default precision 16 bit unsigned integer vector of 4 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec4<u16, defaultp> u16vec4;
|
||||
|
||||
|
||||
/// Default precision 32 bit unsigned integer scalar type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec1<u32, defaultp> u32vec1;
|
||||
|
||||
/// Default precision 32 bit unsigned integer vector of 2 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec2<u32, defaultp> u32vec2;
|
||||
|
||||
/// Default precision 32 bit unsigned integer vector of 3 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec3<u32, defaultp> u32vec3;
|
||||
|
||||
/// Default precision 32 bit unsigned integer vector of 4 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec4<u32, defaultp> u32vec4;
|
||||
|
||||
|
||||
/// Default precision 64 bit unsigned integer scalar type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec1<u64, defaultp> u64vec1;
|
||||
|
||||
/// Default precision 64 bit unsigned integer vector of 2 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec2<u64, defaultp> u64vec2;
|
||||
|
||||
/// Default precision 64 bit unsigned integer vector of 3 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec3<u64, defaultp> u64vec3;
|
||||
|
||||
/// Default precision 64 bit unsigned integer vector of 4 components type.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec4<u64, defaultp> u64vec4;
|
||||
|
||||
|
||||
//////////////////////
|
||||
// Float vector types
|
||||
|
||||
/// 32 bit single-precision floating-point scalar.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::float32 float32;
|
||||
|
||||
/// 64 bit double-precision floating-point scalar.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::float64 float64;
|
||||
|
||||
|
||||
/// 32 bit single-precision floating-point scalar.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::float32 float32_t;
|
||||
|
||||
/// 64 bit double-precision floating-point scalar.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::float64 float64_t;
|
||||
|
||||
|
||||
/// 32 bit single-precision floating-point scalar.
|
||||
/// @see gtc_type_precision
|
||||
typedef float32 f32;
|
||||
|
||||
/// 64 bit double-precision floating-point scalar.
|
||||
/// @see gtc_type_precision
|
||||
typedef float64 f64;
|
||||
|
||||
|
||||
/// Single-precision floating-point vector of 1 component.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec1<float, defaultp> fvec1;
|
||||
|
||||
/// Single-precision floating-point vector of 2 components.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec2<float, defaultp> fvec2;
|
||||
|
||||
/// Single-precision floating-point vector of 3 components.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec3<float, defaultp> fvec3;
|
||||
|
||||
/// Single-precision floating-point vector of 4 components.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec4<float, defaultp> fvec4;
|
||||
|
||||
|
||||
/// Single-precision floating-point vector of 1 component.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec1<f32, defaultp> f32vec1;
|
||||
|
||||
/// Single-precision floating-point vector of 2 components.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec2<f32, defaultp> f32vec2;
|
||||
|
||||
/// Single-precision floating-point vector of 3 components.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec3<f32, defaultp> f32vec3;
|
||||
|
||||
/// Single-precision floating-point vector of 4 components.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec4<f32, defaultp> f32vec4;
|
||||
|
||||
|
||||
/// Double-precision floating-point vector of 1 component.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec1<f64, defaultp> f64vec1;
|
||||
|
||||
/// Double-precision floating-point vector of 2 components.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec2<f64, defaultp> f64vec2;
|
||||
|
||||
/// Double-precision floating-point vector of 3 components.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec3<f64, defaultp> f64vec3;
|
||||
|
||||
/// Double-precision floating-point vector of 4 components.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tvec4<f64, defaultp> f64vec4;
|
||||
|
||||
|
||||
//////////////////////
|
||||
// Float matrix types
|
||||
|
||||
/// Single-precision floating-point 1x1 matrix.
|
||||
/// @see gtc_type_precision
|
||||
//typedef detail::tmat1x1<f32> fmat1;
|
||||
|
||||
/// Single-precision floating-point 2x2 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat2x2<f32, defaultp> fmat2;
|
||||
|
||||
/// Single-precision floating-point 3x3 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat3x3<f32, defaultp> fmat3;
|
||||
|
||||
/// Single-precision floating-point 4x4 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat4x4<f32, defaultp> fmat4;
|
||||
|
||||
|
||||
/// Single-precision floating-point 1x1 matrix.
|
||||
/// @see gtc_type_precision
|
||||
//typedef f32 fmat1x1;
|
||||
|
||||
/// Single-precision floating-point 2x2 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat2x2<f32, defaultp> fmat2x2;
|
||||
|
||||
/// Single-precision floating-point 2x3 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat2x3<f32, defaultp> fmat2x3;
|
||||
|
||||
/// Single-precision floating-point 2x4 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat2x4<f32, defaultp> fmat2x4;
|
||||
|
||||
/// Single-precision floating-point 3x2 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat3x2<f32, defaultp> fmat3x2;
|
||||
|
||||
/// Single-precision floating-point 3x3 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat3x3<f32, defaultp> fmat3x3;
|
||||
|
||||
/// Single-precision floating-point 3x4 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat3x4<f32, defaultp> fmat3x4;
|
||||
|
||||
/// Single-precision floating-point 4x2 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat4x2<f32, defaultp> fmat4x2;
|
||||
|
||||
/// Single-precision floating-point 4x3 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat4x3<f32, defaultp> fmat4x3;
|
||||
|
||||
/// Single-precision floating-point 4x4 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat4x4<f32, defaultp> fmat4x4;
|
||||
|
||||
|
||||
/// Single-precision floating-point 1x1 matrix.
|
||||
/// @see gtc_type_precision
|
||||
//typedef detail::tmat1x1<f32, defaultp> f32mat1;
|
||||
|
||||
/// Single-precision floating-point 2x2 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat2x2<f32, defaultp> f32mat2;
|
||||
|
||||
/// Single-precision floating-point 3x3 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat3x3<f32, defaultp> f32mat3;
|
||||
|
||||
/// Single-precision floating-point 4x4 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat4x4<f32, defaultp> f32mat4;
|
||||
|
||||
|
||||
/// Single-precision floating-point 1x1 matrix.
|
||||
/// @see gtc_type_precision
|
||||
//typedef f32 f32mat1x1;
|
||||
|
||||
/// Single-precision floating-point 2x2 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat2x2<f32, defaultp> f32mat2x2;
|
||||
|
||||
/// Single-precision floating-point 2x3 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat2x3<f32, defaultp> f32mat2x3;
|
||||
|
||||
/// Single-precision floating-point 2x4 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat2x4<f32, defaultp> f32mat2x4;
|
||||
|
||||
/// Single-precision floating-point 3x2 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat3x2<f32, defaultp> f32mat3x2;
|
||||
|
||||
/// Single-precision floating-point 3x3 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat3x3<f32, defaultp> f32mat3x3;
|
||||
|
||||
/// Single-precision floating-point 3x4 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat3x4<f32, defaultp> f32mat3x4;
|
||||
|
||||
/// Single-precision floating-point 4x2 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat4x2<f32, defaultp> f32mat4x2;
|
||||
|
||||
/// Single-precision floating-point 4x3 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat4x3<f32, defaultp> f32mat4x3;
|
||||
|
||||
/// Single-precision floating-point 4x4 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat4x4<f32, defaultp> f32mat4x4;
|
||||
|
||||
|
||||
/// Double-precision floating-point 1x1 matrix.
|
||||
/// @see gtc_type_precision
|
||||
//typedef detail::tmat1x1<f64, defaultp> f64mat1;
|
||||
|
||||
/// Double-precision floating-point 2x2 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat2x2<f64, defaultp> f64mat2;
|
||||
|
||||
/// Double-precision floating-point 3x3 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat3x3<f64, defaultp> f64mat3;
|
||||
|
||||
/// Double-precision floating-point 4x4 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat4x4<f64, defaultp> f64mat4;
|
||||
|
||||
|
||||
/// Double-precision floating-point 1x1 matrix.
|
||||
/// @see gtc_type_precision
|
||||
//typedef f64 f64mat1x1;
|
||||
|
||||
/// Double-precision floating-point 2x2 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat2x2<f64, defaultp> f64mat2x2;
|
||||
|
||||
/// Double-precision floating-point 2x3 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat2x3<f64, defaultp> f64mat2x3;
|
||||
|
||||
/// Double-precision floating-point 2x4 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat2x4<f64, defaultp> f64mat2x4;
|
||||
|
||||
/// Double-precision floating-point 3x2 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat3x2<f64, defaultp> f64mat3x2;
|
||||
|
||||
/// Double-precision floating-point 3x3 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat3x3<f64, defaultp> f64mat3x3;
|
||||
|
||||
/// Double-precision floating-point 3x4 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat3x4<f64, defaultp> f64mat3x4;
|
||||
|
||||
/// Double-precision floating-point 4x2 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat4x2<f64, defaultp> f64mat4x2;
|
||||
|
||||
/// Double-precision floating-point 4x3 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat4x3<f64, defaultp> f64mat4x3;
|
||||
|
||||
/// Double-precision floating-point 4x4 matrix.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tmat4x4<f64, defaultp> f64mat4x4;
|
||||
|
||||
|
||||
//////////////////////////
|
||||
// Quaternion types
|
||||
|
||||
/// Single-precision floating-point quaternion.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tquat<f32, defaultp> f32quat;
|
||||
|
||||
/// Double-precision floating-point quaternion.
|
||||
/// @see gtc_type_precision
|
||||
typedef detail::tquat<f64, defaultp> f64quat;
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "type_precision.inl"
|
||||
|
||||
#endif//GLM_GTC_type_precision
|
||||
32
Research/inc/glm/gtc/type_precision.inl
Normal file
32
Research/inc/glm/gtc/type_precision.inl
Normal file
@@ -0,0 +1,32 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_swizzle
|
||||
/// @file glm/gtc/swizzle.inl
|
||||
/// @date 2009-06-14 / 2011-06-15
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm
|
||||
{
|
||||
|
||||
}
|
||||
179
Research/inc/glm/gtc/type_ptr.hpp
Normal file
179
Research/inc/glm/gtc/type_ptr.hpp
Normal file
@@ -0,0 +1,179 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_type_ptr
|
||||
/// @file glm/gtc/type_ptr.hpp
|
||||
/// @date 2009-05-06 / 2011-06-05
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_half_float (dependence)
|
||||
/// @see gtc_quaternion (dependence)
|
||||
///
|
||||
/// @defgroup gtc_type_ptr GLM_GTC_type_ptr
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Handles the interaction between pointers and vector, matrix types.
|
||||
///
|
||||
/// This extension defines an overloaded function, glm::value_ptr, which
|
||||
/// takes any of the \ref core_template "core template types". It returns
|
||||
/// a pointer to the memory layout of the object. Matrix types store their values
|
||||
/// in column-major order.
|
||||
///
|
||||
/// This is useful for uploading data to matrices or copying data to buffer objects.
|
||||
///
|
||||
/// Example:
|
||||
/// @code
|
||||
/// #include <glm/glm.hpp>
|
||||
/// #include <glm/gtc/type_ptr.hpp>
|
||||
///
|
||||
/// glm::vec3 aVector(3);
|
||||
/// glm::mat4 someMatrix(1.0);
|
||||
///
|
||||
/// glUniform3fv(uniformLoc, 1, glm::value_ptr(aVector));
|
||||
/// glUniformMatrix4fv(uniformMatrixLoc, 1, GL_FALSE, glm::value_ptr(someMatrix));
|
||||
/// @endcode
|
||||
///
|
||||
/// <glm/gtc/type_ptr.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_type_ptr
|
||||
#define GLM_GTC_type_ptr
|
||||
|
||||
// Dependency:
|
||||
#include "../gtc/quaternion.hpp"
|
||||
#include "../vec2.hpp"
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
#include "../mat2x2.hpp"
|
||||
#include "../mat2x3.hpp"
|
||||
#include "../mat2x4.hpp"
|
||||
#include "../mat3x2.hpp"
|
||||
#include "../mat3x3.hpp"
|
||||
#include "../mat3x4.hpp"
|
||||
#include "../mat4x2.hpp"
|
||||
#include "../mat4x3.hpp"
|
||||
#include "../mat4x4.hpp"
|
||||
#include <cstring>
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_type_ptr extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_type_ptr
|
||||
/// @{
|
||||
|
||||
/// Return the constant address to the data of the input parameter.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL typename genType::value_type const * value_ptr(genType const & vec);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tvec2<T, defaultp> make_vec2(T const * const ptr);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tvec3<T, defaultp> make_vec3(T const * const ptr);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tvec4<T, defaultp> make_vec4(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tmat2x2<T, defaultp> make_mat2x2(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tmat2x3<T, defaultp> make_mat2x3(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tmat2x4<T, defaultp> make_mat2x4(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tmat3x2<T, defaultp> make_mat3x2(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tmat3x3<T, defaultp> make_mat3x3(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tmat3x4<T, defaultp> make_mat3x4(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tmat4x2<T, defaultp> make_mat4x2(
|
||||
T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tmat4x3<T, defaultp> make_mat4x3(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> make_mat4x4(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tmat2x2<T, defaultp> make_mat2(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tmat3x3<T, defaultp> make_mat3(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> make_mat4(T const * const ptr);
|
||||
|
||||
/// Build a quaternion from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL detail::tquat<T, defaultp> make_quat(T const * const ptr);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "type_ptr.inl"
|
||||
|
||||
#endif//GLM_GTC_type_ptr
|
||||
|
||||
475
Research/inc/glm/gtc/type_ptr.inl
Normal file
475
Research/inc/glm/gtc/type_ptr.inl
Normal file
@@ -0,0 +1,475 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_type_ptr
|
||||
/// @file glm/gtc/type_ptr.inl
|
||||
/// @date 2011-06-15 / 2011-12-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_type_ptr
|
||||
/// @{
|
||||
|
||||
/// Return the constant address to the data of the vector input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
detail::tvec2<T, P> const & vec
|
||||
)
|
||||
{
|
||||
return &(vec.x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the vector input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
detail::tvec2<T, P> & vec
|
||||
)
|
||||
{
|
||||
return &(vec.x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the vector input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
detail::tvec3<T, P> const & vec
|
||||
)
|
||||
{
|
||||
return &(vec.x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the vector input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
detail::tvec3<T, P> & vec
|
||||
)
|
||||
{
|
||||
return &(vec.x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the vector input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
detail::tvec4<T, P> const & vec
|
||||
)
|
||||
{
|
||||
return &(vec.x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the vector input.
|
||||
//! From GLM_GTC_type_ptr extension.
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
detail::tvec4<T, P> & vec
|
||||
)
|
||||
{
|
||||
return &(vec.x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
detail::tmat2x2<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
detail::tmat2x2<T, P> & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
detail::tmat3x3<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
detail::tmat3x3<T, P> & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
detail::tmat4x4<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
//! From GLM_GTC_type_ptr extension.
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
detail::tmat4x4<T, P> & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
detail::tmat2x3<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
detail::tmat2x3<T, P> & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
detail::tmat3x2<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
detail::tmat3x2<T, P> & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
detail::tmat2x4<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
detail::tmat2x4<T, P> & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
detail::tmat4x2<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
detail::tmat4x2<T, P> & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
detail::tmat3x4<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
detail::tmat3x4<T, P> & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
detail::tmat4x3<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr(detail::tmat4x3<T, P> & mat)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the input parameter.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return &(q[0]);
|
||||
}
|
||||
|
||||
/// Return the address to the data of the quaternion input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
detail::tquat<T, P> & q
|
||||
)
|
||||
{
|
||||
return &(q[0]);
|
||||
}
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T, defaultp> make_vec2(T const * const ptr)
|
||||
{
|
||||
detail::tvec2<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(detail::tvec2<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T, defaultp> make_vec3(T const * const ptr)
|
||||
{
|
||||
detail::tvec3<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(detail::tvec3<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T, defaultp> make_vec4(T const * const ptr)
|
||||
{
|
||||
detail::tvec4<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(detail::tvec4<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<T, defaultp> make_mat2x2(T const * const ptr)
|
||||
{
|
||||
detail::tmat2x2<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x2<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x3<T, defaultp> make_mat2x3(T const * const ptr)
|
||||
{
|
||||
detail::tmat2x3<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x3<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x4<T, defaultp> make_mat2x4(T const * const ptr)
|
||||
{
|
||||
detail::tmat2x4<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x4<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x2<T, defaultp> make_mat3x2(T const * const ptr)
|
||||
{
|
||||
detail::tmat3x2<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x2<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T, defaultp> make_mat3x3(T const * const ptr)
|
||||
{
|
||||
detail::tmat3x3<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x3<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x4<T, defaultp> make_mat3x4(T const * const ptr)
|
||||
{
|
||||
detail::tmat3x4<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x4<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x2<T, defaultp> make_mat4x2(T const * const ptr)
|
||||
{
|
||||
detail::tmat4x2<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x2<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x3<T, defaultp> make_mat4x3(T const * const ptr)
|
||||
{
|
||||
detail::tmat4x3<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x3<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> make_mat4x4(T const * const ptr)
|
||||
{
|
||||
detail::tmat4x4<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x4<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<T, defaultp> make_mat2(T const * const ptr)
|
||||
{
|
||||
return make_mat2x2(ptr);
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T, defaultp> make_mat3(T const * const ptr)
|
||||
{
|
||||
return make_mat3x3(ptr);
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> make_mat4(T const * const ptr)
|
||||
{
|
||||
return make_mat4x4(ptr);
|
||||
}
|
||||
|
||||
//! Build a quaternion from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, defaultp> make_quat(T const * const ptr)
|
||||
{
|
||||
detail::tquat<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(detail::tquat<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
92
Research/inc/glm/gtc/ulp.hpp
Normal file
92
Research/inc/glm/gtc/ulp.hpp
Normal file
@@ -0,0 +1,92 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_ulp
|
||||
/// @file glm/gtc/ulp.hpp
|
||||
/// @date 2011-02-21 / 2011-12-12
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_ulp GLM_GTC_ulp
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Allow the measurement of the accuracy of a function against a reference
|
||||
/// implementation. This extension works on floating-point data and provide results
|
||||
/// in ULP.
|
||||
/// <glm/gtc/ulp.hpp> need to be included to use these features.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_ulp
|
||||
#define GLM_GTC_ulp
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/precision.hpp"
|
||||
#include "../detail/type_int.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_ulp extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_ulp
|
||||
/// @{
|
||||
|
||||
/// Return the next ULP value(s) after the input value(s).
|
||||
/// @see gtc_ulp
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType next_float(genType const & x);
|
||||
|
||||
/// Return the previous ULP value(s) before the input value(s).
|
||||
/// @see gtc_ulp
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType prev_float(genType const & x);
|
||||
|
||||
/// Return the value(s) ULP distance after the input value(s).
|
||||
/// @see gtc_ulp
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType next_float(genType const & x, uint const & Distance);
|
||||
|
||||
/// Return the value(s) ULP distance before the input value(s).
|
||||
/// @see gtc_ulp
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType prev_float(genType const & x, uint const & Distance);
|
||||
|
||||
/// Return the distance in the number of ULP between 2 scalars.
|
||||
/// @see gtc_ulp
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL uint float_distance(T const & x, T const & y);
|
||||
|
||||
/// Return the distance in the number of ULP between 2 vectors.
|
||||
/// @see gtc_ulp
|
||||
template<typename T, template<typename> class vecType>
|
||||
GLM_FUNC_DECL vecType<uint> float_distance(vecType<T> const & x, vecType<T> const & y);
|
||||
|
||||
/// @}
|
||||
}// namespace glm
|
||||
|
||||
#include "ulp.inl"
|
||||
|
||||
#endif//GLM_GTC_ulp
|
||||
|
||||
338
Research/inc/glm/gtc/ulp.inl
Normal file
338
Research/inc/glm/gtc/ulp.inl
Normal file
@@ -0,0 +1,338 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_ulp
|
||||
/// @file glm/gtc/ulp.inl
|
||||
/// @date 2011-03-07 / 2012-04-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
///
|
||||
/// Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
/// Permission to use, copy, modify, and distribute this
|
||||
/// software is freely granted, provided that this notice
|
||||
/// is preserved.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../detail/type_int.hpp"
|
||||
#include <cmath>
|
||||
#include <cfloat>
|
||||
#include <limits>
|
||||
|
||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4127)
|
||||
#endif
|
||||
|
||||
typedef union
|
||||
{
|
||||
float value;
|
||||
/* FIXME: Assumes 32 bit int. */
|
||||
unsigned int word;
|
||||
} ieee_float_shape_type;
|
||||
|
||||
typedef union
|
||||
{
|
||||
double value;
|
||||
struct
|
||||
{
|
||||
glm::detail::int32 lsw;
|
||||
glm::detail::int32 msw;
|
||||
} parts;
|
||||
} ieee_double_shape_type;
|
||||
|
||||
#define GLM_EXTRACT_WORDS(ix0,ix1,d) \
|
||||
do { \
|
||||
ieee_double_shape_type ew_u; \
|
||||
ew_u.value = (d); \
|
||||
(ix0) = ew_u.parts.msw; \
|
||||
(ix1) = ew_u.parts.lsw; \
|
||||
} while (0)
|
||||
|
||||
#define GLM_GET_FLOAT_WORD(i,d) \
|
||||
do { \
|
||||
ieee_float_shape_type gf_u; \
|
||||
gf_u.value = (d); \
|
||||
(i) = gf_u.word; \
|
||||
} while (0)
|
||||
|
||||
#define GLM_SET_FLOAT_WORD(d,i) \
|
||||
do { \
|
||||
ieee_float_shape_type sf_u; \
|
||||
sf_u.word = (i); \
|
||||
(d) = sf_u.value; \
|
||||
} while (0)
|
||||
|
||||
#define GLM_INSERT_WORDS(d,ix0,ix1) \
|
||||
do { \
|
||||
ieee_double_shape_type iw_u; \
|
||||
iw_u.parts.msw = (ix0); \
|
||||
iw_u.parts.lsw = (ix1); \
|
||||
(d) = iw_u.value; \
|
||||
} while (0)
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
GLM_FUNC_QUALIFIER float nextafterf(float x, float y)
|
||||
{
|
||||
volatile float t;
|
||||
glm::detail::int32 hx, hy, ix, iy;
|
||||
|
||||
GLM_GET_FLOAT_WORD(hx, x);
|
||||
GLM_GET_FLOAT_WORD(hy, y);
|
||||
ix = hx&0x7fffffff; // |x|
|
||||
iy = hy&0x7fffffff; // |y|
|
||||
|
||||
if((ix>0x7f800000) || // x is nan
|
||||
(iy>0x7f800000)) // y is nan
|
||||
return x+y;
|
||||
if(x==y) return y; // x=y, return y
|
||||
if(ix==0) { // x == 0
|
||||
GLM_SET_FLOAT_WORD(x,(hy&0x80000000)|1);// return +-minsubnormal
|
||||
t = x*x;
|
||||
if(t==x) return t; else return x; // raise underflow flag
|
||||
}
|
||||
if(hx>=0) { // x > 0
|
||||
if(hx>hy) { // x > y, x -= ulp
|
||||
hx -= 1;
|
||||
} else { // x < y, x += ulp
|
||||
hx += 1;
|
||||
}
|
||||
} else { // x < 0
|
||||
if(hy>=0||hx>hy){ // x < y, x -= ulp
|
||||
hx -= 1;
|
||||
} else { // x > y, x += ulp
|
||||
hx += 1;
|
||||
}
|
||||
}
|
||||
hy = hx&0x7f800000;
|
||||
if(hy>=0x7f800000) return x+x; // overflow
|
||||
if(hy<0x00800000) { // underflow
|
||||
t = x*x;
|
||||
if(t!=x) { // raise underflow flag
|
||||
GLM_SET_FLOAT_WORD(y,hx);
|
||||
return y;
|
||||
}
|
||||
}
|
||||
GLM_SET_FLOAT_WORD(x,hx);
|
||||
return x;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER double nextafter(double x, double y)
|
||||
{
|
||||
volatile double t;
|
||||
glm::detail::int32 hx, hy, ix, iy;
|
||||
glm::detail::uint32 lx, ly;
|
||||
|
||||
GLM_EXTRACT_WORDS(hx, lx, x);
|
||||
GLM_EXTRACT_WORDS(hy, ly, y);
|
||||
ix = hx & 0x7fffffff; // |x|
|
||||
iy = hy & 0x7fffffff; // |y|
|
||||
|
||||
if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || // x is nan
|
||||
((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) // y is nan
|
||||
return x+y;
|
||||
if(x==y) return y; // x=y, return y
|
||||
if((ix|lx)==0) { // x == 0
|
||||
GLM_INSERT_WORDS(x, hy & 0x80000000, 1); // return +-minsubnormal
|
||||
t = x*x;
|
||||
if(t==x) return t; else return x; // raise underflow flag
|
||||
}
|
||||
if(hx>=0) { // x > 0
|
||||
if(hx>hy||((hx==hy)&&(lx>ly))) { // x > y, x -= ulp
|
||||
if(lx==0) hx -= 1;
|
||||
lx -= 1;
|
||||
} else { // x < y, x += ulp
|
||||
lx += 1;
|
||||
if(lx==0) hx += 1;
|
||||
}
|
||||
} else { // x < 0
|
||||
if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){// x < y, x -= ulp
|
||||
if(lx==0) hx -= 1;
|
||||
lx -= 1;
|
||||
} else { // x > y, x += ulp
|
||||
lx += 1;
|
||||
if(lx==0) hx += 1;
|
||||
}
|
||||
}
|
||||
hy = hx&0x7ff00000;
|
||||
if(hy>=0x7ff00000) return x+x; // overflow
|
||||
if(hy<0x00100000) { // underflow
|
||||
t = x*x;
|
||||
if(t!=x) { // raise underflow flag
|
||||
GLM_INSERT_WORDS(y,hx,lx);
|
||||
return y;
|
||||
}
|
||||
}
|
||||
GLM_INSERT_WORDS(x,hx,lx);
|
||||
return x;
|
||||
}
|
||||
}//namespace detail
|
||||
}//namespace glm
|
||||
|
||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER float next_float(float const & x)
|
||||
{
|
||||
# if((GLM_LANG & GLM_LANG_CXX11_FLAG) && !(GLM_PLATFORM & GLM_PLATFORM_ANDROID))
|
||||
return std::nextafter(x, std::numeric_limits<float>::max());
|
||||
# elif((GLM_PLATFORM & GLM_PLATFORM_ANDROID) || (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return detail::nextafterf(x, FLT_MAX);
|
||||
# else
|
||||
return nextafterf(x, FLT_MAX);
|
||||
# endif
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER double next_float(double const & x)
|
||||
{
|
||||
# if((GLM_LANG & GLM_LANG_CXX11_FLAG) && !(GLM_PLATFORM & GLM_PLATFORM_ANDROID))
|
||||
return std::nextafter(x, std::numeric_limits<double>::max());
|
||||
# elif((GLM_PLATFORM & GLM_PLATFORM_ANDROID) || (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return detail::nextafter(x, std::numeric_limits<double>::max());
|
||||
# else
|
||||
return nextafter(x, DBL_MAX);
|
||||
# endif
|
||||
}
|
||||
|
||||
template<typename T, precision P, template<typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> next_float(vecType<T, P> const & x)
|
||||
{
|
||||
vecType<T, P> Result;
|
||||
for(length_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = next_float(x[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float prev_float(float const & x)
|
||||
{
|
||||
# if((GLM_LANG & GLM_LANG_CXX11_FLAG) && !(GLM_PLATFORM & GLM_PLATFORM_ANDROID))
|
||||
return std::nextafter(x, std::numeric_limits<float>::min());
|
||||
# elif((GLM_PLATFORM & GLM_PLATFORM_ANDROID) || (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return detail::nextafterf(x, FLT_MIN);
|
||||
# else
|
||||
return nextafterf(x, FLT_MIN);
|
||||
# endif
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER double prev_float(double const & x)
|
||||
{
|
||||
# if((GLM_LANG & GLM_LANG_CXX11_FLAG) && !(GLM_PLATFORM & GLM_PLATFORM_ANDROID))
|
||||
return std::nextafter(x, std::numeric_limits<double>::min());
|
||||
# elif((GLM_PLATFORM & GLM_PLATFORM_ANDROID) || (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return _nextafter(x, DBL_MIN);
|
||||
# else
|
||||
return nextafter(x, DBL_MIN);
|
||||
# endif
|
||||
}
|
||||
|
||||
template<typename T, precision P, template<typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> prev_float(vecType<T, P> const & x)
|
||||
{
|
||||
vecType<T, P> Result;
|
||||
for(length_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = prev_float(x[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T next_float(T const & x, uint const & ulps)
|
||||
{
|
||||
T temp = x;
|
||||
for(uint i = 0; i < ulps; ++i)
|
||||
temp = next_float(temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
template<typename T, precision P, template<typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> next_float(vecType<T, P> const & x, vecType<uint, P> const & ulps)
|
||||
{
|
||||
vecType<T, P> Result;
|
||||
for(length_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = next_float(x[i], ulps[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T prev_float(T const & x, uint const & ulps)
|
||||
{
|
||||
T temp = x;
|
||||
for(uint i = 0; i < ulps; ++i)
|
||||
temp = prev_float(temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
template<typename T, precision P, template<typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> prev_float(vecType<T, P> const & x, vecType<uint, P> const & ulps)
|
||||
{
|
||||
vecType<T, P> Result;
|
||||
for(length_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = prev_float(x[i], ulps[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER uint float_distance(T const & x, T const & y)
|
||||
{
|
||||
uint ulp = 0;
|
||||
|
||||
if(x < y)
|
||||
{
|
||||
T temp = x;
|
||||
while(temp != y)// && ulp < std::numeric_limits<std::size_t>::max())
|
||||
{
|
||||
++ulp;
|
||||
temp = next_float(temp);
|
||||
}
|
||||
}
|
||||
else if(y < x)
|
||||
{
|
||||
T temp = y;
|
||||
while(temp != x)// && ulp < std::numeric_limits<std::size_t>::max())
|
||||
{
|
||||
++ulp;
|
||||
temp = next_float(temp);
|
||||
}
|
||||
}
|
||||
else // ==
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return ulp;
|
||||
}
|
||||
|
||||
template<typename T, precision P, template<typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<uint, P> float_distance(vecType<T, P> const & x, vecType<T, P> const & y)
|
||||
{
|
||||
vecType<uint, P> Result;
|
||||
for(length_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = float_distance(x[i], y[i]);
|
||||
return Result;
|
||||
}
|
||||
}//namespace glm
|
||||
Reference in New Issue
Block a user