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

Refactor ear clipping algorithm to improve concave and flat triangle detection #2841

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions jsk_recognition_utils/src/pcl/ear_clipping_patched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,17 @@ pcl::EarClippingPatched::isEar (int u, int v, int w, const Vertices& vertices)

// 1: Avoid flat triangles and concave vertex
Eigen::Vector3f cross = p_vu.cross(p_vw);
if ((cross[2] > 0) || (cross.norm() < eps))
return (false);

// Concave vertex condition:
// If the z component of the cross product is less than or equal to zero,
// the triangle is concave, meaning the angle between the vectors is greater than 180 degrees.
if (cross[2] <= 0) {
// Not an ear: concave vertex
return false;
} else if (cross.norm() < eps) {
// Not an ear: flat triangle
return false;
}

Eigen::Vector3f p;
// 2: Check if any other vertex is inside the triangle.
Expand Down
Loading