def distance(self, o):
        if not isinstance(o, Point3D):
            if is_sequence(o):
                o = Point3D(o)
        if o in self:
            return S.Zero
        s = self.perpendicular_segment(o)
        if not isinstance(s, Point3D):
            non_o = s.p1 if s.p1 == o else s.p2
            if self.contains(non_o):
                return Line3D(self).distance(o)  # = s.length but simpler
        # the following applies when neither of the above apply
        return self.source.distance(o)
Finds the shortest distance between the ray and a point.
dataset/ETHPy150Open sympy/sympy/sympy/geometry/line3d.py/Ray3D.distance