Jump to content
  • Advertisement

Archived

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

RajanSky

Barycentric coordinates

This topic is 5893 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

Hi all! I wrote some code today which, given a point on a triangle in 3D, it gives the texture coordinates u and v for that point. I used barycentric coordinates to do this. I get the gist of it, basically you''re making a change of basis where your 3 vectors are the 3 vertices of the triangle, etc. I was wondering if anyone knows, is this method really correct or is it just an approximation that looks good? I can''t seem to reason out why this works. Intuitively it makes sense but I can''t prove why it works... Thanks! Rajan

Share this post


Link to post
Share on other sites
Advertisement
Barycentric coords are a really nice thing. Few people understand what they really are (although it''s really easy once you know ), they can be incredibly useful.

It depends a bit on how exactly you did the math, but normally it should be correct. Barycentric coordinates are simply another way to specify a point on a plane, with the additional constraint, that it must be *inside* of the triangle.

Your 3 barycentric coords (u,v,w), ranging from 0 to 1, specify a point on the triangle using the following equation: P = uA + vB + wC. Where A,B,C are the 3 vertices of your triangle. Note also that u + v + w = 1.

So to check the validity of your equation, just check them against the constraints of the barycentric equation. See if all your barycentric coords are between 0 and 1, and if they sum up to 1. In that case, they specify a valid point on the plane and inside of your triangle.

/ Yann

Share this post


Link to post
Share on other sites
Thanks Yann! It makes a little more sense now and I can definitely visualize how it works. I still wonder how one could prove it mathematically but for now this is good enough so again, thank you

Amish- I''m using barycentric coordinates to texture a triangle. What it means is that we have a triangle with three points in 3d space- A, B, and C. Our goal is that, if we are given a point on the triangle, P, we can calculate the barycentric coordinates u, v and w, such that:
Au + Bv + Cw = P

I won''t go into the details but basically using barycentric coordinates makes the job of calculating texture coordinates a lot easier.

Rajan

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!