Ticket #5635: 11803.patch
| File 11803.patch, 3.2 KB (added by novoselt, 4 years ago) |
|---|
-
sage/geometry/lattice_polytope.py
# HG changeset patch # User Andrey Novoseltsev <novoselt@gmail.com> # Date 1238474465 25200 # Node ID 4190bb65ff67fc4ed8169a583d1770ed8fc072ab # Parent 5c72dbb92d8284101858a5e6f2b476a56e597e14 Removed plot() for consistency (it was showing a bad 3d plot, plot3d works better). diff -r 5c72dbb92d82 -r 4190bb65ff67 sage/geometry/lattice_polytope.py
a b 211 211 212 212 We draw a pretty picture of the polytype in 3-dimensional space:: 213 213 214 sage: p.plot ().show()214 sage: p.plot3d().show() 215 215 216 216 Now we add an extra point, which is in the interiour of the 217 217 polytope... … … 1453 1453 """ 1454 1454 return SetOfAllLatticePolytopes 1455 1455 1456 def plot(self, camera_center=None):1457 """1458 Draw a 3d picture of the polytope.1459 1460 INPUT:1461 1462 1463 - ``self`` - polytope of dimension 3.1464 1465 - ``camera_center`` - (default: random) location of1466 center of the camera (i.e., viewer)1467 1468 1469 OUTPUT: a Tachyon 3d raytracer plot of the polytope1470 1471 The face colors are random.1472 1473 AUTHORS:1474 1475 - William Stein and Tom Boothby1476 1477 EXAMPLES::1478 1479 sage: o = lattice_polytope.octahedron(3)1480 sage: o.plot().show()1481 """1482 if self.dim() != 3:1483 raise ValueError, "Polytope must have dimension 3!"1484 m = self._vertices1485 r = random.random1486 if camera_center is None:1487 x = max(m.list())1488 camera_center = [(1+r())*x,(1+r())*x,(1+r())*x]1489 for i in range(3):1490 if r() > 0.5:1491 camera_center[i] *= -11492 t = Tachyon(camera_center=camera_center)1493 t.light(tuple([2*v for v in camera_center]), .1, (1,1,1))1494 1495 cols = m.columns()1496 n = len(cols)1497 for i in range(n):1498 for j in range(i,n):1499 for k in range(j,n):1500 s = "T%010d%010d%010d"%(i,j,k)1501 t.texture(s, color=hue(r()))1502 t.triangle(cols[i],cols[j],cols[k], s)1503 return t1504 1505 1456 def plot3d(self, 1506 1457 show_facets=True, facet_opacity=0.5, facet_color=(0,1,0), 1507 1458 show_edges=True, edge_thickness=3, edge_color=(0.5,0.5,0.5), … … 1606 1557 pplot += text3d(i, index_shift*self.point(i), rgbcolor=pindex_color) 1607 1558 return pplot 1608 1559 1609 def show (self, camera_center=None):1560 def show3d(self): 1610 1561 """ 1611 Draw a 3d picture of the polytope.1562 Show a 3d picture of the polytope with default settings and without axes or frame. 1612 1563 1613 See self.plot ? for more details.1564 See self.plot3d? for more details. 1614 1565 1615 1566 EXAMPLES:: 1616 1567 1617 1568 sage: o = lattice_polytope.octahedron(3) 1618 sage: o.show ()1569 sage: o.show3d() 1619 1570 """ 1620 self.plot (camera_center=camera_center).show()1571 self.plot3d().show(axis=False, frame=False) 1621 1572 1622 1573 def point(self, i): 1623 1574 r"""
