Angles of triangles of a 3D mesh using #CGAL

不羁岁月 提交于 2019-12-08 08:59:50

问题


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.



来源:https://stackoverflow.com/questions/29435384/angles-of-triangles-of-a-3d-mesh-using-cgal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!