MCPcopy Create free account
hub / github.com/Geode-solutions/OpenGeode / test

Function test

tests/geometry/test-triangle.cpp:35–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33#include <geode/tests/common.hpp>
34
35void test()
36{
37 const geode::Point3D a{ { 0.0, 0.0, 0.0 } };
38 const geode::Point3D b_ref{ { 0.5, 0.1, 0.0 } };
39 const geode::Point3D b{ { 0.6, 0.3 * geode::GLOBAL_EPSILON, 0.0 } };
40 const geode::Point3D c{ { 1.0, 0.0, 0.0 } };
41
42 const geode::Vector3D answer{ { 0, 0, -1 } };
43
44 const geode::Triangle3D triangle_ref{ a, b_ref, c };
45 const auto normal_ref = triangle_ref.normal();
46 geode::OpenGeodeGeometryException::test( normal_ref.has_value(),
47 "Normal of reference triangle should be calculated" );
48 geode::OpenGeodeGeometryException::test(
49 normal_ref.value() == answer, "Wrong normal of reference triangle" );
50 const auto pivot_ref = triangle_ref.pivot();
51 geode::OpenGeodeGeometryException::test( pivot_ref.has_value(),
52 "Pivot of reference triangle should be calculated" );
53 geode::OpenGeodeGeometryException::test(
54 pivot_ref.value() == 0, "Wrong pivot of reference triangle" );
55
56 const geode::Triangle3D triangle2{ a, b, c };
57 const auto normal2 = triangle2.normal();
58 geode::OpenGeodeGeometryException::test(
59 !normal2, "Normal of triangle2 should not be calculated" );
60 const auto pivot2 = triangle2.pivot();
61 geode::OpenGeodeGeometryException::test(
62 !pivot2, "Pivot of triangle2 should not be calculated" );
63}
64
65OPENGEODE_TEST( "distance" )

Callers

nothing calls this directly

Calls 3

pivotMethod · 0.80
normalMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected