Skip to content

Instantly share code, notes, and snippets.

@juliangaal
Last active November 11, 2020 07:45
Show Gist options
  • Save juliangaal/b9ccd272d98dd7cd1fd97bea3dab4f03 to your computer and use it in GitHub Desktop.
Save juliangaal/b9ccd272d98dd7cd1fd97bea3dab4f03 to your computer and use it in GitHub Desktop.
TriMesh::HalfedgeHandle heh_init = mesh->halfedge_handle(vh);
auto heh = heh_init;
/** Loop die vertices der reihe nach abgeht:
* * ausgehend vom inserteten vertex
* * sprung zum naechst aeusseren vertex
* * speicher der outside edge zur uberpruefung von delaunay
* * sprung zurueck in die "mitte"
*/
do {
auto current_vh = mesh->to_vertex_handle(heh);
auto outside_eh = mesh->edge_handle(mesh->halfedge_handle(current_vh));
std::cout << std::boolalpha << current_vh.idx() << ": " << isDelaunay(mesh, outside_eh) << "\n";
heh = mesh->opposite_halfedge_handle(heh);
heh = mesh->next_halfedge_handle(heh);
} while (heh != heh_init);
// --
// isDelaunay()
// --
// Calculate angles alpha (at a) and delta (at d). theta = arccos( skalar(va, vb) / norm(va) * norm(vb) )
// If their sum is larger than 180 Deg, the edge is not delaunay
auto v_ac = c - a;
auto v_ab = b - a;
double angle_a = std::acos(v_ac.dot(v_ab) / (v_ac.norm() * v_ab.norm()));
auto v_dc = c - d;
auto v_db = b - d;
double angle_d = std::acos(v_dc.dot(v_db) / (v_dc.norm() * v_db.norm()));
return (angle_a + angle_d) < 180.f;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment