| 33 | #include <geode/tests/common.hpp> |
| 34 | |
| 35 | void 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 | |
| 65 | OPENGEODE_TEST( "distance" ) |