Skip to content

Commit 540759c

Browse files
committed
fix(Geometry): return only positive or null value for point_tetrahedron_distance
1 parent cf0296f commit 540759c

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

src/geode/geometry/distance.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -937,16 +937,10 @@ namespace geode
937937
const auto& facet_vertices =
938938
Tetrahedron::tetrahedron_facet_vertex[facet];
939939
const auto& vertices = tetra.vertices();
940-
const auto output = point_triangle_signed_distance( point,
940+
const auto output = point_triangle_distance( point,
941941
Triangle3D{ vertices[facet_vertices[0]],
942942
vertices[facet_vertices[1]], vertices[facet_vertices[2]] } );
943-
// Tetra facet normals point towards inside
944-
if( tetrahedron_volume_sign( tetra ) == Sign::negative )
945-
{
946-
return output;
947-
}
948-
return std::make_tuple(
949-
-std::get< 0 >( output ), std::get< 1 >( output ) );
943+
return output;
950944
}
951945

952946
std::tuple< double, Point3D > point_triangle_signed_distance(

tests/geometry/test-distance.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -748,16 +748,14 @@ void test_point_tetrahedron_distance()
748748
geode::point_tetrahedron_distance( q1, tetra );
749749
OPENGEODE_EXCEPTION( distance == 0 && closest_point == q1,
750750
"[Test] Wrong result for point_tetrahedron_distance with query "
751-
"Point3D "
752-
"q1" );
751+
"Point3D q1" );
753752

754753
const geode::Point3D q2{ { 0.25, 0.25, 0.0 } };
755754
std::tie( distance, closest_point ) =
756755
geode::point_tetrahedron_distance( q2, tetra );
757756
OPENGEODE_EXCEPTION( distance == 0 && closest_point == q2,
758757
"[Test] Wrong result for point_tetrahedron_distance with query "
759-
"Point3D "
760-
"q2" );
758+
"Point3D q2" );
761759

762760
const geode::Point3D q3{ { 2.5, 2.5, 0.0 } };
763761
std::tie( distance, closest_point ) =
@@ -766,8 +764,7 @@ void test_point_tetrahedron_distance()
766764
OPENGEODE_EXCEPTION(
767765
distance == std::sqrt( 8 ) && closest_point.inexact_equal( answer ),
768766
"[Test] Wrong result for point_tetrahedron_distance with query "
769-
"Point3D "
770-
"q3" );
767+
"Point3D q3" );
771768
};
772769

773770
const geode::Point3D a{ { 0.0, 0.0, 0.0 } };

0 commit comments

Comments
 (0)