Sage多面体简介

如果你已经知道一些凸几何 a la 格伦鲍姆或伯恩斯特德,那么你可能会渴望用一些多面体的计算把你的手弄脏。下面是一个小指南。

基础

首先,让我们定义一个多面体为一组点的凸包,即 S 我们计算 P={{rm conv}}(S)

sage: P1 = Polyhedron(vertices = [[-5,2], [4,4], [3,0], [1,0], [2,-4], [-3,-1], [-5,-3]])
sage: P1
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 4 vertices

请注意,Sage告诉您多面体的尺寸以及环境空间的尺寸。

当然,您想知道这个对象是什么样子的:

sage: P1.plot()
Graphics object consisting of 6 graphics primitives

即使在二维空间中,也很难弄清楚支撑超平面的是什么。幸运的是Sage会照顾我们。

sage: for q in P1.Hrepresentation():
....:    print(q)
An inequality (-4, 1) x + 12 >= 0
An inequality (1, 7) x + 26 >= 0
An inequality (1, 0) x + 5 >= 0
An inequality (2, -9) x + 28 >= 0

这种表示法不能立即解析,因为说真的,那些看起来不像直线方程(或半空间方程,实际上它们就是这样的)。

(-4, 1) x + 12 >= 0 真的意味着 (-4, 1)cdotvec{{x}} + 12 geq 0 .

所以。。。如果你想通过不等式定义一个多面体,你必须把每个不等式转化成一个向量。例如, (-4, 1)cdotvec{{x}} + 12 geq 0 变成(12,-4,1)。

sage: altP1 = Polyhedron(ieqs=[(12, -4, 1), (26, 1, 7),(5,1,0), (28, 2, -9)])
sage: altP1.plot()
Graphics object consisting of 6 graphics primitives

您可能想从Sage中提取关于多面体的其他信息是顶点列表,它可以通过两种方式完成:

sage: for q in P1.Vrepresentation():
....:    print(q)
A vertex at (-5, -3)
A vertex at (-5, 2)
A vertex at (4, 4)
A vertex at (2, -4)
sage: P1.vertices()
(A vertex at (-5, -3), A vertex at (-5, 2), A vertex at (4, 4), A vertex at (2, -4))

极性对偶

你肯定要计算极对偶:

sage: P1dual = P1.polar()
sage: P1dual
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 4 vertices

我们从一个整数格子多面体开始,二元化为有理格子多面体。让我们看看。

sage: P1dual.plot()
Graphics object consisting of 6 graphics primitives
sage: P1.plot() + P1dual.plot()
Graphics object consisting of 12 graphics primitives

哦,是的,除非多面体是单位球体大小,否则双星体的大小将大不相同。让我们重新缩放。

sage: ((1/4)*P1).plot() + (4*P1dual).plot()
Graphics object consisting of 12 graphics primitives

如果你觉得这看起来有点阴暗,那你是对的。下面是一个让问题更清楚的例子。

sage: P2 = Polyhedron(vertices = [[-5,0], [-1,1], [-2,0], [1,0], [-2,-1], [-3,-1], [-5,-1]])
sage: P2
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 5 vertices
sage: P2dual = P2.polar(); P2dual
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 5 vertices
sage: P2.plot() + P2dual.plot()
Graphics object consisting of 14 graphics primitives

这显然不是在计算我们所认为的两极对偶。但是看看这个。。。

sage: P2.plot() + (-1*P2dual).plot()
Graphics object consisting of 14 graphics primitives

这是怎么回事。

如果是多面体 P 是在 ZZ ,然后…

  1. …对偶以某种方式反转,对于多边形是垂直的。

  2. …双重的是P本身。

  3. …如果原点不在P中,则返回错误。

但是,如果多面体 not 在里面 ZZ ,例如 QQRDF ,然后…

(1')…双精度不反转。

(2’)…双重结构取质心位置。

记住所有这些,当你采取极地双。

多面体结构

明可夫斯基总结!现在有两种语法!

sage: P1+P2
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 8 vertices
sage: P1.minkowski_sum(P2)
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 8 vertices

好吧,很好。我们至少应该有一些三维的例子。(请注意,为了有效地显示多面体,您需要安装Javaview和Jmol等可视化软件。)

sage: P3 = Polyhedron(vertices=[(0,0,0), (0,0,1/2), (0,1/2,0), (1/2,0,0), (3/4,1/5,3/2)]); P3
A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 5 vertices
sage: P4 = Polyhedron(vertices=[(-1,1,0),(1,1,0),(-1,0,1), (1,0,1),(0,-1,1),(0,1,1)]); P4
A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 6 vertices
sage: P3.plot() + P4.plot()
Graphics3d Object
sage: (P3+P4).plot()
Graphics3d Object

我们也可以找到两个多面体的交点。。。这也有两种语法!

sage: int12 = P1.intersection(P2*.5); int12.plot()
Graphics object consisting of 7 graphics primitives
sage: int34 = P3 & P4; int34.plot()
Graphics3d Object

如果你想翻译,你可以。

sage: transP2 = P2.translation([2,1])
sage: P2.plot() + transP2.plot()
Graphics object consisting of 14 graphics primitives

当然,我们可以用棱柱体,金字塔,和多面体的双锥体。。。

sage: P2.prism().plot()
Graphics3d Object
sage: P1.pyramid().plot()
Graphics3d Object
sage: P2dual.bipyramid().plot()
Graphics3d Object

好吧,很好。是的,Sage有一些多面体。如果你打字 polytopes. 然后按 TAB 在这段时间之后,您将得到一个预构建多面体的列表。

sage: P5 = polytopes.hypercube(5)
sage: P6 = polytopes.cross_polytope(3)
sage: P7 = polytopes.simplex(7)

让我们看一个四维多面体。

sage: P8 = polytopes.hypercube(4)
sage: P8.plot()
Graphics3d Object

我们可以从另一个角度来看:

sage: P8.schlegel_projection([2,5,11,17]).plot()
Graphics3d Object

多面体查询

一旦你构建了一些多面体,你可以问一些关于它的明智的问题。

sage: P1.contains([1,0])
True
sage: P1.interior_contains([3,0])
False
sage: P3.contains([1,0,0])
False

面部信息可能很有用。

sage: int34.f_vector()
(1, 8, 12, 6, 1)

几何信息可能是 more 有帮助。。。在这里,我们被告知哪些顶点构成了每个2面:

sage: [f.ambient_V_indices() for f in int34.faces(2)]
[(2, 6, 7), (0, 1, 3, 5), (1, 3, 4), (0, 5, 6, 7), (0, 1, 2, 4, 6), (2, 3, 4, 5, 7)]

是啊,那没那么有用。让我们计算出列表中第一个面的顶点和超平面表示。

sage: first2faceofint34 = int34.faces(2)[0]
sage: first2faceofint34.ambient_Hrepresentation(); first2faceofint34.vertices()
(An inequality (0, 0, -1) x + 1 >= 0,)
(A vertex at (2/3, 2/15, 1), A vertex at (3/8, 1/10, 1), A vertex at (1/2, 3/10, 1))

如果你想要更多。。。 多面体的基类 是你想去的第一个地方。