mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
test_perlin
This commit is contained in:
@@ -8,9 +8,36 @@
|
|||||||
#include "test_common.h"
|
#include "test_common.h"
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, perlin) {
|
TEST_IMPL(GLM_PREFIX, perlin) {
|
||||||
vec4 p = {1.0f, 2.0f, 3.0f, 4.0f};
|
vec4 p1[] = {
|
||||||
|
{0.1f, 0.2f, 0.3f, 0.4f},
|
||||||
|
{0.2f, 0.3f, 0.4f, 0.5f},
|
||||||
|
{0.3f, 0.4f, 0.5f, 0.6f},
|
||||||
|
{0.4f, 0.5f, 0.6f, 0.7f},
|
||||||
|
{0.5f, 0.6f, 0.7f, 0.8f},
|
||||||
|
{0.6f, 0.7f, 0.8f, 0.9f},
|
||||||
|
{0.7f, 0.8f, 0.9f, 1.0f},
|
||||||
|
{0.8f, 0.9f, 1.0f, 1.1f},
|
||||||
|
{0.9f, 1.0f, 1.1f, 1.2f},
|
||||||
|
{1.0f, 1.1f, 1.2f, 1.3f},
|
||||||
|
};
|
||||||
|
|
||||||
|
// expected values calculated by glm::perlin
|
||||||
|
float e[] = {
|
||||||
|
-0.5091819763183594f,
|
||||||
|
-0.4375732541084290f,
|
||||||
|
-0.3212279379367828f,
|
||||||
|
-0.2279999703168869f,
|
||||||
|
-0.1577337533235550f,
|
||||||
|
-0.0445968918502331f,
|
||||||
|
0.1069696992635727f,
|
||||||
|
0.2067739963531494f,
|
||||||
|
0.2106968611478806f,
|
||||||
|
0.1397782564163208f
|
||||||
|
};
|
||||||
|
|
||||||
float out = GLM(perlin)(p);
|
for (int i = 0; i < 10; i++) {
|
||||||
ASSERT(test_eq(out, 10.0f))
|
ASSERT(test_eq(GLM(perlin)(p1[i]), e[i]));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user