I have a list of triangles of the mesh and point cloud. the question is :how to determine each point belongs to a triangle

2 次查看(过去 30 天)
I have a list of triangles of the mesh and point cloud. the question is :how to determine each point belongs to a triangle
  5 个评论

请先登录,再进行评论。

采纳的回答

Roger Stafford
Roger Stafford 2016-2-26
Let the points (x1,y1), (x2,y2), and (x3,y3) be the three vertices of a triangle, and let (x,y) be some arbitrary point. Define:
c1 = (x2-x1)*(y3-y1)-(x3-x1)*(y2-y1);
p1 = (x2-x) *(y3-y) -(x3-x) *(y2-y) ;
c2 = (x3-x2)*(y1-y2)-(x1-x2)*(y3-y2);
p2 = (x3-x) *(y1-y) -(x1-x) *(y3-y) ;
c3 = (x1-x3)*(y2-y3)-(x2-x3)*(y1-y3);
p3 = (x1-x) *(y2-y) -(x2-x) *(y1-y) ;
Then the point (x,y) lies inside or on the triangle if:
sign(c1)*sign(p1) >= 0 & sign(c2)*sign(p2) >= 0 & sign(c3)*sign(p3) >= 0
  2 个评论
Roger Stafford
Roger Stafford 2016-2-27
编辑:Roger Stafford 2016-2-27
Two points.
1) My apologies! I made the computations more complicated than they need be. The quantities c1, c2, and c3 are all identically equal, so you need only calculate one of them. They are each twice the signed area of the (straight-lined) triangle. with the sign determined by whether (x1,y1), (x2,y2), (x3,y3) are in counterclockwise or clockwise order around the triangle.
2) In answer to your question of triangles in three-dimensional space, that is a somewhat different situation. Your arbitrary point (x,y,z) has to be shown to lie in the same plane as that of the triangle, if that is what you mean by "belongs to", in addition to satisfying three inequalities. Do you want me to show how this is to be determined?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Point Cloud Processing 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by