2016-11-12 13:19:22 +00:00
|
|
|
#define GLM_ENABLE_EXPERIMENTAL
|
2013-10-27 22:38:22 +00:00
|
|
|
#include <glm/gtx/norm.hpp>
|
2013-10-27 18:25:03 +00:00
|
|
|
|
2024-01-20 09:11:13 +00:00
|
|
|
static int test_lMaxNorm()
|
2019-07-19 17:11:07 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2019-08-25 08:03:13 +00:00
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|
|
|
|
|
2024-01-20 09:11:13 +00:00
|
|
|
static int test_lxNorm()
|
2019-07-19 17:28:31 +00:00
|
|
|
{
|
|
|
|
int Error(0);
|
|
|
|
|
|
|
|
{
|
|
|
|
unsigned int depth_1 = 1;
|
|
|
|
float normA = glm::lxNorm(glm::vec3(2, 3, 1), depth_1);
|
|
|
|
float normB = glm::l1Norm(glm::vec3(2, 3, 1));
|
|
|
|
Error += glm::epsilonEqual(normA, normB, 0.00001f) ? 0 : 1;
|
|
|
|
Error += glm::epsilonEqual(normA, 6.f, 0.00001f) ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
unsigned int depth_1 = 1;
|
|
|
|
float normA = glm::lxNorm(glm::vec3(-1, -2, -3), depth_1);
|
|
|
|
float normB = glm::l1Norm(glm::vec3(-1, -2, -3));
|
|
|
|
Error += glm::epsilonEqual(normA, normB, 0.00001f) ? 0 : 1;
|
|
|
|
Error += glm::epsilonEqual(normA, 6.f, 0.00001f) ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
unsigned int depth_2 = 2;
|
|
|
|
float normA = glm::lxNorm(glm::vec3(2, 3, 1), depth_2);
|
|
|
|
float normB = glm::l2Norm(glm::vec3(2, 3, 1));
|
|
|
|
Error += glm::epsilonEqual(normA, normB, 0.00001f) ? 0 : 1;
|
|
|
|
Error += glm::epsilonEqual(normA, 3.741657387f, 0.00001f) ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
unsigned int depth_2 = 2;
|
|
|
|
float normA = glm::lxNorm(glm::vec3(-1, -2, -3), depth_2);
|
|
|
|
float normB = glm::l2Norm(glm::vec3(-1, -2, -3));
|
|
|
|
Error += glm::epsilonEqual(normA, normB, 0.00001f) ? 0 : 1;
|
|
|
|
Error += glm::epsilonEqual(normA, 3.741657387f, 0.00001f) ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
unsigned int oddDepth = 3;
|
|
|
|
float norm = glm::lxNorm(glm::vec3(2, 3, 1), oddDepth);
|
|
|
|
Error += glm::epsilonEqual(norm, 3.301927249f, 0.00001f) ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
unsigned int oddDepth = 3;
|
|
|
|
float norm = glm::lxNorm(glm::vec3(-1, -2, -3), oddDepth);
|
|
|
|
Error += glm::epsilonEqual(norm, 3.301927249f, 0.00001f) ? 0 : 1;
|
|
|
|
}
|
2019-07-19 17:11:07 +00:00
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|
|
|
|
|
2013-10-27 18:25:03 +00:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
int Error(0);
|
|
|
|
|
2019-07-19 17:11:07 +00:00
|
|
|
Error += test_lMaxNorm();
|
2019-07-19 17:28:31 +00:00
|
|
|
Error += test_lxNorm();
|
2019-07-19 17:11:07 +00:00
|
|
|
|
2013-10-27 18:25:03 +00:00
|
|
|
return Error;
|
|
|
|
}
|