Maths pain, trying to plot a certain point inside a triangle

Hello all,

I’m Phil, been a PHP web guy for about a decade and this year I’ve been digging into some objective C app dev and playing with openframeworks for a couple of weeks. Now the code side of things isn’t a problem, but it’s been 15ish years since I left school and did much more than basic arithmetic and I’m stuck on something I’m trying.

What I’d like to do is draw and equilateral triangle composed of a red, green, and blue triangle proportioned to represent an RGB colour. Working out the relative percentage area’s of the equilateral isn’t a problem, but plotting the point where they meet is.

I knocked up a diagram http://philrennie.co.uk/openframeworks/fourmasssets/pointp.jpg

For equilateral triangle ABC, I’d like to work out the coordinates of point P if for example
Tri APC = 30% the area of ABC
Tri ABP = 20% the area of ABC
Tri CPB = 50% the area of ABC

I’ve found I can get the lengths for lines x, y and z using height = (2 * area) / base, but now I’m a bit stumped find P to satisfy the constraints.

I’m also assuming that given there will be a bunch of fractional numbers involved that may never add up to exactly 100% of the overall area, if I can find P given just two of the areas I can let the third one eat up the rounding errors.

I’ve googled around and did find some info on ternary plots that looked like it might be helpful but I can’t make any sense of the equations listed as the notation is all greek to me now.
http:// en.wikipedia.org/wiki/Ternary_plot
(excuse me breaking the link, the forum software complained about the number of links I can make as a new user)

I’m running right up against the old saying ‘use it or lose it’ when it comes to my maths at the moment :smile:
The end goal I’m looking for is to fill the screen with a load of these equilaterals tessellated, then I’m going to treat them as huge ‘pixels’ pulling their colours from the webcam to achieve a very low-res version of the image. Speaking to the camera, pulling out pixel info, drawing the poly’s I’m fine with, it’s just the pesky maths.

here’s the unbroken wikipedia link