differt.rt.fermat module

differt.rt.fermat module#

Path tracing utilities that utilize Fermat’s principle.

Fermat’s principle states that the path taken by a ray between two given points is the path that can be traveled in the least time [Wikipediacontributors24a]. In a homogeneous medium, this means that the path of least time is also the path of last distance.

As a result, this module offers minimization methods for finding ray paths.

fermat_path_on_planar_mirrors(from_vertices, to_vertices, mirror_vertices, mirror_normals, **kwargs)[source]#

Return the ray paths between pairs of vertices, that reflect on a given list of mirrors in between.

Parameters:
  • from_vertices (Float[Array, '*batch 3']) – An array of from vertices, i.e., vertices from which the ray paths start. In a radio communications context, this is usually an array of transmitters.

  • to_vertices (Float[Array, '*batch 3']) – An array of to vertices, i.e., vertices to which the ray paths end. In a radio communications context, this is usually an array of receivers.

  • mirror_vertices (Float[Array, '*batch num_mirrors 3']) – An array of mirror vertices. For each mirror, any vertex on the infinite plane that describes the mirror is considered to be a valid vertex.

  • mirror_normals (Float[Array, '*batch num_mirrors 3']) –

    An array of mirror normals, where each normal has a unit length and is perpendicular to the corresponding mirror.

    Note

    Unlike with the Image method, the normals do not actually have to be unit vectors. However, we keep the same documentation so it is easier for the user to move from one method to the other.

  • kwargs (Any) – Keyword arguments passed to minimize.

Return type:

Float[Array, '*batch num_mirrors 3']

Returns:

An array of ray paths obtained using Fermat’s principle.

Note

The paths do not contain the starting and ending vertices.

You can easily create the complete ray paths using jax.numpy.concatenate:

paths = fermat_path_on_planar_mirrors(
    from_vertices,
    to_vertices,
    mirror_vertices,
    mirror_normals,
)

full_paths = jnp.concatenate(
    (jnp.expand_dims(from_vertices, -2), got, jnp.expand_dims(to_vertices, -2)),
    axis=-2,
)