Archived

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

archangle

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

Recommended Posts

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
--->x


You 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 this post


Link to post
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 this post


Link to post
Share on other sites