@@ -105,30 +105,30 @@ void test_point_segment_distance_3d()
105105 distance = geode::point_segment_distance ( a, segment3D );
106106 OPENGEODE_EXCEPTION ( distance < geode::GLOBAL_EPSILON
107107 && geode::point_segment_projection ( a, segment3D )
108- .inexact_equal ( a ),
108+ .inexact_equal ( a ),
109109 " [Test] Wrong result for point_segment_distance with query Point3D "
110110 " a" );
111111
112112 distance = geode::point_segment_distance ( b, segment3D );
113113 OPENGEODE_EXCEPTION ( distance < geode::GLOBAL_EPSILON
114114 && geode::point_segment_projection ( b, segment3D )
115- .inexact_equal ( b ),
115+ .inexact_equal ( b ),
116116 " [Test] Wrong result for point_segment_distance with query Point3D "
117117 " b" );
118118
119119 const geode::Point3D q1{ { 0.0 , 0.0 , 0.0 } };
120120 distance = geode::point_segment_distance ( q1, segment3D );
121121 OPENGEODE_EXCEPTION ( distance < geode::GLOBAL_EPSILON
122122 && geode::point_segment_projection ( q1, segment3D )
123- .inexact_equal ( q1 ),
123+ .inexact_equal ( q1 ),
124124 " [Test] Wrong result for point_segment_distance with query Point3D "
125125 " q1" );
126126
127127 const geode::Point3D q2{ { 10.0 , 10.0 , 10.0 } };
128128 distance = geode::point_segment_distance ( q2, segment3D );
129129 OPENGEODE_EXCEPTION ( distance == std::sqrt ( 170 )
130130 && geode::point_segment_projection ( q2, segment3D )
131- .inexact_equal ( a ),
131+ .inexact_equal ( a ),
132132 " [Test] Wrong result for point_segment_distance with query Point3D "
133133 " q2" );
134134
@@ -137,7 +137,7 @@ void test_point_segment_distance_3d()
137137 const geode::Point3D result_q3{ { 0.0 , 0.0 , 0.0 } };
138138 OPENGEODE_EXCEPTION ( distance == std::sqrt ( 26 )
139139 && geode::point_segment_projection ( q3, segment3D )
140- .inexact_equal ( result_q3 ),
140+ .inexact_equal ( result_q3 ),
141141 " [Test] Wrong result for point_segment_distance with query Point3D "
142142 " q3" );
143143
@@ -149,7 +149,7 @@ void test_point_segment_distance_3d()
149149 std::sqrt ( 5.05 * 5.05 + 0.75 * 0.75 + 0.65 * 0.65 ) - distance )
150150 < geode::GLOBAL_EPSILON
151151 && geode::point_segment_projection ( q4, segment3D )
152- .inexact_equal ( result_q4 ),
152+ .inexact_equal ( result_q4 ),
153153 " [Test] Wrong result for point_segment_distance with query Point3D "
154154 " q4" );
155155}
@@ -597,7 +597,7 @@ void test_point_line_distance_2d()
597597 OPENGEODE_EXCEPTION (
598598 std::fabs ( std::sqrt ( 26 ) - distance ) < geode::GLOBAL_EPSILON
599599 && geode::point_line_projection ( q2, line2D )
600- .inexact_equal ( result_q2 ),
600+ .inexact_equal ( result_q2 ),
601601 " [Test] Wrong result for point_line_distance with query Point2D "
602602 " q2" );
603603}
@@ -647,7 +647,7 @@ void test_point_line_signed_distance_2d()
647647 OPENGEODE_EXCEPTION (
648648 std::fabs ( std::sqrt ( 26 ) - distance ) < geode::GLOBAL_EPSILON
649649 && geode::point_line_projection ( q3, line2D )
650- .inexact_equal ( result_q3 ),
650+ .inexact_equal ( result_q3 ),
651651 " [Test] Wrong result for point_line_signed_distance with query Point2D "
652652 " q3" );
653653
@@ -657,7 +657,7 @@ void test_point_line_signed_distance_2d()
657657 OPENGEODE_EXCEPTION (
658658 std::fabs ( -std::sqrt ( 26 ) - distance ) < geode::GLOBAL_EPSILON
659659 && geode::point_line_projection ( q4, line2D )
660- .inexact_equal ( result_q3 ),
660+ .inexact_equal ( result_q3 ),
661661 " [Test] Wrong result for point_line_signed_distance with query Point2D "
662662 " q4" );
663663}
@@ -699,7 +699,7 @@ void test_point_line_distance_3d()
699699 OPENGEODE_EXCEPTION (
700700 std::fabs ( std::sqrt ( 26 ) - distance ) < geode::GLOBAL_EPSILON
701701 && geode::point_line_projection ( q2, line3D )
702- .inexact_equal ( result_q2 ),
702+ .inexact_equal ( result_q2 ),
703703 " [Test] Wrong result for point_line_distance with query Point3D "
704704 " q2" );
705705}
@@ -1127,14 +1127,16 @@ void test_point_ellipse_distance_2d_not_aligned()
11271127{
11281128 const geode::Point2D center{ { 0.0 , 0.0 } };
11291129 const geode::Vector2D first_axis{ { 1.0 , 1.0 } };
1130- const geode::Vector2D second_axis{ { -1 .0 , 1 .0 } };
1130+ const geode::Vector2D second_axis{ { -2 .0 , 2 .0 } };
11311131 const geode::Frame2D frame{ { first_axis, second_axis } };
11321132 const geode::Ellipse2D ellipse{ center, frame };
11331133 const geode::Point2D point{ { 2.0 , 2.0 } };
11341134 const auto [distance, closest_point] =
11351135 geode::point_ellipse_distance ( point, ellipse );
11361136 const geode::Point2D result{ { 1.0 , 1.0 } };
1137- OPENGEODE_EXCEPTION ( closest_point.inexact_equal ( result ),
1137+ OPENGEODE_EXCEPTION (
1138+ std::fabs ( std::sqrt ( 2 ) - distance ) < geode::GLOBAL_EPSILON
1139+ && closest_point.inexact_equal ( result ),
11381140 " [Test] Wrong result for point_ellipse_distance_2d_not_aligned" );
11391141}
11401142
@@ -1180,11 +1182,18 @@ void test_point_ellipse_distance_3d()
11801182 && outside3_closest_point.inexact_equal ( result_outside3 ),
11811183 " [Test] Wrong result for point_ellipse_distance_3d with outside3 "
11821184 " point" );
1185+ const auto [inside_distance, inside_closest_point] =
1186+ geode::point_ellipse_distance ( center, ellipse );
1187+ const geode::Point3D result_inside{ { 0 , 0 , 1 } };
1188+ OPENGEODE_EXCEPTION (
1189+ inside_distance == 1
1190+ && inside_closest_point.inexact_equal ( result_inside ),
1191+ " [Test] Wrong result for point_ellipse_distance_3d with inside "
1192+ " point" );
11831193}
11841194
11851195void test_point_ellipse_distance ()
11861196{
1187- geode::Logger::set_level ( geode::Logger::LEVEL::trace );
11881197 test_point_ellipse_distance_2d ();
11891198 test_point_ellipse_distance_3d ();
11901199 test_point_ellipse_distance_2d_not_aligned ();
0 commit comments