Add cylindrical mapping!

This commit is contained in:
Godzil
2020-03-04 16:16:35 +00:00
parent 1b6c14691b
commit 7209244f48
6 changed files with 123 additions and 3 deletions

View File

@@ -387,4 +387,46 @@ TEST(PatternTest, Using_a_planar_mapping_on_a_3d_point)
ASSERT_TRUE(double_equal(u, testResults[i][0]));
ASSERT_TRUE(double_equal(v, testResults[i][1]));
}
}
TEST(PatternTest, Using_a_cylindrical_mapping_on_a_3d_point)
{
Point testList[] = {
Point( 0.00000, 0.00, -1.00000),
Point( 0.00000, 0.50, -1.00000),
Point( 0.00000, 1.00, -1.00000),
Point( 0.70711, 0.50, -0.70711),
Point( 1.00000, 0.50, -0.00000),
Point( 0.70711, 0.50, 0.70711),
Point( 0.00000, -0.25, 1.00000),
Point(-0.70711, 0.50, 0.70711),
Point(-1.00000, 1.25, 0.00000),
Point(-0.70711, 0.50, -0.70711),
};
double testResults[][2] {
{0.000, 0.00},
{0.000, 0.50},
{0.000, 0.00},
{0.125, 0.50},
{0.250, 0.50},
{0.375, 0.50},
{0.500, 0.75},
{0.625, 0.50},
{0.750, 0.25},
{0.875, 0.50},
};
int testCount = sizeof(testList)/sizeof((testList)[0]);
int i;
TextureMap tm = TextureMap(CYLINDRICAL_MAP, nullptr);
for(i = 0; i < testCount; i++)
{
double u, v;
tm.cylindricalMap(testList[i], u, v);
ASSERT_TRUE(double_equal(u, testResults[i][0]));
ASSERT_TRUE(double_equal(v, testResults[i][1]));
}
}