differt.geometry.fibonacci_lattice#
- fibonacci_lattice(n, dtype=None, *, frustum=None)[source]#
Return a lattice of vertices on the unit sphere.
This function uses the Fibonacci lattice method [8] to generate an almost uniformly distributed set of points on the unit sphere.
If
frustumis passed, points are distributed in the region defined by the frustum’s limits.- Parameters:
n (
int) – The size of the lattice.dtype (
str|type[Any] |dtype|SupportsDType|None) – The float dtype of the vertices.frustum (
Float[ArrayLike, '2 2']|Float[ArrayLike, '2 3']|None) –The spatial region where to sample points.
The frustum in an array of min. and max. values for azimuthal and elevation angles, see
viewing_frustumfor example.It is allowed to pass a frustum with distance values, but it will be ignored as the distance of from sampled points to origin is always 1.
- Return type:
- Returns:
The array of vertices.
- Raises:
ValueError – If the provided dtype is not a floating dtype, or if
nis not strictly positive.
Examples
The following example shows how to generate and plot a fibonacci lattice.
>>> from differt.geometry import ( ... fibonacci_lattice, ... ) >>> from differt.plotting import draw_markers >>> >>> xyz = fibonacci_lattice(100) >>> fig = draw_markers(xyz, marker={"color": xyz[:, 0]}, backend="plotly") >>> fig