fresnel.geometry

Overview

fresnel.geometry.Geometry

Base class for all geometry.

fresnel.geometry.ConvexPolyhedron

Convex polyhedron geometry.

fresnel.geometry.Cylinder

Cylinder geometry.

fresnel.geometry.Polygon

Polygon 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

examples/00-Basic-tutorials/01-Primitive-properties

Tutorial: Modifying primitive properties.

examples/00-Basic-tutorials/02-Material-properties

Tutorial: Modifying material properties.

examples/00-Basic-tutorials/03-Outline-materials

Tutorial: Applying outline materials.

examples/02-Advanced-topics/00-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

examples/01-Primitives/02-Convex-polyhedron-geometry

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

examples/01-Primitives/01-Cylinder-geometry

Tutorial: defining and setting cylinder 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

examples/01-Primitives/03-Mesh-geometry

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

  • vertices (numpy.ndarray or array_like) – (Nx2 : float32) - Polygon vertices.

  • position (numpy.ndarray or array_like) – (Nx2 : float32) - Position of each polygon.

  • angle (numpy.ndarray or array_like) – (N : float32) - Orientation angle of each polygon.

  • color (numpy.ndarray or array_like) – (Nx3 : float32) - 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.

See also

examples/01-Primitives/04-Polygon-geometry

Tutorial: defining and setting polygon geometry properties

Note

The constructor arguments position, angle, 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 polygons.

Type

fresnel.util.array

angle

Read or modify the orientation angles of the polygons.

Type

fresnel.util.array

color

Read or modify the colors of the polygons.

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

examples/01-Primitives/00-Sphere-geometry

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]]