mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Fixed reflect and refract test
This commit is contained in:
parent
3aa30ff67c
commit
0cd665c4ca
@ -8,23 +8,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/epsilon.hpp>
|
||||
|
||||
int test_reflect()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f, 0.0f);
|
||||
glm::vec2 A(1.0f,-1.0f);
|
||||
glm::vec2 B(0.0f, 1.0f);
|
||||
glm::vec2 C = glm::reflect(A, B);
|
||||
Error += C == glm::vec2(-1.0, 0.0) ? 0 : 1;
|
||||
Error += C == glm::vec2(1.0, 1.0) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::dvec2 A(1.0f, 0.0f);
|
||||
glm::dvec2 A(1.0f,-1.0f);
|
||||
glm::dvec2 B(0.0f, 1.0f);
|
||||
glm::dvec2 C = glm::reflect(A, B);
|
||||
Error += C == glm::dvec2(-1.0, 0.0) ? 0 : 1;
|
||||
Error += C == glm::dvec2(1.0, 1.0) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
@ -35,24 +36,24 @@ int test_refract()
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
float A(1.0f);
|
||||
float A(-1.0f);
|
||||
float B(1.0f);
|
||||
float C = glm::refract(A, B, 0.5f);
|
||||
Error += C == 1.0f ? 0 : 1;
|
||||
Error += C == -1.0f ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f, 0.0f);
|
||||
glm::vec2 A(0.0f,-1.0f);
|
||||
glm::vec2 B(0.0f, 1.0f);
|
||||
glm::vec2 C = glm::refract(A, B, 0.5f);
|
||||
Error += C == glm::vec2(-1.0, 0.0) ? 0 : 1;
|
||||
Error += glm::all(glm::equalEpsilon(C, glm::vec2(0.0, -1.0), 0.0001f)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::dvec2 A(1.0f, 0.0f);
|
||||
glm::dvec2 A(0.0f,-1.0f);
|
||||
glm::dvec2 B(0.0f, 1.0f);
|
||||
glm::dvec2 C = glm::refract(A, B, 0.5);
|
||||
Error += C == glm::dvec2(-1.0, 0.0) ? 0 : 1;
|
||||
Error += C == glm::dvec2(0.0, -1.0) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
|
Loading…
Reference in New Issue
Block a user