1 decade ago by Tradekan
Hey, new guy here... I know I can get the length and angle that one entity is from another, but is it possible to tell if there is an entity directly between the two?
Thanks,
TraDekan
Thanks,
TraDekan
This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact
EntityA
and EntityB
.// returns wether (x,y) point is within ( (x1,y1); (x2,y2) ) segment // and nearer than maxDistance. function isWithin(x, y, x1, y1, x2, y2, maxDistance) { var A = x - x1; var B = y - y1; var C = x2 - x1; var D = y2 - y1; var dot = A * C + B * D; var len_sq = C * C + D * D; var param = dot / len_sq; if ( (param < 0) || (param >1) ) return false; var xx, yy; xx = x1 + param * C; yy = y1 + param * D; return (sq(x-xx)+ sq(y-yy)) < sq(maxDistance); } function sq(x) {return x*x }