From: <ron@do...>  20010131 15:13:04

oles wrote: >Already solved :) > >N =3D (Direction.y, Direction.x) >c =3D N.dot(StartPoint) > >distance_to_P =3D N.dot(P) + c > >Correct? > No, not always. In the first place, assuming that your Direction vector is a unit vector, this will give a signed distance (not what one usually means by "distance"). The sign is negative if the point lies on the right side of the line of the ray as you look in the direction of the ray (provided that your coordinate axis definition is the usual one). Take its absolute value to get an ordinary distance. =20 In the second place, this does not always give the distance from the point to the ray, but rather always the distance from the point to the line containing the ray. This will not be the same as the distance from the point to the ray if=20 Direction dot (P  StartPoint) < 0 In this case, P lies in the "back" halfplane defined by the line through StartPoint perpendicular to the ray and the distance from P to the ray is just the distance from P to StartPoint. 