fresnel.geometry

Overview

fresnel.geometry.Geometry Base class for all geometry.
fresnel.geometry.ConvexPolyhedron Convex polyhedron geometry.
fresnel.geometry.Cylinder Cylinder geometry.
fresnel.geometry.Sphere 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.

See also

Primitive properties
Tutorial: Modifying primitive properties.
Material properties
Tutorial: Modifying material properties.
Outline materials
Tutorial: Applying outline materials.
Multiple geometries
Tutorial: Displaying multiple geometries in a scene.
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 scene
  • polyhedron_info (dict) – A dictionary containing the face normals (face_normal), origins (face_origin), colors (face_color), and the radius (radius)).
  • position (numpy.ndarray or array_like) – (Nx3 : float32) - Position of each polyhedra.
  • orientation (numpy.ndarray or array_like) – (Nx4 : float32) - Orientation of each polyhedra (as a quaternion).
  • color (numpy.ndarray or array_like) – (Nx3 : float32) - Color of each polyhedron.
  • N (int) – Number of spheres in the geometry. If None, determine N from position.

See also

Convex polyhedron
Tutorial: Defining and setting convex polyhedron geometry properties.

Note

The constructor arguments position, orientation, and color are 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:fresnel.util.array
orientation

Read or modify the orientations of the polyhedra.

Type:fresnel.util.array
color

Read or modify the color of the polyhedra.

Type:fresnel.util.array
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:float
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 scene
  • points (numpy.ndarray or array_like) – (Nx2x3 : float32) - cylinder start and end points.
  • radius (numpy.ndarray or array_like) – (N : float32) - Radius of each cylinder.
  • color (numpy.ndarray or array_like) – (Nx2x3 : float32) - Color of each start and end point.
  • N (int) – Number of cylinders in the geometry. If None, determine N from points.

See also

Cylinder
Tutorial: defining and setting cyliner geometry properties

Note

The constructor arguments points, radius, and color are 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:fresnel.util.array
radius

Read or modify the radii of the cylinders.

Type:fresnel.util.array
color

Read or modify the colors of the start and end points of the cylinders.

Type:fresnel.util.array
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.

Geometry provides operations common to all geometry classes.

material

The geometry’s material.

Type:fresnel.material.Material
outline_material

The geometry’s outline material.

Type:fresnel.material.Material
outline_width

The geometry’s outline width, in distance units in the scene’s coordinate system.

Type:float

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.

remove()

Remove the geometry from the scene.

After calling remove, the geometry is no longer part of the scene. It cannot be added back into the scene. Use disable() if you want a reversible operation.

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 scene
  • vertices (numpy.ndarray or array_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.ndarray or array_like) – (3Tx3 : float32) - Color of each vertex.
  • position (numpy.ndarray or array_like) – (Nx3 : float32) - Positions of each mesh instance.
  • orientation (numpy.ndarray or array_like) – (Nx4 : float32) - Orientation of each mesh instance (as a quaternion).
  • N (int) – Number of mesh instances in the geometry. If None, determine N from position.

See also

Interactive scene view
Tutorial: Defining and setting mesh geometry properties.

Note

The constructor arguments position, orientation, and color are 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. Mesh determines 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:fresnel.util.array
orientation

Read or modify the orientations of the mesh instances.

Type:fresnel.util.array
color

Read or modify the color of the vertices.

Type:fresnel.util.array
get_extents()

Get the extents of the geometry

Returns:
[[minimum x, minimum y, minimum z],
[maximum x, maximum y, maximum z]]
class fresnel.geometry.Prism(scene, vertices, position=None, angle=None, height=None, color=None, N=None, material=<fresnel.material.Material object>, outline_material=<fresnel.material.Material object>, outline_width=0.0)

Prism geometry.

Define a set of right convex prism primitives. The bottom polygon face is always in the xy plane. Each prism may have a different height and rotation angle.

Parameters:
  • scene (fresnel.Scene) – Add the geometry to this scene
  • vertices – The vertices of the polygon in a counter clockwise winding direction. Type: anything convertible by numpy to a Nx2 array of floats.
  • position – Positions of the prisms, optional. Type: anything convertible by numpy to a Nx3 array of floats.
  • height – Height of each prism in the z direction, optional. Type: anything convertible by numpy to a N length array of floats.
  • angle – Rotation angle of each prism (in radians), optional. Type: anything convertible by numpy to a N length array of floats.
  • color – (r,g,b) color of each particle, optional. Type: anything convertible by numpy to a Nx3 array of floats.
  • N (int) – Number of prisms in the geometry. If None, determine N from position.

Note

The constructor arguments position, height, angle, and color are 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.

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 prisms.

Type:fresnel.util.array
height

Read or modify the heights of the prisms.

Type:fresnel.util.array
angle

Read or modify the angles of the prisms.

Type:fresnel.util.array
color

Read or modify the color of the prisms.

Type:fresnel.util.array
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:

See also

Sphere
Tutorial: Defining and setting sphere geometry properties.

Note

The constructor arguments position, radius, and color are 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:fresnel.util.array
radius

Read or modify the radii of the spheres.

Type:fresnel.util.array
color

Read or modify the color of the spheres.

Type:fresnel.util.array
get_extents()

Get the extents of the geometry

Returns:[[minimum x, minimum y, minimum z],[maximum x, maximum y, maximum z]]