MCPcopy Create free account
hub / github.com/PDAL/PDAL / TEST

Function TEST

test/unit/MathUtilsTest.cpp:43–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41{
42
43TEST(MathUtilsTest, barycentric)
44{
45 using namespace math;
46
47 // Triangle (1, 1), (5, 4), (3, 6) -- z's 55, 25, 100
48 double x1 = 1;
49 double y1 = 1;
50 double z1 = 55;
51 double x2 = 5;
52 double y2 = 4;
53 double z2 = 25;
54 double x3 = 3;
55 double y3 = 6;
56 double z3 = 100;
57
58 struct point
59 {
60 double x;
61 double y;
62 };
63
64 std::vector<point> points { { 3, 3 }, {4, 2}, {5, 4}, {4, 6}, {1, 5},
65 {4, 5}, {2, 7.0 / 4}, {3, 4}, {3, 6} };
66
67 double inf = std::numeric_limits<double>::infinity();
68 std::vector<double> results { 48.57142857142, inf, 25, inf, inf,
69 62.5, 47.5, 65.7142857142, 100 };
70
71 double z;
72 for (size_t i = 0; i < points.size(); ++i)
73 {
74 const point& p = points[i];
75 z = barycentricInterpolation(x1, y1, z1, x2, y2, z2, x3, y3, z3, p.x, p.y);
76 if (std::isinf(results[i]))
77 EXPECT_TRUE(std::isinf(z));
78 else
79 EXPECT_NEAR(z, results[i], .0000000001);
80 }
81
82 // Re-order triangle points (x2 is before x1 in input). Results should be the same.
83 for (size_t i = 0; i < points.size(); ++i)
84 {
85 const point& p = points[i];
86 z = barycentricInterpolation(x2, y2, z2, x1, y1, z1, x3, y3, z3, p.x, p.y);
87 if (std::isinf(results[i]))
88 EXPECT_TRUE(std::isinf(z));
89 else
90 EXPECT_NEAR(z, results[i], .0000000001);
91 }
92}
93
94TEST(MathUtilsTest, bary_issue_4694)
95{

Callers

nothing calls this directly

Calls 2

barycentricInterpolationFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected