使用#CGAL的3D网格的三角形的角度 [英] Angles of triangles of a 3D mesh using #CGAL

查看:209
本文介绍了使用#CGAL的3D网格的三角形的角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以使用CGAL函数计算3D网格(用图形表示)的三角形的角度?

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 ?

谢谢

推荐答案

如果您有一个具有三个点abc的非退化三角形,则三角形的角度即余弦a处的角度是两个向量的标量积除以它们的长度:

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);

其中,K是用于这些点的内核类型.角度本身在半径中可以通过以下方式计算:

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);

当然,对于退化的三角形,长度可以为零,并且上面的表达式将计算0./0.(即 not-a-number ).您必须分别处理这种情况.

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.

这篇关于使用#CGAL的3D网格的三角形的角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆