tmuecksch Posted July 8, 2015 Share Posted July 8, 2015 Hey there, I'd like to determine the distance between a point and a line. The line is denoted by two pairs of x,y coordinates. Is there a phaser-way of doing this? Thanks in advance! Link to comment Share on other sites More sharing options...
rich Posted July 8, 2015 Share Posted July 8, 2015 You can't determine the distance between a point and a line without deciding where on the line to base the distance from - as it could be a variety of distances away depending where on the line you check it against. Alternatively you can give the point a 'heading' from which you can extrapolate that into a line itself and check for intersection against the other line. Link to comment Share on other sites More sharing options...
stupot Posted July 9, 2015 Share Posted July 9, 2015 Also, do you mean a line segment or an infinite line. I'll wager you want the minimum distance and the answer to be a handy javascript function, a bit like this: http://codemonger.tumblr.com/post/10717903865/distance-from-a-point-to-a-line-in-javascript Link to comment Share on other sites More sharing options...
tmuecksch Posted July 9, 2015 Author Share Posted July 9, 2015 Thank you very much.Yes my question was about the minimum distance between a point and a line segment (I didn't know the english term). Link to comment Share on other sites More sharing options...
Recommended Posts