Advertisement

Remapping barycentric coordinates to barycentric coordinates of a sub-triangle?

Started by February 20, 2015 04:27 AM
2 comments, last by coderchris 9 years, 11 months ago

I have point defined by barycentric coordinates. I DO NOT have the 3 points of the triangle.

Now, I split this triangle in two at the mid point of y, z = w.

With this new triangle, I want to remap the barycentric coordinates of my point.

The point is guaranteed to be in the triangle to the right of the split. More technically, p = (a, b, c) -> b > c

Does anyone have some insight into how I might derive a formula for this mapping?

[attachment=26008:problem.png]

Ah just figured it out. Don't know if anyone will ever have this problem but here is the solution:


if (coords.y > coords.z)
    new_coords = vec3(coords.x, coords.y - coords.z, coords.z + coords.z);
else
    new_coords = vec3(coords.x, coords.y + coords.y, coords.z - coords.y);
Advertisement

And the derivation is:

The point does not change its cartesian co-ordinates, so

p( a,b,c ) = p( a',b',c' )

where

p( a,b,c ) = a * p1 + b * p2 + c * p3

p( a',b',c' ) = a' * p1 + b' * p2 + c' * ( p2 + p3 ) / 2

which gives (by comparing the coefficients)
a' = a
b' = b - c' / 2 = b - c
c' = 2 c
That matches your solution for b > c. It does not hint at the need for a case distinction. Now, if c < b, then p would be outside the nominated sub-triangle. As such a', b', and c' cannot all be positive.
So ... I'm not sure why you made the case distinction!?

Ah thanks for the derivation! I used the brute force method for finding the solution wacko.png

The reason that snippet has the case distinction is because I wanted to rearrange the point ordering depending on which side its on but your explanation makes total sense - you don't really need the case distinction.

This topic is closed to new replies.

Advertisement