thank youvery much but,if there is a coordinates of triangle (x1, y1, z1), (x2, y2, z2), (x3, y3, z3) how to determine the points of the triangle object belongs
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 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
amina lk
am 26 Feb. 2016
Kommentiert: amina lk
am 28 Feb. 2016
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 Kommentare
Akzeptierte Antwort
Roger Stafford
am 26 Feb. 2016
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 Kommentare
Roger Stafford
am 27 Feb. 2016
Bearbeitet: Roger Stafford
am 27 Feb. 2016
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?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!