Angles of triangles of a 3D mesh using #CGAL

2019-06-01 06:17发布

问题:

I would like to know if it is possible to compute the angles of triangles of a 3D mesh (represented with a graph) using a function of CGAL ?

Thanks

回答1:

If you have a non-degenerated triangle with three points a, b, and c, the angle of triangle, the cosine of the angle at a is the scalar product of two vectors divided by their lengths:

CGAL::Vector_3<K> v1 = b - a;
CGAL::Vector_3<K> v2 = c - a;
double cosine = v1 * v2 / CGAL::sqrt(v1*v1) / CGAL::sqrt(v2 * v2);

where K is the type of kernel that you are using for the points. The angle itself in radius can be computed by:

double angle = std::acos(cosine);

Of course, for degenerate triangles, the lengths can be zero, and the expression above will compute 0./0. (that is a not-a-number). You have to deal with that case separately.



标签: mesh cgal