# Path: sunds/core/tf_geometry/cameras.py
# class AbstractCamera(abc.ABC):
# class PinholeCamera(AbstractCamera):
#   def project(self, points: TensorLike) -> tf.Tensor:
#   def unproject(self,
#                 points: Optional[TensorLike] = None,
#                 to_rays: bool = True) -> tf.Tensor:
#   def pixel_centers(self) -> tf.Tensor:
#   def __post_init__(self):
#   def from_fov(
#       cls,
#       *,
#       image_width: int,
#       image_height: int,
#       horizontal_fov_in_degrees: float,
#       vertical_fov_in_degrees: Optional[float] = None) -> 'PinholeCamera':
#     def focal_length_from_fov(image_size, fov_in_degrees):
#   def from_intrinsics(
#       cls,
#       *,
#       image_size_in_pixels: Tuple[int, int],
#       focal_length_in_pixels: Tuple[float, float],
#       principal_point_in_pixels: Optional[Tuple[float, float]] = None,
#       skew: float = 0.0,
#   ) -> 'PinholeCamera':
#   def project(self, points: TensorLike) -> tf.Tensor:
#   def unproject(self,
#                 points: Optional[TensorLike] = None,
#                 to_rays: bool = True) -> tf.Tensor:
#   def pixel_centers(self) -> tf.Tensor:
#   K: TensorLike  # pylint: disable=invalid-name
# 
# Path: sunds/core/tf_geometry/isometry.py
# class Isometry:
#   R: TensorLike  # pylint: disable=invalid-name
#   def __post_init__(self):
#   def from_matrix(cls, matrix: TensorLike) -> 'Isometry':
#   def matrix3x4(self) -> tf.Tensor:
#   def matrix4x4(self) -> tf.Tensor:
#   def inverse(self) -> 'Isometry':
#   def compose(self, other: 'Isometry') -> 'Isometry':
#   def transform_points(self, points: TensorLike) -> tf.Tensor:
#   def __mul__(
#       self, other: Union['Isometry',
#                          TensorLike]) -> Union['Isometry', tf.Tensor]:


from typing import Dict
from sunds.core.tf_geometry import cameras
from sunds.core.tf_geometry import isometry
import tensorflow as tf
  image points and camera center.

  See `rays_from_image_grid` for generating rays passing through centers of all
  pixels in the camera image.

  The image points are provided as a tensor of shape `(..., 2)`, stored in
  convention defined by the camera model. For example if the camera model is an
  instance of type `isun.geometry.PinholeCamera`, the image points should have
  the following convention: The top left corner of the image is `(0, 0)` and the
  bottom right corner is `(image_width, image_height)`. So the center of the top
  left corner pixel is `(0.5, 0.5)`.

  Args:
    camera: An instance of camera of type `isun.geometry.AbstractCamera`.
    world_from_camera: Pose of the camera w.r.t world represented by an isometry
      transform `[R | t]` that takes points to camera frame to world.
    points_image: A tensor of shape `(..., 2)` containing image points.

  Returns:
    ray_orgins: Tensor of shape `(..., 3)` containing origin of each ray.
    ray_directions: Tensor of shape `(..., 3)` containing (normalized) direction
      vectors of each ray.
  """
  # Get rays through each pixel center by camera unproject.
  points_camera = camera.unproject(points_image)

  # Transform into world-frame rays.
  return _rays_from_directions(points_camera, world_from_camera)



# Path: sunds/core/tf_geometry/cameras.py
# class AbstractCamera(abc.ABC):
# class PinholeCamera(AbstractCamera):
#   def project(self, points: TensorLike) -> tf.Tensor:
#   def unproject(self,
#                 points: Optional[TensorLike] = None,
#                 to_rays: bool = True) -> tf.Tensor:
#   def pixel_centers(self) -> tf.Tensor:
#   def __post_init__(self):
#   def from_fov(
#       cls,
#       *,
#       image_width: int,
#       image_height: int,
#       horizontal_fov_in_degrees: float,
#       vertical_fov_in_degrees: Optional[float] = None) -> 'PinholeCamera':
#     def focal_length_from_fov(image_size, fov_in_degrees):
#   def from_intrinsics(
#       cls,
#       *,
#       image_size_in_pixels: Tuple[int, int],
#       focal_length_in_pixels: Tuple[float, float],
#       principal_point_in_pixels: Optional[Tuple[float, float]] = None,
#       skew: float = 0.0,
#   ) -> 'PinholeCamera':
#   def project(self, points: TensorLike) -> tf.Tensor:
#   def unproject(self,
#                 points: Optional[TensorLike] = None,
#                 to_rays: bool = True) -> tf.Tensor:
#   def pixel_centers(self) -> tf.Tensor:
#   K: TensorLike  # pylint: disable=invalid-name
# 
# Path: sunds/core/tf_geometry/isometry.py
# class Isometry:
#   R: TensorLike  # pylint: disable=invalid-name
#   def __post_init__(self):
#   def from_matrix(cls, matrix: TensorLike) -> 'Isometry':
#   def matrix3x4(self) -> tf.Tensor:
#   def matrix4x4(self) -> tf.Tensor:
#   def inverse(self) -> 'Isometry':
#   def compose(self, other: 'Isometry') -> 'Isometry':
#   def transform_points(self, points: TensorLike) -> tf.Tensor:
#   def __mul__(
#       self, other: Union['Isometry',
#                          TensorLike]) -> Union['Isometry', tf.Tensor]:


# Path: sunds/core/tf_geometry/rays.py
from typing import Dict
from sunds.core.tf_geometry import cameras
from sunds.core.tf_geometry import isometry
import tensorflow as tf

  image points and camera center.

  See `rays_from_image_grid` for generating rays passing through centers of all
  pixels in the camera image.

  The image points are provided as a tensor of shape `(..., 2)`, stored in
  convention defined by the camera model. For example if the camera model is an
  instance of type `isun.geometry.PinholeCamera`, the image points should have
  the following convention: The top left corner of the image is `(0, 0)` and the
  bottom right corner is `(image_width, image_height)`. So the center of the top
  left corner pixel is `(0.5, 0.5)`.

  Args:
    camera: An instance of camera of type `isun.geometry.AbstractCamera`.
    world_from_camera: Pose of the camera w.r.t world represented by an isometry
      transform `[R | t]` that takes points to camera frame to world.
    points_image: A tensor of shape `(..., 2)` containing image points.

  Returns:
    ray_orgins: Tensor of shape `(..., 3)` containing origin of each ray.
    ray_directions: Tensor of shape `(..., 3)` containing (normalized) direction
      vectors of each ray.
  """
  # Get rays through each pixel center by camera unproject.
  points_camera = camera.unproject(points_image)

  # Transform into world-frame rays.
  return _rays_from_directions(points_camera, world_from_camera)



def rays_from_image_grid(camera: cameras.CameraType,