I have a few lines connecting points in a comp. These lines are just solids, scaled/positioned/rotated to connect two other layers.

I now want to "fill" the space bounded by sets of lines, so I'm using solids which are corner pinned to warp around as the points, and therefore the lines associated with them, move. So each "fill" layer has 8 layer controls associated with it, two per corner, which define which pair of lines detemine the corner's position at their crossing point.

The problem is, to find out what those positions are, I now have a load of (I think) parallel equations, like this. (This would be for the rightmost point on the green diamond shape - where lines 3 and 5 cross.)

L1 = thisComp.layer("line3");

L2 = thisComp.layer("line4");

p1 = L1.position;

p2 = L2.position;

r1 = degreesToRadians(L1.rotation);

r2 = degreesToRadians(L2.rotation);

// if the crossing point is [x, y]... pseudocode from here on!

x = p1[0] + d1 * Math.cos(r1) = p2[0] + d2 * Math.cos(r2);

y = p1[1] + d1 * Math.sin(r1) = p2[1] + d2 * Math.sin(r2);

// where d1 and d2 are the distances between p1 and [x,y], and p2 and [x,y], respectively.

I know there's probably a neat way of solving these two (basically all I need is to find d1 or d2) but it's years since I had to do this at school (and I was never very good at it anyway) so I'm struggling!