1a0cedb7af0fd0fd40ce46a3c41fd4afa79326b7
3 # This is the code example used in the tutorial. It shows how to define and
4 # manipulate polyhedra.
9 class InteractiveConsole(code
.InteractiveConsole
):
10 def push(self
, line
=''):
13 return super().push(line
)
18 if __name__
== '__main__':
20 shell
= InteractiveConsole()
22 shell
.push('from linpy import *')
23 shell
.push("x, y = symbols('x y')")
26 shell
.push('square1 = Le(0, x, 2) & Le(0, y, 2)')
30 shell
.push("square2 = Polyhedron('1 <= x <= 3, 1 <= y <= 3')")
34 shell
.push('inter = square1.intersection(square2) # or square1 & square2')
38 shell
.push('hull = square1.convex_union(square2)')
42 shell
.push('proj = square1.project([y])')
46 shell
.push('inter <= square1')
47 shell
.push('inter == Empty')
50 shell
.push('union = square1.union(square2) # or square1 | square2')
52 shell
.push('union <= hull')
55 shell
.push('diff = square1.difference(square2) # or square1 - square2')
57 shell
.push('~square1')