'Distance beteen the plane and another geometric entity.
Parameters
Point3D, LinearEntity3D, Plane.
Returns
distance
Notes
This method accepts only 3D entities as it\'s parameter, but if you want
to calculate the distance between a 2D entity and a plane you should
first convert to a 3D entity by projecting onto a desired plane and
then proceed to calculate the distance.
Examples
>>> from sympy import Point, Point3D, Line, Line3D, Plane
>>> a = Plane(Point3D(1, 1, 1), normal_vector=(1, 1, 1))
>>> b = Point3D(1, 2, 3)
>>> a.distance(b)
sqrt(3)
>>> c = Line3D(Point3D(2, 3, 1), Point3D(1, 2, 2))
>>> a.distance(c)
0'

def distance(self, o):

    from sympy.geometry.line import LinearEntity3D
    (x, y, z) = map(Dummy, 'xyz')
    if (self.intersection(o) != []):
        return S.Zero
    if isinstance(o, Point3D):
        (x, y, z) = map(Dummy, 'xyz')
        k = self.equation(x, y, z)
        (a, b, c) = [k.coeff(i) for i in (x, y, z)]
        d = k.xreplace({x: o.args[0], y: o.args[1], z: o.args[2]})
        t = abs((d / sqrt((((a ** 2) + (b ** 2)) + (c ** 2)))))
        return t
    if isinstance(o, LinearEntity3D):
        (a, b) = (o.p1, self.p1)
        c = Matrix(a.direction_ratio(b))
        d = Matrix(self.normal_vector)
        e = c.dot(d)
        f = sqrt(sum([(i ** 2) for i in self.normal_vector]))
        return abs((e / f))
    if isinstance(o, Plane):
        (a, b) = (o.p1, self.p1)
        c = Matrix(a.direction_ratio(b))
        d = Matrix(self.normal_vector)
        e = c.dot(d)
        f = sqrt(sum([(i ** 2) for i in self.normal_vector]))
        return abs((e / f))
