fresnel.geometry¶
Overview
Base class for all geometry. |
|
Convex polyhedron geometry. |
|
Cylinder geometry. |
|
Box geometry. |
|
Polygon geometry. |
|
Sphere geometry. |
Details
Geometric primitives.
Geometry provides operations common to all geometry classes. Use a
specific geometry class to add objects to the fresnel.Scene.
-
class
fresnel.geometry.Box(scene, box, box_radius=0.5, box_color=[0, 0, 0])¶ Box geometry.
Generate a triclinic box shape.
- Parameters
scene (
fresnel.Scene) – Add the geometry to this scenebox_radius (
numpy.ndarrayorarray_like) – (`1`,`3`, or`6`:float32) Assumes 1x1 is cubic, 1x3 is orthorhombic, and 1x6 is triclinic.radius (
float) – Radius of box edges.box_color (
numpy.ndarrayorarray_like) – (1x3:float32) - Color of box edges.
Note
The constructor arguments
radiusandcolorare optional. If you do not provide them, they are initialized to 0.5 and black, respectively.Note
The Box class is constructed from Cylinders, which can be modified individually. The convenience attributes
box_radiusandbox_colorcan be used to easily modify the thickness and color of the box. If the individual cylinders are modified, the getter for thebox_radiuswill return the radius of the 0th element cylinder.-
points¶ Read or modify the start and end points of the cylinders.
- Type
-
radius¶ Read or modify the radii of the cylinders.
- Type
-
color¶ Read or modify the colors of the start and end points of the cylinders.
- Type
-
box¶ Read or modify the box parameters. Boxes will be converted from any acceptable box type to a tuple (Lx, Ly, Lz, xy, xz, yz). Changing the box will update the points used to generate the cylinders.
- Type
-
class
fresnel.geometry.ConvexPolyhedron(scene, polyhedron_info, position=None, orientation=None, color=None, N=None, material=<fresnel.material.Material object>, outline_material=<fresnel.material.Material object>, outline_width=0.0)¶ Convex polyhedron geometry.
Define a set of convex polyhedron primitives. A convex polyhedron is defined by P outward facing planes (origin and normal vector) and a radius that encompass the shape.
fresnel.util.convex_polyhedron_from_vertices()can construct this by computing the convex hull of a set of vertices.- Parameters
scene (
fresnel.Scene) – Add the geometry to this scenepolyhedron_info (
dict) – A dictionary containing the face normals (face_normal), origins (face_origin), colors (face_color), and the radius (radius)).position (
numpy.ndarrayorarray_like) – (Nx3:float32) - Position of each polyhedra.orientation (
numpy.ndarrayorarray_like) – (Nx4:float32) - Orientation of each polyhedra (as a quaternion).color (
numpy.ndarrayorarray_like) – (Nx3:float32) - Color of each polyhedron.N (int) – Number of spheres in the geometry. If
None, determineNfromposition.
Note
The constructor arguments
position,orientation, andcolorare optional. If you do not provide them, they are initialized to 0’s.Hint
Avoid costly memory allocations and type conversions by specifying primitive properties in the appropriate numpy array type.
-
position¶ Read or modify the positions of the polyhedra.
- Type
-
orientation¶ Read or modify the orientations of the polyhedra.
- Type
-
color¶ Read or modify the color of the polyhedra.
- Type
-
color_by_face¶ 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 per-particle and per-face colors.
- Type
-
get_extents()¶ Get the extents of the geometry
- Returns
[[minimum x, minimum y, minimum z], [maximum x, maximum y, maximum z]]
-
class
fresnel.geometry.Cylinder(scene, points=None, radius=None, color=None, N=None, material=<fresnel.material.Material object>, outline_material=<fresnel.material.Material object>, outline_width=0.0)¶ Cylinder geometry.
Define a set of spherocylinder primitives with start and end positions, radii, and individual colors.
- Parameters
scene (
fresnel.Scene) – Add the geometry to this scenepoints (
numpy.ndarrayorarray_like) – (Nx2x3:float32) - cylinder start and end points.radius (
numpy.ndarrayorarray_like) – (N:float32) - Radius of each cylinder.color (
numpy.ndarrayorarray_like) – (Nx2x3:float32) - Color of each start and end point.N (int) – Number of cylinders in the geometry. If
None, determineNfrom points.
Note
The constructor arguments
points,radius, andcolorare optional. If you do not provide them, they are initialized to 0’s.Hint
Avoid costly memory allocations and type conversions by specifying primitive properties in the appropriate numpy array type.
Tip
When all cylinders are the same size, pass a single value for radius and numpy will broadcast it to all elements of the array.
-
points¶ Read or modify the start and end points of the cylinders.
- Type
-
radius¶ Read or modify the radii of the cylinders.
- Type
-
color¶ Read or modify the colors of the start and end points of the cylinders.
- Type
-
get_extents()¶ Get the extents of the geometry
- Returns
[[minimum x, minimum y, minimum z], [maximum x, maximum y, maximum z]]
-
class
fresnel.geometry.Geometry¶ Base class for all geometry.
Geometryprovides operations common to all geometry classes.-
material¶ The geometry’s material.
-
outline_material¶ The geometry’s outline material.
-
outline_width¶ The geometry’s outline width, in distance units in the scene’s coordinate system.
- Type
Note
You cannot instantiate a Geometry directly. Use one of the sub classes.
-
disable()¶ Disable the geometry.
When disabled, the geometry will not be present in the scene.
-
enable()¶ Enable the geometry.
When enabled, the geometry will be present when rendering the scene.
-
-
class
fresnel.geometry.Mesh(scene, vertices, position=None, orientation=None, color=None, N=None, material=<fresnel.material.Material object>, outline_material=<fresnel.material.Material object>, outline_width=0.0)¶ Mesh geometry.
Define a set of triangle mesh primitives.
- Parameters
scene (
fresnel.Scene) – Add the geometry to this scenevertices (
numpy.ndarrayorarray_like) – (3Tx3:float32) - Vertices of the triangles, listed contiguously. Vertices 0,1,2 define the first triangle, 3,4,5 define the second, and so on.color (
numpy.ndarrayorarray_like) – (3Tx3:float32) - Color of each vertex.position (
numpy.ndarrayorarray_like) – (Nx3:float32) - Positions of each mesh instance.orientation (
numpy.ndarrayorarray_like) – (Nx4:float32) - Orientation of each mesh instance (as a quaternion).N (int) – Number of mesh instances in the geometry. If
None, determineNfromposition.
Note
The constructor arguments
position,orientation, andcolorare optional, and just short-hand for assigning the attribute after construction.Colors are in the linearized sRGB color space. Use
fresnel.color.linear()to convert standard sRGB colors into this space.Meshdetermines the color of a triangle using interpolation with the barycentric coordinates in every triangular face.Hint
Avoid costly memory allocations and type conversions by specifying primitive properties in the appropriate numpy array type.
-
position¶ Read or modify the positions of the mesh instances.
- Type
-
orientation¶ Read or modify the orientations of the mesh instances.
- Type
-
color¶ Read or modify the color of the vertices.
- Type
-
get_extents()¶ Get the extents of the geometry
- Returns
[[minimum x, minimum y, minimum z], [maximum x, maximum y, maximum z]]
-
class
fresnel.geometry.Polygon(scene, vertices, position=None, angle=None, color=None, rounding_radius=0, N=None, material=<fresnel.material.Material object>, outline_material=<fresnel.material.Material object>, outline_width=0.0)¶ Polygon geometry.
Define a set of simple polygon primitives. Each polygon face is always in the xy plane. Each polygon may have a different color and rotation angle.
- Parameters
scene (
fresnel.Scene) – Add the geometry to this scenevertices (
numpy.ndarrayorarray_like) – (Nx2:float32) - Polygon vertices.position (
numpy.ndarrayorarray_like) – (Nx2:float32) - Position of each polygon.angle (
numpy.ndarrayorarray_like) – (N:float32) - Orientation angle of each polygon.color (
numpy.ndarrayorarray_like) – (Nx3:float32) - Color of each polygon.rounding_radius (float) – Rounding radius for spheropolygons.
N (int) – Number of polygons in the geometry. If
None, determineNfromposition.
Note
The constructor arguments
position,angle, andcolorare optional. If you do not provide them, they are initialized to 0’s.Hint
Avoid costly memory allocations and type conversions by specifying primitive properties in the appropriate numpy array type.
-
position¶ Read or modify the positions of the polygons.
- Type
-
angle¶ Read or modify the orientation angles of the polygons.
- Type
-
color¶ Read or modify the colors of the polygons.
- Type
-
get_extents()¶ Get the extents of the geometry
- Returns
[[minimum x, minimum y, minimum z], [maximum x, maximum y, maximum z]]
-
class
fresnel.geometry.Sphere(scene, position=None, radius=None, color=None, N=None, material=<fresnel.material.Material object>, outline_material=<fresnel.material.Material object>, outline_width=0.0)¶ Sphere geometry.
Define a set of sphere primitives with positions, radii, and individual colors.
- Parameters
scene (
fresnel.Scene) – Add the geometry to this sceneposition (
numpy.ndarrayorarray_like) – (Nx3:float32) - Position of each sphere.radius (
numpy.ndarrayorarray_like) – (N:float32) - Radius of each sphere.color (
numpy.ndarrayorarray_like) – (Nx3:float32) - Color of each sphere.N (int) – Number of spheres in the geometry. If
None, determineNfromposition.
Note
The constructor arguments
position,radius, andcolorare optional. If you do not provide them, they are initialized to 0’s.Hint
Avoid costly memory allocations and type conversions by specifying primitive properties in the appropriate numpy 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.
-
position¶ Read or modify the positions of the spheres.
- Type
-
radius¶ Read or modify the radii of the spheres.
- Type
-
color¶ Read or modify the color of the spheres.
- Type
-
get_extents()¶ Get the extents of the geometry
- Returns
[[minimum x, minimum y, minimum z], [maximum x, maximum y, maximum z]]