fresnel.util¶
Overview
Map internal fresnel buffers as |
|
Convert convex polyhedron vertices to fresnel data structures |
|
Map internal image buffers as |
Details
Utilities.
-
class
fresnel.util.
Array
(buf, geom)¶ Map internal fresnel buffers as
numpy.ndarray
objects.fresnel.util.Array
provides a python interface to access internal data of memory buffers stored and managed by fresnel. You can access afresnel.util.Array
as if it were anumpy.ndarray
(with limited operations). Below, slice is a slice or arrayindexing
mechanic that numpy understands.Writing
Write to an array with
array[slice] = v
where v isnumpy.ndarray
,list
, or scalar value to broadcast. When v is a contiguousnumpy.ndarray
of the same data type, the data is copied directly from v into the internal buffer. Otherwise, it is converted to anumpy.ndarray
before copying.Reading
Read from an array with
v = array[slice]
. This returns a copy of the data as anumpy.ndarray
each time it is called.-
dtype
¶ Numpy data type
-
-
class
fresnel.util.
ImageArray
(buf, geom)¶ Map internal image buffers as
numpy.ndarray
objects.Inherits from
Array
and provides all of its functionality, plus some additional convenience methods specific to working with images. Images are represented asWxHx4
numpy.ndarray
ofuint8
values in RGBA format.When a
ImageArray
is the result of an image in a Jupyter notebook cell, Jupyter will display the image.
-
fresnel.util.
convex_polyhedron_from_vertices
(vertices)¶ Convert convex polyhedron vertices to fresnel data structures
- Parameters
vertices (
numpy.ndarray
orarray_like
) – (Nx3
:float64
) - The vertices of the polyhedron.- Returns
A dict containing the information used to draw the polyhedron. The dict contains the keys
face_origin
,face_normal
,face_color
, andradius
.
The dictionary can be used directly to draw a polyhedron from its vertices:
scene = fresnel.Scene() polyhedron = fresnel.util.convex_polyhedron_from_vertices(vertices) geometry = fresnel.geometry.ConvexPolyhedron(scene, polyhedron, position=[0, 0, 0], orientation=[1, 0, 0, 0])