## trig

This is done in 2d only.

So ultimately what I'm trying to achieve is...

remainder = shadow_height - length(p,n);

(where remainder should be equal to the distance between m and p I believe)

...the only problem is that I can't figure out how to find n (or m for that matter).

p.s. my math is terrible.

Assuming m,n,p an etc are all 2D vectors (they have an x and y component):

The length of the line between them is the sum of the componentwise differences, all squared, added up and then square rooted again.

ie:

diffx = p.x-n.x

diffy = p.y-n.y

length = sqrt(diffx*diffx + diffy*diffy)

Note that the multiplies effectively remove any minus signs so it doesn't matter which order you subtract - could be n minus p for the same answer.

I hope I haven't made a silly mistake there, I got up literally 20 seconds ago and am still waiting on the kettle for my first coffee...