#### Archived

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

# Parametric Triangle Representation

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

## Recommended Posts

I know this is simple, but I''m having a brain meltdown right now...I''ve looked through all my books I have and can''t seem to find anything regarding parametric representation of triangles. I''ve done a Ray-Triangle intersection test. As a result of a successful intersection, I end up with U & V coordinates for the triangle. Here is my question... How do I compute the X,Y,Z coordinates of the intersection based upon the U & V coordinates? Here is what I''ve done so far. It "feels" correct, but something about the results don''t seem to work 100% of the time V = Triangle Vertex P = Intersection Point Edge1=V1-V0; Edge2=V2-V0; P=V0+Edge1*U+Edge2*V Any pointers will be greatly appreciated. Dean M.

##### Share on other sites
ok.. for ray-triangle intersection (or ray-anything intersection ) it''s easier to work with the Q(t)=Q+vt form, all you have to do is plug that into the plane equation, get the intersection point at Q+vt for the given t and then find out if the intersection point is within the triangle.

i don''t really understand what you mean by "U & V coordinates for the triangle".. are those supposed to be 2d coordinates in the triangle''s plane, or is U an offset along two edges with V being a distance along the resulting vector, or what?

-goltrpoat

--
Float like a butterfly, bite like a crocodile.

##### Share on other sites
The u,v coordinates that you are getting from the intersection are called barycentric coordinates. The x,y,z coordinates are computed with:

P = (1-u-v)*V0 + u*V1 + v*V2

This just happens to be what you have already figured out, just a little rearrangement of the terms.

With the barycentric coordinates it is real easy to test if the point is within the triangle. For the point to be within the following conditions must hold:

u >= 0
v >= 0
u+v <= 1

- WitchLord

##### Share on other sites
Thanks for the help...I updated my code with the correct way to determine the intersection point and I am up and going.

I''m going to have to do some reading up on barycentric coordinates. I''ve seen that term thrown around, but haven''t yet taken the time to actually understand what it is.

If you are curious: I am writing a sort of level editor (non-gaming related, eventually I get around to writing games). It is for architectural walkthroughs. But, game technologies and techniques are exactly what this project calls for.

With this piece of information (the intersection point), I now have 100% accurate polygon selection with the mouse working. I''m able to determine the polygon with the closest intersection point to the camera and highlight it for the user to do something. It is really quite pleasing to see this work perfectly.

Dean M.

p.s. I apologize for posting in the "wrong" forum, I am still learning this board and didn''t actually realize where I was posting, that won''t happen in the future

• 10
• 13
• 52
• 11
• 15