trig
![[Image: diagram_.jpg]](http://i1095.photobucket.com/albums/i470/ars556655/diagram_.jpg)
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.
Whoa, I'm struggling with this given your diagram looks 3D.
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...
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...

