#### Archived

This topic is now archived and is closed to further replies.

# in basic code how do i know if said coord are "in" a triangle?

This topic is 5428 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

in basic code how do i get true or false if x,y,z are in a 3d triangle and how do i know which triangle?

##### Share on other sites
The problem here is you have to apply a tolerance because due to numerical precision, your point will rarely be exactly on the triangle.

Else conceptually it''s just an affine transform from world space to triangle space. Triangle (A,B,C) is equivalent to referential and 3D matrix :
U=B-A, V=C-A, W=normalize(U^V), O=A; // cross product

U,V,W,T seen in columns is just a 4*3 matrix ( 0,0,0,1 and it''s a 4*4)

Just inverse this matrix and you get
toTriangle( T, P );
Where T is a 3D point in triangle space. checking if the point belongs to Tri is just :

T.x + T.y < 1, T.x>0, T.y>0
and abs(T.z) < tolerance.

y| \|   \          t in tri is x+y<1 --->xYou can speed up this computation by developping simplifying the equations. I let it to you. In fact it''s the same thing seeing 4 plane equations. One for each edge with the triangle normal. One for the support plane. But it will be faster than an explicit matrix inversion which costs a division.



##### Share on other sites
Thanks Charles but...............
If I could give current rotation values of the said 3D triangle
new ones or add to the old ones 3 exact value that will make it face the camera (normal position?). Then I could rotate a 3d grid using the reverse values and scan the 3d triangle!
but how do I get those exact rotational differances?
XZ ROT TO NORMAL=_?_
YZ ROT TO NORMAL=_?_
XY ROT TO NORMAL=_?_
THESE VALUE WOULD MAKE THE SAID TRIANGLE FACE THE CAMERA

##### Share on other sites
Check question #9 in the forum FAQ:

Forum FAQ

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

1. 1
2. 2
3. 3
4. 4
frob
20
5. 5
JoeJ
20

• 11
• 11
• 12
• 13
• 9
• ### Forum Statistics

• Total Topics
632214
• Total Posts
3004857

×