- Joined
- Jul 10, 2007
- Messages
- 6,306
JASS:
library IsPointOnVector
//checks to see if point px is on vector [(vx1, vy1), (vx2, vy2)]
function IsPointOnVector takes real vx1, real vy1, real vx2, real vy2, real px, real py returns boolean
return (/*
first see if px, py is on either end of the vector
*/(vx1 == px and vy1 == py) or (vx2 == px and vy2 == py)) or/*
if no, make sure that the change in x is not 0
*/((vx2 != px and vx1 != px) and/*
make sure slopes are equal (lies on the line)
*/((vy2-vy1)/(vx2-vx1) == (py-vy1)/(px-vx1)) and/*
make sure that it's between end points of vector
*/((vx2 > vx1 and vx1 <= px and vx2 >= px) or (vx2 <= px and vx1 >= px))/*
*/)
endfunction
endlibrary
Last edited: