.. py:class :: Domain
- The properties of a domain can be are found using the following
-
.. py:method:: symbols
Returns a tuple of the symbols that exsist in a domain.
Returns ``True`` if a domain depends on the given dimensions.
- The unary properties of a domain can be inspected using the following methods.
-
.. py:method:: isempty(self)
Return ``True`` is a domain is empty.
It is not guarenteed that a domain is disjoint. If it is necessary, this method will return a domain as disjoint.
- The following methods compare two domains to find the binary properties.
-
.. py:method:: isdisjoint(self, other)
Return ``True`` if the intersection of *self* and *other* results in an empty set.
Test whether every element in *other* is in a domain.
-
- The following methods implement unary operations on a domain.
-
.. py:method:: complement(self)
¬self
Return a single sample subset of a domain.
- The following methods implement binary operations on two domains.
-
.. py:method:: intersection(self, other)
self | other
Return the sum of two domains.
- The following methods use lexicographical ordering to find the maximum or minimum element in a domain.
-
.. py:method:: lexmin(self)
Return a new set containing the lexicographic minimum of the elements in the set.
Return a new set containing the lexicographic maximum of the elements in the set.
- A 2D or 3D domain can be plotted using the :meth:`plot` function. The points, verticies, and faces of a domain can be inspected using the following functions.
+A 2D or 3D domain can be plotted using the :meth:`plot` function. The points, verticies, and faces of a domain can be inspected using the following functions.
.. py:method:: points(self)
>>> #test equality
>>> square1 == square2
False
- >>> # find the union of two polygons
- >>> square1 + square2
+ >>> # compute the union of two polygons
+ >>> square1 | square2
Or(And(Ge(x, 0), Ge(-x + 2, 0), Ge(y, 0), Ge(-y + 2, 0)), And(Ge(x - 2, 0), Ge(-x + 4, 0), Ge(y - 2, 0), Ge(-y + 4, 0)))
>>> # check if square1 and square2 are disjoint
>>> square1.disjoint(square2)
False
- >>> # find the intersection of two polygons
+ >>> # compute the intersection of two polygons
>>> square1 & square2
And(Eq(y - 2, 0), Eq(x - 2, 0))
- >>> # find the convex union of two polygons
+ >>> # compute the convex union of two polygons
>>> Polyhedron(square1 | sqaure2)
And(Ge(x, 0), Ge(-x + 4, 0), Ge(y, 0), Ge(-y + 4, 0), Ge(x - y + 2, 0), Ge(-x + y + 2, 0))
(x, y)
>>> square1.inequalities
(x, -x + 2, y, -y + 2)
+ >>> # project out the variable x
>>> square1.project([x])
And(Ge(-y + 2, 0), Ge(y, 0))
[Point({x: Fraction(0, 1), y: Fraction(1, 1)}), Point({x: Fraction(-1, 1), y: Fraction(0, 1)}), Point({x: Fraction(1, 1), y: Fraction(0, 1)}), Point({x: Fraction(0, 1), y: Fraction(-1, 1)})]
>>> diamond.points()
[Point({x: -1, y: 0}), Point({x: 0, y: -1}), Point({x: 0, y: 0}), Point({x: 0, y: 1}), Point({x: 1, y: 0})]
+
+ The user also can pass another plot to the :meth:`plot` method. This can be useful to compare two polyhedrons on the same axis. This example illustrates the union of two squares.
+
+ >>> from linpy import *
+ >>> import matplotlib.pyplot as plt
+ >>> from matplotlib import pylab
+ >>> x, y = symbols('x y')
+ >>> square1 = Le(0, x) & Le(x, 2) & Le(0, y) & Le(y, 2)
+ >>> square2 = Le(1, x) & Le(x, 3) & Le(1, y) & Le(y, 3)
+ >>> fig = plt.figure()
+ >>> plot = fig.add_subplot(1, 1, 1, aspect='equal')
+ >>> square1.plot(plot, facecolor='red', alpha=0.3)
+ >>> square2.plot(plot, facecolor='blue', alpha=0.3)
+ >>> squares = Polyhedron(square1 + square2)
+ >>> squares.plot(plot, facecolor='blue', alpha=0.3)
+ >>> pylab.show()
+
+ .. figure:: images/union.jpg
+ :align: center
+
+
+