Jump to content
  • Advertisement

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?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!