ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 11 May 2021 15:58:50 +0200Subfaces of a face in Polyhedra package?https://ask.sagemath.org/question/57069/subfaces-of-a-face-in-polyhedra-package/I'm using polyhedra package and I need the operation that, for a given face, provides the list of all its subfaces (as faces in the bigger polyhedron). If I'm doing something like face.as_polyhedron().faces(n), the faces stop being recognised as belonging to the bigger polyhedron. What is the correct way to do that?PolydaryaTue, 11 May 2021 15:58:50 +0200https://ask.sagemath.org/question/57069/Oriented vertices of Polyhedronhttps://ask.sagemath.org/question/56186/oriented-vertices-of-polyhedron/ Hi, I wonder what is the most convenient way to extract the ordered/oriented vertices of a Polyhedron/PolyhedronFace.
Specifically, say that we have a cube:
sage: cb = Polyhedron(vertices=[(0,0,0), (0,0,1), (0,1,0), (0,1,1), (1,0,0), (1,0,1), (1,1,0), (1,1,1)])
which consists of 6 facets:
sage: cb.facets()
(A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 4 vertices,
A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 4 vertices,
A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 4 vertices,
A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 4 vertices,
A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 4 vertices,
A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 4 vertices)
I can easily know the indices of vertices (in `cb.Vrepresentation`) that form each facets, e.g., for the first facet:
sage: cb.facets()[0].ambient_V_indices()
(0, 1, 4, 5)
However, the four vertices are not properly ordered (linked) as I inspect the adjacency matrix:
sage: cb.vertex_adjacency_matrix()
[0 1 1 0 1 0 0 0]
[1 0 0 1 0 1 0 0]
[1 0 0 1 0 0 1 0]
[0 1 1 0 0 0 0 1]
[1 0 0 0 0 1 1 0]
[0 1 0 0 1 0 0 1]
[0 0 1 0 1 0 0 1]
[0 0 0 1 0 1 1 0]
(from the adjacent matrix the ordered indices of the four vertices should be 0->1->5->4, or reversed as 4->5->1->0).
The proper orientation of the vertices is needed for B-rep. Though I can extract the proper ordering with `vertex_adjacency_matrix()`, how to make sure they're consistently CCW orientated (seen from outside) still confuses me.
I'm kinda sure these are well managed in Sage, because the `obj_repr()` method in [plot3d](https://doc.sagemath.org/html/en/reference/plot3d/sage/plot/plot3d/base.html?highlight=obj_repr#sage.plot.plot3d.base.Graphics3d.obj_repr) seems working well providing a consistent facet-vertex representation:
sage: cb_render = cb.render_solid()
sage: cb_render.obj_repr(cb_render.default_render_params())
['g obj_1',
'usemtl texture7',
['v 0 0 0',
'v 0 0 1',
'v 0 1 0',
'v 0 1 1',
'v 1 0 0',
'v 1 0 1',
'v 1 1 0',
'v 1 1 1'],
['f 8 4 2 6',
'f 7 3 4 8',
'f 8 6 5 7',
'f 3 1 2 4',
'f 5 1 3 7',
'f 6 2 1 5'],
['f 6 2 4 8',
'f 8 4 3 7',
'f 7 5 6 8',
'f 4 2 1 3',
'f 7 3 1 5',
'f 5 1 2 6']]
(notice that the vertex index in OBJ representation starts from 1 instead of 0; the line `f 6 2 1 5` corresponds to the ordering `4->5->1->0` that I want)
Is there a native method for Polyhedron or PolyhdronFace that I can directly use for this?zhaiyuTue, 16 Mar 2021 18:20:01 +0100https://ask.sagemath.org/question/56186/PolyhedronFacehttps://ask.sagemath.org/question/50633/polyhedronface/ Hello,
In the PolyhedronFace class, everything works fine for me except the functions ambient_V_indices and ambient_H_indices.
Exemple :
square = polytopes.hypercube(2)
fl = square.face_lattice();
list(f.ambient_V_indices() for f in fl)
I get :
AttributeError Traceback (most recent call last)
<ipython-input-3-58aa615735f2> in <module>()
2 fl = square.face_lattice();fl
3
----> 4 list(f.ambient_V_indices() for f in fl)
<ipython-input-3-58aa615735f2> in <genexpr>((f,))
2 fl = square.face_lattice();fl
3
----> 4 list(f.ambient_V_indices() for f in fl)
AttributeError: 'PolyhedronFace' object has no attribute 'ambient_V_indices'
Other methods work fine:
simplex = polytopes.simplex(3)
for face in simplex.faces(2):
print face.as_polyhedron()
print face.dim()
print face.vertices()
work perfectly.
When I deal with a polyhedron face, I would really like to get corresponding vertices indices in the parent polyhedron via "ambient" methodes. How can I fix this ?
Thanks a lot
johnsmokeWed, 08 Apr 2020 12:26:06 +0200https://ask.sagemath.org/question/50633/