Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Geometry): adding new tetrahedron quality metric (volume to edge ratio). #1061

Merged
merged 5 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/geode/geometry/quality.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ namespace geode
{
[[nodiscard]] double opengeode_geometry_api tetrahedron_aspect_ratio(
const Tetrahedron& tetra );
[[nodiscard]] double opengeode_geometry_api
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[[nodiscard]] double opengeode_geometry_api
[[nodiscard]] double opengeode_geometry_api

tetrahedron_volume_to_edge_ratio( const Tetrahedron& tetra );
} // namespace geode
23 changes: 23 additions & 0 deletions src/geode/geometry/quality.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is the modification in the hpp?

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <limits>

#include <geode/geometry/basic_objects/tetrahedron.hpp>
#include <geode/geometry/mensuration.hpp>
#include <geode/geometry/vector.hpp>

namespace geode
Expand Down Expand Up @@ -64,4 +65,26 @@ namespace geode
constant * longest_edge_length * total_area2 / absolute_det;
return aspect_ratio;
}

double tetrahedron_volume_to_edge_ratio( const Tetrahedron& tetra )
{
const auto signed_volume = geode::tetrahedron_signed_volume( tetra );
double sq_len{ 0 };
const auto& vertices = tetra.vertices();
for( const auto v0 : geode::LRange{ 3 } )
{
const auto& point0 = vertices[v0].get();
for( const auto v1 : geode::LRange{ v0, 4 } )
{
const auto& point1 = vertices[v1].get();
for( const auto d : geode::LRange{ 3 } )
{
const auto diff = point0.value( d ) - point1.value( d );
sq_len += diff * diff;
}
}
}
const auto l_rms = std::sqrt( sq_len / 6 );
return 6 * std::sqrt( 2 ) * signed_volume / ( l_rms * l_rms * l_rms );
BenoitTHEBAULT marked this conversation as resolved.
Show resolved Hide resolved
}
} // namespace geode
Loading