Ticket #10796: trac_10796-platonic-and-doc.patch

File trac_10796-platonic-and-doc.patch, 2.4 KB (added by kcrisman, 10 years ago)

Apply only this patch

  • sage/plot/plot3d/platonic.py

    # HG changeset patch
    # User Karl-Dieter Crisman <kcrisman@gmail.com>
    # Date 1299907169 18000
    # Node ID cac9bc229d820789f633184b3ba5302022743905
    # Parent  6a679959b54b7975af1841df4dd77d28b0faef28
    Trac 10796 - Fix interaction of scale and center in Platonic solids
    
    Also update documentation for the helper functions which do this.
    
    diff -r 6a679959b54b -r cac9bc229d82 sage/plot/plot3d/platonic.py
    a b  
    5555from index_face_set import IndexFaceSet
    5656
    5757def index_face_set(face_list, point_list, enclosed, **kwds):
     58    """
     59    Helper function that creates ``IndexFaceSet`` object for the
     60    tetrahedron, dodecahedron, and icosahedron.
     61   
     62    INPUT:
     63   
     64    -  ``face_list`` - list of faces, given explicitly from the
     65       solid invocation
     66   
     67    -  ``point_list`` - list of points, given explicitly from the
     68       solid invocation
     69   
     70    -  ``enclosed`` - boolean (default passed is always True
     71       for these solids)
     72   
     73    TESTS:
     74
     75    Verify that these are working and passing on keywords::
     76
     77        sage: tetrahedron(center=(2,0,0),size=2,color='red')
     78
     79    ::
     80
     81        sage: dodecahedron(center=(2,0,0),size=2,color='red')
     82
     83    ::
     84
     85        sage: icosahedron(center=(2,0,0),size=2,color='red')
     86    """
    5887    if kwds.has_key('center'):
    5988        center = kwds['center']
    6089        del kwds['center']
     
    6998    return prep(I, center, size, kwds)
    7099
    71100def prep(G, center, size, kwds):
     101    """
     102    Helper function that scales and translates the platonic
     103    solid, and passes extra keywords on.
     104   
     105    INPUT:
     106   
     107    -  ``center`` - 3-tuple indicating the center (default passed
     108       from :func:`index_face_set` is the origin `(0,0,0)`)
     109   
     110    -  ``size`` - number indicating amount to scale by (default
     111       passed from :func:`index_face_set` is 1)
     112   
     113    -  ``kwds`` - a dictionary of keywords, passed from solid
     114       invocation by :func:`index_face_set`
     115   
     116    TESTS:
     117
     118    Verify that scaling and moving the center work together properly,
     119    and that keywords are passed (see Trac #10796)::
     120
     121        sage: octahedron(center=(2,0,0),size=2,color='red')
     122    """
     123    if size != 1:
     124        G = G.scale(size)
    72125    if center != (0,0,0):
    73126        G = G.translate(center)
    74     if size != 1:
    75         G = G.scale(size)
    76127    G._set_extra_kwds(kwds)
    77128    return G
    78129