mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Merge pull request #928 from l90lpa/lMaxNorm-proposal
L max norm proposal #928
This commit is contained in:
commit
bd32be3ebd
@ -3,6 +3,7 @@
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtx_quaternion (dependence)
|
||||
/// @see gtx_component_wise (dependence)
|
||||
///
|
||||
/// @defgroup gtx_norm GLM_GTX_norm
|
||||
/// @ingroup gtx
|
||||
@ -16,6 +17,7 @@
|
||||
// Dependency:
|
||||
#include "../geometric.hpp"
|
||||
#include "../gtx/quaternion.hpp"
|
||||
#include "../gtx/component_wise.hpp"
|
||||
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# ifndef GLM_ENABLE_EXPERIMENTAL
|
||||
@ -70,6 +72,16 @@ namespace glm
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL T lxNorm(vec<3, T, Q> const& x, unsigned int Depth);
|
||||
|
||||
//! Returns the LMax norm between x and y.
|
||||
//! From GLM_GTX_norm extension.
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL T lMaxNorm(vec<3, T, Q> const& x, vec<3, T, Q> const& y);
|
||||
|
||||
//! Returns the LMax norm of v.
|
||||
//! From GLM_GTX_norm extension.
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL T lMaxNorm(vec<3, T, Q> const& x);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
|
@ -80,4 +80,16 @@ namespace detail
|
||||
return pow(pow(abs(v.x), T(Depth)) + pow(abs(v.y), T(Depth)) + pow(abs(v.z), T(Depth)), T(1) / T(Depth));
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T lMaxNorm(vec<3, T, Q> const& a, vec<3, T, Q> const& b)
|
||||
{
|
||||
return compMax(abs(b - a));
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T lMaxNorm(vec<3, T, Q> const& v)
|
||||
{
|
||||
return compMax(abs(v));
|
||||
}
|
||||
|
||||
}//namespace glm
|
||||
|
@ -1,6 +1,24 @@
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/gtx/norm.hpp>
|
||||
|
||||
|
||||
int test_lMaxNorm()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
{
|
||||
float norm = glm::lMaxNorm(glm::vec3(-1, -2, -3));
|
||||
Error += glm::epsilonEqual(norm, 3.f, 0.00001f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
float norm = glm::lMaxNorm(glm::vec3(2, 3, 1));
|
||||
Error += glm::epsilonEqual(norm, 3.f, 0.00001f) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_lxNorm()
|
||||
{
|
||||
int Error(0);
|
||||
@ -49,7 +67,6 @@ int test_lxNorm()
|
||||
Error += glm::epsilonEqual(norm, 3.301927249f, 0.00001f) ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
@ -57,6 +74,7 @@ int main()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += test_lMaxNorm();
|
||||
Error += test_lxNorm();
|
||||
|
||||
return Error;
|
||||
|
Loading…
Reference in New Issue
Block a user