fresnel.geometry#
Overview
Box geometry. |
|
Convex polyhedron geometry. |
|
Cylinder geometry. |
|
Geometry base class. |
|
Mesh geometry. |
|
Polygon geometry. |
|
Sphere geometry. |
Details
Geometric primitives.
Geometry defines objects that are visible in a Scene
. The base class
Geometry
provides common operations and properties. Instantiate specific
geometry class to add objects to a Scene
.
- class fresnel.geometry.Box(scene, box, box_radius=0.5, box_color=[0, 0, 0])#
Bases:
Cylinder
Box geometry.
Generate a triclinic box outline with
spherocylinders
. The geometry’s material defaults tomaterial.Material(solid=1.0)
.- Parameters:
scene (Scene) – Add the geometry to this scene.
box ((1, ), (3, ), or (6, )
numpy.ndarray
offloat32
) – Box parameters.box_radius (float) – Radius of box edges.
box_color ((3, )
numpy.ndarray
offloat32
) – Color of the box edges.
Note
A 1-element box array expands to a cube. A 3-element box array
[Lx, Ly, Lz]
expands to an orthorhobic cuboid, and a 6-element box array represents a fully triclinic box in the same format as GSD and HOOMD:[Lx, Ly, Lz, xy, xz, yz]
.Note
The Box class is constructed from
spherocylinders
, which can be modified individually. The convenience attributesbox_radius
andbox_color
can be used to set the thickness and color of the entire box.- property box#
Box parameters.
Set
box
to update the shape of the box.- Type:
(1, ), (3, ), or (6, )
numpy.ndarray
offloat32
- property box_color#
Color of the box edges.
Note
This property sets the color of the
material
.- Type:
(3, )
numpy.ndarray
offloat32
- class fresnel.geometry.ConvexPolyhedron(scene, polyhedron_info, position=(0, 0, 0), orientation=(1, 0, 0, 0), color=(0, 0, 0), N=None, material=None, outline_material=None, outline_width=0.0)#
Bases:
Geometry
Convex polyhedron geometry.
Define a set of convex polyhedron primitives with individual positions, orientations, and colors.
A convex polyhedron is defined by P outward facing planes (origin and normal vector) and a radius that encompass the shape. Use
convex_polyhedron_from_vertices
to construct this from the convex hull of a set of vertices.- Parameters:
scene (Scene) – Add the geometry to this scene.
polyhedron_info (Dict) – A dictionary containing the face normals (
face_normal
), origins (face_origin
), face colors (face_color
), and the radius (radius
)).position ((N, 3)
numpy.ndarray
offloat32
) – Position of each polyhedron instance.orientation ((N, 4)
numpy.ndarray
offloat32
) – Orientation of each polyhedron instance (as a quaternion).color ((N, 3)
numpy.ndarray
offloat32
) – Color of each polyhedron.N (int) – Number of spheres in the geometry. If
None
, determine N from position.material (material.Material) – Define how light interacts with the geometry. When
None
, defaults tomaterial.Material()
.outline_material (material.Material) – Define how light interacts with the geometry’s outline. When
None
, defaults to solid blackmaterial.Material(solid=1, color=(0,0,0))
.outline_width (float) – Width of the outline in scene units.
Hint
Avoid costly memory allocations and type conversions by specifying primitive properties in the appropriate array type.
- property color_by_face#
Mix face colors with the per-polyhedron color.
Set to 0 to color particles by the per-particle
color
. Set to 1 to color faces by the per-face color. Set to a value between 0 and 1 to blend between the two colors.- Type:
- get_extents()#
Get the extents of the geometry.
- Returns:
The lower left and upper right corners of the scene.
- Return type:
(3,2)
numpy.ndarray
offloat32
- class fresnel.geometry.Cylinder(scene, points=((0, 0, 0), (0, 0, 0)), radius=0.5, color=(0, 0, 0), N=None, material=None, outline_material=None, outline_width=0.0)#
Bases:
Geometry
Cylinder geometry.
Define a set of spherocylinder primitives with individual start and end positions, radii, and colors.
- Parameters:
scene (Scene) – Add the geometry to this scene.
points ((N, 2, 3)
numpy.ndarray
offloat32
) – N cylinder start and end points.radius ((N, )
numpy.ndarray
offloat32
) – Radius of each cylinder.color ((N, 2, 3)
numpy.ndarray
offloat32
) – Color of each start and end point.N (int) – Number of cylinders in the geometry. When
None
, determine N from points.material (material.Material) – Define how light interacts with the geometry. When
None
, defaults tomaterial.Material()
.outline_material (material.Material) – Define how light interacts with the geometry’s outline. When
None
, defaults to solid blackmaterial.Material(solid=1, color=(0,0,0))
.outline_width (float) – Width of the outline in scene units.
Hint
Avoid costly memory allocations and type conversions by specifying primitive properties in the appropriate array type.
Tip
When all cylinders are the same size or color, pass a single value and NumPy will broadcast it to all elements of the array.
- get_extents()#
Get the extents of the geometry.
- Returns:
The lower left and upper right corners of the scene.
- Return type:
(3,2)
numpy.ndarray
offloat32
- class fresnel.geometry.Geometry#
Bases:
object
Geometry base class.
Geometry
provides operations and properties common to all geometry classes.Note
You cannot instantiate a Geometry directly. Use one of the subclasses.
- disable()#
Disable the geometry.
When disabled, the geometry will not visible in the
Scene
.See also
- property material#
Define how light interacts with the geometry.
- Type:
- property outline_material#
Define how light interacts with the geometry’s outline.
- Type:
- class fresnel.geometry.Mesh(scene, vertices, position=(0, 0, 0), orientation=(1, 0, 0, 0), color=(0, 0, 0), N=None, material=None, outline_material=None, outline_width=0.0)#
Bases:
Geometry
Mesh geometry.
Define a set of triangle mesh primitives with individual positions, orientations, and colors.
- Parameters:
scene (Scene) – Add the geometry to this scene.
vertices ((3T, 3)
numpy.ndarray
offloat32
) – Vertices of the triangles, listed contiguously. Vertices 0,1,2 define the first triangle, 3,4,5 define the second, and so on.color ((3T, 3)
numpy.ndarray
offloat32
) – Color of each vertex.position ((N, 3)
numpy.ndarray
offloat32
) – Position of each mesh instance.orientation ((N, 4)
numpy.ndarray
offloat32
) – Orientation of each mesh instance (as a quaternion).N (int) – Number of mesh instances in the geometry. If
None
, determine N from position.material (material.Material) – Define how light interacts with the geometry. When
None
, defaults tomaterial.Material()
.outline_material (material.Material) – Define how light interacts with the geometry’s outline. When
None
, defaults to solid blackmaterial.Material(solid=1, color=(0,0,0))
.outline_width (float) – Width of the outline in scene units.
Hint
Avoid costly memory allocations and type conversions by specifying primitive properties in the appropriate array type.
- get_extents()#
Get the extents of the geometry.
- Returns:
The lower left and upper right corners of the scene.
- Return type:
(3,2)
numpy.ndarray
offloat32
- class fresnel.geometry.Polygon(scene, vertices, position=(0, 0), angle=0, color=(0, 0, 0), rounding_radius=0, N=None, material=None, outline_material=None, outline_width=0.0)#
Bases:
Geometry
Polygon geometry.
Define a set of simple polygon primitives in the xy plane with individual positions, rotation angles, and colors.
- Parameters:
scene (Scene) – Add the geometry to this scene.
vertices ((N_vert, 2)
numpy.ndarray
offloat32
) – Polygon vertices.position ((N, 2)
numpy.ndarray
offloat32
) – Position of each polygon.angle ((N, )
numpy.ndarray
offloat32
) – Orientation angle of each polygon (in radians).color ((N, 3)
numpy.ndarray
offloat32
) – Color of each polygon.rounding_radius (float) – Rounding radius for spheropolygons.
N (int) – Number of polygons in the geometry. If
None
, determine N from position.material (material.Material) – Define how light interacts with the geometry. When
None
, defaults tomaterial.Material()
.outline_material (material.Material) – Define how light interacts with the geometry’s outline. When
None
, defaults to solid blackmaterial.Material(solid=1, color=(0,0,0))
.outline_width (float) – Width of the outline in scene units.
Hint
Avoid costly memory allocations and type conversions by specifying primitive properties in the appropriate array type.
- get_extents()#
Get the extents of the geometry.
- Returns:
The lower left and upper right corners of the scene.
- Return type:
(3,2)
numpy.ndarray
offloat32
- class fresnel.geometry.Sphere(scene, position=(0, 0, 0), radius=0.5, color=(0, 0, 0), N=None, material=None, outline_material=None, outline_width=0.0)#
Bases:
Geometry
Sphere geometry.
Define a set of sphere primitives with individual positions, radii, and colors.
- Parameters:
scene (Scene) – Add the geometry to this scene.
position ((N, 3)
numpy.ndarray
offloat32
) – Position of each sphere.radius ((N, )
numpy.ndarray
offloat32
) – Radius of each sphere.color ((N, 3)
numpy.ndarray
offloat32
) – Color of each sphere.N (int) – Number of spheres in the geometry. If
None
, determine N from position.material (material.Material) – Define how light interacts with the geometry. When
None
, defaults tomaterial.Material()
.outline_material (material.Material) – Define how light interacts with the geometry’s outline. When
None
, defaults to solid blackmaterial.Material(solid=1, color=(0,0,0))
.outline_width (float) – Width of the outline in scene units.
Hint
Avoid costly memory allocations and type conversions by specifying primitive properties in the appropriate array type.
Tip
When all spheres are the same size, pass a single value for radius and numpy will broadcast it to all elements of the array.
- get_extents()#
Get the extents of the geometry.
- Returns:
The lower left and upper right corners of the scene.
- Return type:
(3,2)
numpy.ndarray
offloat32