# 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
# def rays_from_image_points(camera: cameras.CameraType,
#                            world_from_camera: isometry.Isometry,
#                            points_image: TensorLike):
# def rays_from_image_grid(camera: cameras.CameraType,
#                          world_from_camera: isometry.Isometry):
# def _rays_from_directions(ray_directions: TensorLike,
#                           world_from_camera: isometry.Isometry):
# def depth_samples_along_rays(near_depth: TensorLike,
#                              far_depth: TensorLike,
#                              num_samples_per_ray: int,
#                              method: str = 'linspace_depth') -> tf.Tensor:
# def jitter_depth_samples_along_rays(point_depths: TensorLike) -> tf.Tensor:
# def point_samples_along_rays(ray_origins: TensorLike,
#                              ray_directions: TensorLike,
#                              point_depths: TensorLike) -> tf.Tensor:


from absl.testing import parameterized
from sunds.core.tf_geometry import cameras
from sunds.core.tf_geometry import isometry
from sunds.core.tf_geometry import rays
import numpy as np
import tensorflow as tf
# limitations under the License.

"""Tests for isun.geometry.rays."""



def simple_pinhole_camera():
  image_width, image_height = 320, 240
  fx, fy, cx, cy = 400.0, 400.0, image_width / 2, image_height / 2
  return cameras.PinholeCamera(
      K=[[fx, 0., cx], [0., fy, cy], [0., 0., 1.]],
      image_width=image_width,
      image_height=image_height)


def random_pose():
  """Use QR decomposition of random (normal) matrix to get random rotation."""
  random_rotation, _ = tf.linalg.qr(tf.random.normal(shape=[3, 3]))
  return isometry.Isometry(R=random_rotation, t=tf.random.uniform(shape=[3]))


def pinhole_camera_with_random_pose():
  return {
      'testcase_name': 'pinhole_camera_with_random_pose',
      'camera': simple_pinhole_camera(),
      'world_from_camera': random_pose(),
  }


def pinhole_camera_with_non_square_pixels():

# 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
# def rays_from_image_points(camera: cameras.CameraType,
#                            world_from_camera: isometry.Isometry,
#                            points_image: TensorLike):
# def rays_from_image_grid(camera: cameras.CameraType,
#                          world_from_camera: isometry.Isometry):
# def _rays_from_directions(ray_directions: TensorLike,
#                           world_from_camera: isometry.Isometry):
# def depth_samples_along_rays(near_depth: TensorLike,
#                              far_depth: TensorLike,
#                              num_samples_per_ray: int,
#                              method: str = 'linspace_depth') -> tf.Tensor:
# def jitter_depth_samples_along_rays(point_depths: TensorLike) -> tf.Tensor:
# def point_samples_along_rays(ray_origins: TensorLike,
#                              ray_directions: TensorLike,
#                              point_depths: TensorLike) -> tf.Tensor:


# Path: sunds/core/tf_geometry/rays_test.py
from absl.testing import parameterized
from sunds.core.tf_geometry import cameras
from sunds.core.tf_geometry import isometry
from sunds.core.tf_geometry import rays
import numpy as np
import tensorflow as tf

# limitations under the License.

"""Tests for isun.geometry.rays."""



def simple_pinhole_camera():
  image_width, image_height = 320, 240
  fx, fy, cx, cy = 400.0, 400.0, image_width / 2, image_height / 2
  return cameras.PinholeCamera(
      K=[[fx, 0., cx], [0., fy, cy], [0., 0., 1.]],
      image_width=image_width,
      image_height=image_height)


def random_pose():
  """Use QR decomposition of random (normal) matrix to get random rotation."""
  random_rotation, _ = tf.linalg.qr(tf.random.normal(shape=[3, 3]))
  return isometry.Isometry(R=random_rotation, t=tf.random.uniform(shape=[3]))


def pinhole_camera_with_random_pose():
  return {
      'testcase_name': 'pinhole_camera_with_random_pose',
      'camera': simple_pinhole_camera(),
      'world_from_camera': random_pose(),
  }


def pinhole_camera_with_non_square_pixels():

  camera = cameras.PinholeCamera.from_intrinsics(