'Finds the shortest distance between the ray and a point.
Raises
NotImplementedError is raised if `other` is not a Point
Examples
>>> from sympy import Point, Ray
>>> p1, p2 = Point(0, 0), Point(1, 1)
>>> s = Ray(p1, p2)
>>> s.distance(Point(-1, -1))
sqrt(2)
>>> s.distance((-1, 2))
3*sqrt(2)/2
>>> p1, p2 = Point(0, 0, 0), Point(1, 1, 2)
>>> s = Ray(p1, p2)
>>> s
Ray3D(Point3D(0, 0, 0), Point3D(1, 1, 2))
>>> s.distance(Point(-1, -1, 2))
4*sqrt(3)/3
>>> s.distance((-1, -1, 2))
4*sqrt(3)/3'

def distance(self, other):

    if (not isinstance(other, GeometryEntity)):
        other = Point(other, dim=self.ambient_dimension)
    if self.contains(other):
        return S.Zero
    proj = Line(self.p1, self.p2).projection(other)
    if self.contains(proj):
        return abs((other - proj))
    else:
        return abs((other - self.source))
