繁体   English   中英

使用#CGAL的2D网格的三角形的角度

[英]Angles of triangles of a 2D mesh using #CGAL

对于2D网格,已经存在此问题的答案: 使用#CGAL的3D网格的三角形角度

我知道,对于2D,答案是不同的。 那么:如何在CGAL中计算2D网格的三角形的角度? 我可以通过成对获取顶点及其各自的Vector,但我正在寻找一种直接计算角度的方法,而无需检查它是外角还是内角。

如果有任何不同,则该网格由CDT生成。

没关系,但是我认为这可能会对某人有所帮助,因为Laurent Rineauin在最初的3D网格问题中的评论提出解决方案是不同的。 所以这里是:

// faces_iterator iterates through the triangles of l_cdt CDT triangulation

CGAL::Point_2<K> vertex1 = l_cdt.triangle(faces_iterator)[0];
CGAL::Point_2<K> vertex2 = l_cdt.triangle(faces_iterator)[1];
CGAL::Point_2<K> vertex3 = l_cdt.triangle(faces_iterator)[2];

double a = CGAL::sqrt((vertex2.x() - vertex3.x()) * (vertex2.x() - vertex3.x()) + (vertex2.y() - vertex3.y()) * (vertex2.y() - vertex3.y()));
double b = CGAL::sqrt((vertex1.x() - vertex3.x()) * (vertex1.x() - vertex3.x()) + (vertex1.y() - vertex3.y()) * (vertex1.y() - vertex3.y()));
double c = CGAL::sqrt((vertex2.x() - vertex1.x()) * (vertex2.x() - vertex1.x()) + (vertex2.y() - vertex1.y()) * (vertex2.y() - vertex1.y()));

// constants::PI is just π, for conversion to degrees instead of radians 
double angle1 = ((std::acos((b*b + c*c - a*a) / (2*b*c))) * 180) / constants::PI;
double angle2 = ((std::acos((a*a + c*c - b*b) / (2*a*c))) * 180) / constants::PI;
double angle3 = ((std::acos((a*a + b*b - c*c) / (2*b*a))) * 180) / constants::PI;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM