'Is the other GeometryEntity contained within this Segment?
Examples
>>> from sympy import Point, Segment
>>> p1, p2 = Point(0, 1), Point(3, 4)
>>> s = Segment(p1, p2)
>>> s2 = Segment(p2, p1)
>>> s.contains(s2)
True
>>> from sympy import Point3D, Segment3D
>>> p1, p2 = Point3D(0, 1, 1), Point3D(3, 4, 5)
>>> s = Segment3D(p1, p2)
>>> s2 = Segment3D(p2, p1)
>>> s.contains(s2)
True
>>> s.contains((p1 + p2) / 2)
True'

def contains(self, other):

    if (not isinstance(other, GeometryEntity)):
        other = Point(other, dim=self.ambient_dimension)
    if isinstance(other, Point):
        if Point.is_collinear(other, self.p1, self.p2):
            (d1, d2) = ((other - self.p1), (other - self.p2))
            d = (self.p2 - self.p1)
            try:
                return bool(Eq(simplify(((abs(d1) + abs(d2)) - abs(d))), 0))
            except TypeError:
                raise Undecidable('Cannot    determine    if    {}    is    in    {}'.format(other, self))
    if isinstance(other, Segment):
        return ((other.p1 in self) and (other.p2 in self))
    return False
