Ask Your Question
0

What is the most efficient way to "look up" a face in the face lattice of a polyhedron?

asked 2016-08-16 04:06:34 -0600

done_with_fish gravatar image

updated 2016-08-16 18:16:58 -0600

Say I have a polyhedron p with face lattice L = p.face_lattice(). I want to define x as the element of L defined as the convex hull of vertices <0 1 3> of p. What is the most efficient way to define x?

For example, consider

sage: p = polytopes.simplex(3)
sage: for v in p.vertices():
    print '\tIndex {}:'.format(v.index()), v
....:     
    Index 0: A vertex at (0, 0, 0, 1)
    Index 1: A vertex at (0, 0, 1, 0)
    Index 2: A vertex at (0, 1, 0, 0)
    Index 3: A vertex at (1, 0, 0, 0)

We see that p has four vertices.

The vertices indexed by 0, 1, and 3 are the vertices of a face of p. This is confirmed:

sage: L = p.face_lattice()
sage: list(L)
[<>,
 <0>,
 <1>,
 <2>,
 <3>,
 <0,1>,
 <0,2>,
 <1,2>,
 <0,3>,
 <1,3>,
 <2,3>,
 <0,1,2>,
 <0,1,3>,
 <0,2,3>,
 <1,2,3>,
 <0,1,2,3>]

I want to define x as the face in p.face_lattice() given by these vertices. Of course, I could do this by hand with x = list(L)[12], but I want a way to automate this.

edit retag flag offensive close merge delete

Comments

Please provide a polyhedron p so that other users have a starting point to try and answer your question.

slelievre gravatar imageslelievre ( 2016-08-16 17:34:15 -0600 )edit

@slelievre Thanks for the suggestion. I've updated my question with an example.

done_with_fish gravatar imagedone_with_fish ( 2016-08-16 18:16:25 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-07-19 15:27:53 -0600

dan_fulea gravatar image

The following works for me:

TYPES = ( int, sage.rings.integer.Integer )

def get_face( P, verticesInput ):
    """Here, <P> is a polyhedron, 
    and the <verticesInput> are a list of true vertices of the polyhedron.
    Then we search for a face of the polyhedron having the given <verticesInput>
    matching the own vertices. If found, we return it. If not we return None.
    """

    verticesP = P.vertices()
    verticesSetInput = set( [ verticesP[ v ] if type(v) in TYPES else v
                              for v in verticesInput ] )

    if len( verticesInput ) != len( verticesSetInput ):
        return

    for f in P.face_lattice():
        if set( f.vertices() ) == verticesSetInput:
            return f

P = polytopes.dodecahedron()
# test
for data in ( [0..3], [0..4], [0..5], [15..19], {8,15}, (7,) ):
    f = get_face( P, data )
    if f:    print "data = %s --> FOUND FACE %s" % ( data, f )
    else:    print "data = %s --> NO SUCH FACE"  % ( data )

It gives:

data = [0, 1, 2, 3] --> NO SUCH FACE
data = [0, 1, 2, 3, 4] --> FOUND FACE <0,1,2,3,4>
data = [0, 1, 2, 3, 4, 5] --> NO SUCH FACE
data = [15, 16, 17, 18, 19] --> FOUND FACE <15,16,17,18,19>
data = set([8, 15]) --> FOUND FACE <8,15>
data = (7,) --> FOUND FACE <7>
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-08-16 04:06:34 -0600

Seen: 487 times

Last updated: Jul 19