differt.plotting.draw_rays#
- draw_rays(ray_origins, ray_directions, *, ratio=0.1, **kwargs)[source]#
Plot a batch of rays.
- Parameters:
ray_origins (
Real[ArrayLike, '*batch 3']) – An array of origin vertices.ray_directions (
Real[ArrayLike, '*batch 3']) – An array of ray directions. The ray ends should be equal toray_origins + ray_directions.ratio (
Float[ArrayLike, '']) – The ratio of the arrow head size with respect to the corresponding ray length.kwargs (
Any) – Keyword arguments passed toArrow,quiver, or a mix ofScatter3dandCone[1] , depending on the backend.
- Return type:
- Returns:
The resulting plot output.
Specific keyword rules for Plotly's backend
The following keyword arguments have a special meaning:
color: the color of the rays;name: the name of the rays;
The following keyword arguments are passed to the line plot:
legendgroup=name;line_color=color;mode="lines";showlegend=False.
The following keyword arguments are passed to the cone plot (i.e., arrow head):
colorscale=[color, color];hoverinfo="name";legendgroup=name;name=name;showscale=False;showlegend=True;sizemode="raw".
If you wish to override any of the above arguments, or add any additional, you can use the following keyword arguments:
cone_kwargs: a mapping of keyword arguments passed toCone;line_kwargs: a mapping of keyword arguments passed toScatter3d;
Other keyword arguments are passed to both constructors.
Examples
The following example shows how to plot rays.
>>> from differt.geometry import fibonacci_lattice >>> from differt.plotting import draw_rays >>> >>> ray_origins = jnp.zeros(3) >>> ray_directions = fibonacci_lattice(50) >>> ray_origins, ray_directions = jnp.broadcast_arrays( ... ray_origins, ray_directions ... ) >>> fig = draw_rays( ... ray_origins, ... ray_directions, ... backend="plotly", ... ) >>> fig