# Path: ldif/util/camera_util.py
# def look_at(eye, center, world_up):
# def roll_pitch_yaw_to_rotation_matrices(roll_pitch_yaw):
# 
# Path: ldif/util/tf_util.py
# def assert_shape(tensor, shape, name):
# def log(msg, t):
# def tile_new_axis(t, axis, length):
# def zero_by_mask(mask, vals, replace_with=0.0):
# def remove_element(t, elt, axis):


from ldif.util import camera_util
from ldif.util import tf_util
import tensorflow as tf

NORMALIZATION_EPS = 1e-8
SQRT_NORMALIZATION_EPS = 1e-4
DIV_EPSILON = 1e-8


def sample_quadric_surface(quadric, center, samples):
  """Samples the algebraic distance to the input quadric at sparse locations.


  Args:
    quadric: Tensor with shape [..., 4, 4]. Contains the matrix of the quadric
      surface.
    center: Tensor with shape [..., 3]. Contains the [x,y,z] coordinates of the
      center of the coordinate frame of the quadric surface in NIC space with a
      top-left origin.
    samples: Tensor with shape [..., N, 3], where N is the number of samples to
      evaluate. These are the sample locations in the same space in which the
      quadric surface center is defined. Supports broadcasting the batching
      dimensions.

  Returns:
    distances: Tensor with shape [..., N, 1]. Contains the algebraic distance
      to the surface at each sample.
  """
  with tf.name_scope('sample_quadric_surface'):
    batching_dimensions = quadric.get_shape().as_list()[:-2]
    batching_rank = len(batching_dimensions)
    tf_util.assert_shape(quadric, batching_dimensions + [4, 4],
                         'sample_quadric_surface:quadric')

# Path: ldif/util/camera_util.py
# def look_at(eye, center, world_up):
# def roll_pitch_yaw_to_rotation_matrices(roll_pitch_yaw):
# 
# Path: ldif/util/tf_util.py
# def assert_shape(tensor, shape, name):
# def log(msg, t):
# def tile_new_axis(t, axis, length):
# def zero_by_mask(mask, vals, replace_with=0.0):
# def remove_element(t, elt, axis):


# Path: ldif/representation/quadrics.py
from ldif.util import camera_util
from ldif.util import tf_util
import tensorflow as tf


NORMALIZATION_EPS = 1e-8
SQRT_NORMALIZATION_EPS = 1e-4
DIV_EPSILON = 1e-8


def sample_quadric_surface(quadric, center, samples):
  """Samples the algebraic distance to the input quadric at sparse locations.


  Args:
    quadric: Tensor with shape [..., 4, 4]. Contains the matrix of the quadric
      surface.
    center: Tensor with shape [..., 3]. Contains the [x,y,z] coordinates of the
      center of the coordinate frame of the quadric surface in NIC space with a
      top-left origin.
    samples: Tensor with shape [..., N, 3], where N is the number of samples to
      evaluate. These are the sample locations in the same space in which the
      quadric surface center is defined. Supports broadcasting the batching
      dimensions.

  Returns:
    distances: Tensor with shape [..., N, 1]. Contains the algebraic distance
      to the surface at each sample.
  """
  with tf.name_scope('sample_quadric_surface'):
    batching_dimensions = quadric.get_shape().as_list()[:-2]
    batching_rank = len(batching_dimensions)
    tf_util.assert_shape(quadric, batching_dimensions + [4, 4],
                         'sample_quadric_surface:quadric')

    tf_util.assert_shape(center, batching_dimensions + [-1],