pysdic.Rays#

The pysdic.Rays provides a standardized way to store and manage a collection of rays in 3D space, expressed in world coordinates. Each ray is stored with its origin and its unit direction in an array with shape \((\dots, 6)\).

See also

Rays class#

class Rays(rays)[source]#

A collection of rays in 3D space, expressed in world coordinates.

This class is returned by the compute_rays method of the extrinsic transformations (for example pysdic.PerspectiveExtrinsic) and by the function pysdic.compute_rays(). Each ray passes through a normalized point of the camera.

The rays are stored in an array with shape \((\dots, 6)\), where the last dimension encodes the origin and the unit direction of each ray:

rays[..., 0:3]    # origin (x, y, z)
rays[..., 3:6]    # direction (dx, dy, dz)

The points of a ray are \(\vec{X}(t) = \vec{O} + t \, \vec{d}\) with \(t \geq 0\).

Note

The array is copied and read-only, so the rays cannot be modified after their creation.

Parameters:

rays (ArrayLike) – The rays in world coordinates. Shape \((\dots, 6)\).

property batch_shape: Tuple[int, ...]#

[Get] the batch shape of the rays, i.e. the shape of the array without the last dimension.

Returns:

The batch shape \((\dots)\).

Return type:

Tuple[int, …]

property directions: ndarray#

[Get] the unit directions \(\vec{d}\) of the rays in world coordinates (read-only view).

Returns:

The directions of the rays. Shape \((\dots, 3)\).

Return type:

numpy.ndarray

property origins: ndarray#

[Get] the origins \(\vec{O}\) of the rays in world coordinates (read-only view).

Returns:

The origins of the rays. Shape \((\dots, 3)\).

Return type:

numpy.ndarray

points_at(t)[source]#

Compute the points of the rays at the abscissa \(t\):

\[\vec{X}(t) = \vec{O} + t \, \vec{d}\]

Since the directions are unit vectors, \(t\) is the distance to the origin.

Parameters:

t (ArrayLike) – The abscissa, a scalar or an array broadcastable to the batch shape of the rays.

Returns:

The points in world coordinates. Shape \((\dots, 3)\).

Return type:

numpy.ndarray