schrodinger.graphics3d.polyhedron module¶
The polyhedron module allows creation and drawing of polyhedra. The body of the polyhedron is composed of faces that are composed of vertices.
Drawing is done in the current OpenGL rendering context and current OpenGL window, so you must set those prior to drawing. If you are using this with Maestro’s drawing callback mechanism the context and window are handled automatically.
Control over the vertices, faces, color, and opacity of a box are provided. However, please note that the current implementation does not ensure the passed in vertices and faces will enclose to form a volume. This must be determined in the subclass.
To draw any number of polyhedra, create the Polyhedron instances, add them to a Group instance then invoke the Group’s draw() method.
Copyright Schrodinger, LLC. All rights reserved.
-
class
schrodinger.graphics3d.polyhedron.
Cube
(*args, **keywords)¶ Bases:
schrodinger.graphics3d.polyhedron.MaestroCube
This class is now deprecated. Please use MaestroCube.
-
class
schrodinger.graphics3d.polyhedron.
Dodecahedron
(*args, **keywords)¶ Bases:
schrodinger.graphics3d.polyhedron.MaestroDodecahedron
This class is now deprecated. Please use MaestroDodecahedron.
-
class
schrodinger.graphics3d.polyhedron.
Icosahedron
(*args, **keywords)¶ Bases:
schrodinger.graphics3d.polyhedron.MaestroIcosahedron
This class is now deprecated. Please use MaestroIcosahedron.
-
class
schrodinger.graphics3d.polyhedron.
MaestroCube
(center, mode, length=None, radius=None, volume=None, color='red', opacity=1.0, style=1)¶ Bases:
schrodinger.graphics3d.polyhedron.MaestroPolyhedronCore
Class to draw a 3D cube in Maestro’s Workspace.
Cubes should be added to a graphics3d.common.Group, or CubeGroup, and drawing done via the Group. See the
graphics3d.common.Group
documentation.API Example:
import schrodinger.maestro.maestro as maestro import schrodinger.graphics3d.polyhedron as polyhedron cube_group = polyhedron.Group() st = maestro.workspace_get() # Here, st is methane. for atom in st.atom: if atom.element == 'C': center = atom.xyz cube = polyhedron.Cube( center = center, mode = polyhedron.MODE_MAESTRO, length = 1.828, # length between Hs color = 'goldenrod', opacity = 1.0, style = polyhedron.LINE ) # Add the primative to the container. cube_group.add(cube) # Show the markers cube.show() cube_group.show() # Hide the markers. cube_group.hide() # Remove the markers and the callback. cube_group.clear()
-
getIndices
()¶ :return The indices of the faces
-
getVertices
(center, length=None, radius=None, volume=None)¶ Get a list of vertices. If the center coordinates are considered the origin the vertices will have a base on the y-plane, a vertex on the x-axis and a vertex directly in the +z-axis from the
center
.Parameters: - center (list(float, float, float)) – List of 3 Angstrom values indicating the center coordinate of the tetrahedron.
- length (float) – Length in Angstroms of each of the sides of the
tetrahedron. Note:
length
orradius
must be specified to create tetrahedron. - radius (float) – Circumsphere radius in Angstroms from center of
tetrahedron. Note:
length
orradius
must be specified to create tetrahedron. - volume (float) – Volume in cubed Angstroms of the object.
-
-
class
schrodinger.graphics3d.polyhedron.
MaestroDodecahedron
(center, mode, length=None, radius=None, volume=None, color='red', opacity=1.0, style=1)¶ Bases:
schrodinger.graphics3d.polyhedron.MaestroPolyhedronCore
Class to draw a 3D dodecahedron in Maestro’s Workspace.
See
Tetrahedron
doc string for more details.-
getIndices
()¶ :return The indices of the faces
-
getVertices
(center, length=None, radius=None, volume=None)¶ Get a list of vertices. If the center coordinates are considered the origin the vertices will have a base on the y-plane, a vertex on the x-axis and a vertex directly in the +z-axis from the
center
.Parameters: - center (list(float, float, float)) – List of 3 Angstrom values indicating the center coordinate of the dodecahedron.
- length (float) – Length in Angstroms of each of the sides of the
dodecahedron. Note:
length
orradius
must be specified to create dodecahedron. - radius (float) – Circumsphere radius in Angstroms from center of
dodecahedron. Note:
length
orradius
must be specified to create dodecahedron. - volume (float) – Volume in cubed Angstroms of the object.
-
-
class
schrodinger.graphics3d.polyhedron.
MaestroIcosahedron
(center, mode, length=None, radius=None, volume=None, color='red', opacity=1.0, style=1)¶ Bases:
schrodinger.graphics3d.polyhedron.MaestroPolyhedronCore
Class to draw a 3D icosahedron in Maestro’s Workspace.
See
Tetrahedron
doc string for more details.-
getIndices
()¶ :return The indices of the faces
-
getVertices
(center, length=None, radius=None, volume=None)¶ Get a list of vertices. If the center coordinates are considered the origin the vertices will have a base on the y-plane, a vertex on the x-axis and a vertex directly in the +z-axis from the
center
.Parameters: - center (list(float, float, float)) – List of 3 Angstrom values indicating the center coordinate of the icosahedron.
- length (float) – Length in Angstroms of each of the sides of the
icosahedron. Note:
length
orradius
must be specified to create icosahedron. - radius (float) – Circumsphere radius in Angstroms from center of
icosahedron. Note:
length
orradius
must be specified to create icosahedron. - volume (float) – Volume in cubed Angstroms of the object.
-
-
class
schrodinger.graphics3d.polyhedron.
MaestroOctahedron
(center, mode, length=None, radius=None, volume=None, color='red', opacity=1.0, style=1)¶ Bases:
schrodinger.graphics3d.polyhedron.MaestroPolyhedronCore
Class to draw a 3D octahedron in Maestro’s Workspace.
See
Tetrahedron
doc string for more details.-
getIndices
()¶ :return The indices of the faces
-
getVertices
(center, length=None, radius=None, volume=None)¶ Get a list of vertices. If the center coordinates are considered the origin the vertices will have a base on the y-plane, a vertex on the x-axis and a vertex directly in the +z-axis from the
center
.Parameters: - center (list(float, float, float)) – List of 3 Angstrom values indicating the center coordinate of the tetrahedron.
- length (float) – Length in Angstroms of each of the sides of the
tetrahedron. Note:
length
orradius
must be specified to create tetrahedron. - radius (float) – Circumsphere radius in Angstroms from center of
tetrahedron. Note:
length
orradius
must be specified to create tetrahedron. - volume (float) – Volume in cubed Angstroms of the object.
-
-
class
schrodinger.graphics3d.polyhedron.
MaestroPolyhedronCore
(center, mode, length=None, radius=None, volume=None, color='red', opacity=1.0, style=1)¶ Bases:
schrodinger.graphics3d.polyhedron.Polyhedron
-
getFaces
(vertices)¶ Parameters: vertices (list of lists) – List of vertices. Each member of list should be a list of 3 coords, [x,y,z]
-
getIndices
()¶ Abstract method, defined by convention only
-
getVertices
()¶ Abstract method, defined by convention only
-
updateVertices
(center, length=None, radius=None, volume=None)¶ Update the vertices given a new
center
and size parameter. The changes will be seen the next time the object is drawn.Parameters: - center (list(float, float, float)) – List of 3 Angstrom values indicating the center coordinate of the tetrahedron.
- length (float) – Length in Angstroms of each of the edges of the tetrahedron.
- radius (float) – Circumsphere radius in Angstroms from center of tetrahedron.
- volume (float) – Volume in cubed Angstroms of the object.
Raises: - RuntimeError – If a single option from
length
,radius
, andvolume
does not have a value. - ValueError – If the size parameter (
length
,radius
, orvolume
) is not a float.
-
-
class
schrodinger.graphics3d.polyhedron.
MaestroTetrahedron
(center, mode, length=None, radius=None, volume=None, color='red', opacity=1.0, style=1)¶ Bases:
schrodinger.graphics3d.polyhedron.MaestroPolyhedronCore
Class to draw a 3D tetrahedron in Maestro’s Workspace.
Tetrahedrons should be added to a graphics3d.common.Group, or TetrahedronGroup, and drawing done via the Group. See the
graphics3d.common.Group
documentation.API Example:
import schrodinger.maestro.maestro as maestro import schrodinger.graphics3d.polyhedron as polyhedron tetrahedron_grp = polyhedron.Group() st = maestro.workspace_get() # Here, st is methane. for atom in st.atom: if atom.element == 'C': center = atoms.xyz tetra = polyhedron.Tetrahedron( center = center, length = 1.828, # length between Hs color = 'goldenrod', opacity = 1.0, style = tetrahedron.LINE ) # Add the primative to the container. tetrahedron_grp.add(tetra) # Add the draw callback. maestro.workspace_draw_function_add(tetrahedron_grp.draw) # Hide the markers. tetrahedron_grp.hide() # Remove the markers and the callback. tetrahedron_grp.clear() maestro.workspace_draw_function_remove(tetrahedron_grp.draw)
-
getIndices
()¶ :return The indices of the faces
-
getVertices
(center, length=None, radius=None, volume=None)¶ Get a list of vertices. If the center coordinates are considered the origin the vertices will have a base on the y-plane, a vertex on the x-axis and a vertex directly in the +z-axis from the
center
.Parameters: - center (list(float, float, float)) – List of 3 Angstrom values indicating the center coordinate of the tetrahedron.
- length (float) – Length in Angstroms of each of the sides of the
tetrahedron. Note:
length
orradius
must be specified to create tetrahedron. - radius (float) – Circumsphere radius in Angstroms from center of
tetrahedron. Note:
length
orradius
must be specified to create tetrahedron. - volume (float) – Volume in cubed Angstroms of the object.
-
-
class
schrodinger.graphics3d.polyhedron.
Octahedron
(*args, **keywords)¶ Bases:
schrodinger.graphics3d.polyhedron.MaestroOctahedron
This class is now deprecated. Please use MaestroOctahedron.
-
class
schrodinger.graphics3d.polyhedron.
Polyhedron
(vertices, faces, mode, color='red', opacity=1.0, style=1)¶ Bases:
schrodinger.graphics3d.common.Primitive
Class to draw a 3D polyhedron with OpenGL using the current context in whatever is the current drawable (which could be Maestro).
-
faces
= None¶ A list containing lists of vertices that define a face of the polyhedron. These are set during the L{Polyhedron.update} method and taken from constructor argument, C{faces}.
@see: L{Polyhedron.update}
-
normals
= None¶ The normals for the C{faces} passed in. These are calculated and set during the L{Polyhedron.update} method.
@see: L{Polyhedron._setNormals} @see: L{Polyhedron.update}
-
setStyle
(style)¶ Sets the polyhedron’s drawing style.
Parameters: style (Choice, FILL or LINE) – Whether to fill the polyhedron in or to leave it as lines connecting vertices.
-
update
(vertices, faces)¶ Update the polyhedron’s shape.
Parameters: - vertices (list of lists) – List of vertices. Each member of list should be a list of 3 coords, [x,y,z]
- faces (list of lists) – List of faces comprising the polyhedron. Each face should be a list of at least 3 vertices.
See: Tetrahedron.updateVertices
for an example of usage
-
vertices
= None¶ A list of each vertex of the polyhedron. These are set during the L{Polyhedron.update} method and taken from the constructor argument, C{vertices}.
@see: L{Polyhedron.update}
-
-
class
schrodinger.graphics3d.polyhedron.
Tetrahedron
(*args, **keywords)¶ Bases:
schrodinger.graphics3d.polyhedron.MaestroTetrahedron
This class is now deprecated. Please use MaestroTetrahedron.
-
schrodinger.graphics3d.polyhedron.
origin_to_point
(vertices, center)¶ Takes a set of vertices that have been created around the origin and translates them to the be centered around the x, y, z coordinates supplied in
center
.Parameters: