Handling Diffraction

Handling Diffraction#

Like reflection, diffraction changes the direction of rays that interact with the edges of an object. An edge can be a line segment or any rough transition between two adjacent surfaces. The angle of deflection depends on the angle between the incoming ray and the local direction of the edge at the point of incidence.

Unlike reflection, a ray is diffracted into a continuum of rays that form a cone-like structure around the edge.

Important

This tutorial is still TODO, but you can find premise of it below.

import jax.numpy as jnp
from differt.geometry import TriangleMesh, assemble_paths
from differt.plotting import draw_paths, set_backend
from differt.rt import fermat_path_on_linear_objects
from differt.scene import TriangleScene
set_backend("plotly")

corner = TriangleMesh.box()[0:4]

h = jnp.linspace(-0.5, 0.5, 5)
edge_origins = jnp.array([[-0.5, 0.5, -0.5]])
edge_vectors = jnp.array([[[0.0, 0.0, 1.0]]])
receivers = jnp.stack((jnp.zeros_like(h), jnp.ones_like(h), h), axis=-1)
scene = TriangleScene(
    transmitters=jnp.array([-1.0, -0.5, 0.0]), receivers=receivers, mesh=corner
)
fig = scene.plot(
    tx_kwargs={"labels": "BS", "name": "BS"},
    rx_kwargs={
        "labels": "UE",
        "marker_size": 5,
        "name": "UEs",
        "textfont_size": 10,
    },
)
fig
paths = fermat_path_on_linear_objects(
    scene.transmitters, scene.receivers, edge_origins, edge_vectors
)

paths = assemble_paths(
    scene.transmitters,
    paths,
    scene.receivers,
)

draw_paths(paths, figure=fig, name="Diffraction paths")