irtk.scene.PerspectiveCamera

class irtk.scene.PerspectiveCamera(fov: float, to_world: torch.Tensor | ndarray | List | Tuple, near: float = 1e-06, far: float = 10000000.0)

A class representing a perspective camera.

__init__(fov: float, to_world: torch.Tensor | ndarray | List | Tuple, near: float = 1e-06, far: float = 10000000.0) None

Initializes a PerspectiveCamera object.

Parameters:
  • fov (float) – The field of view of the camera.

  • to_world (TensorLike) – The transformation matrix to world coordinates (float, shape (4, 4)).

  • near (float) – The near clipping plane.

  • far (float) – The far clipping plane.

classmethod from_lookat(fov: float, origin: torch.Tensor | ndarray | List | Tuple, target: torch.Tensor | ndarray | List | Tuple, up: torch.Tensor | ndarray | List | Tuple, near: float = 1e-06, far: float = 10000000.0) PerspectiveCamera

Creates a PerspectiveCamera object from lookat parameters.

Parameters:
  • fov (float) – The field of view of the camera.

  • origin (TensorLike) – The origin of the camera (float, shape (3, )).

  • target (TensorLike) – The target point of the camera (float, shape (3, )).

  • up (TensorLike) – The up vector of the camera (float, shape (3, )).

  • near (float) – The near clipping plane.

  • far (float) – The far clipping plane.

Returns:

A PerspectiveCamera object.

Return type:

PerspectiveCamera

get_rays(samples: torch.Tensor, aspect_ratio: float) Tuple[torch.Tensor, torch.Tensor]

Generates rays from the camera.

Parameters:
  • samples (torch.Tensor) – The sample points.

  • aspect_ratio (float) – The aspect ratio of the camera.

Returns:

A tuple containing the ray origins and directions.

Return type:

Tuple[torch.Tensor, torch.Tensor]