# Path: ldif/util/np_util.py
# def batch_np(arr, batch_size):
# def make_coordinate_grid(height, width, is_screen_space, is_homogeneous):
# def make_coordinate_grid_3d(length, height, width, is_screen_space,
#                             is_homogeneous):
# def filter_valid(mask, vals):
# def zero_by_mask(mask, vals, replace_with=0.0):
# def make_mask(im, thresh=0.0):
# def make_pixel_mask(im):
# def thresh_and_radius_to_distance(radius, thresh):
# def plot_rbfs_at_thresh(centers, radii, thresh=0.5):
# def plot_rbfs(centers, radii, scale=10.0):
# def cube_and_render(volume, thresh):
# def sample_surface(quadrics, centers, radii, length, height, width,
#                    renormalize):
# def visualize_prediction(quadrics,
#                          centers,
#                          radii,
#                          renormalize,
#                          thresh=0.0,
#                          input_volumes=None):
# 
# 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):


import math
import numpy as np
import tensorflow as tf
from ldif.util import np_util
from ldif.util import camera_util
from ldif.util import tf_util
  assert isinstance(reflect_x, bool)
  assert isinstance(reflect_y, bool)
  assert isinstance(reflect_z, bool)
  floats = [-1.0 if ax else 1.0 for ax in [reflect_x, reflect_y, reflect_z]]
  mult = np.array(floats, dtype=np.float32)
  shape = samples.get_shape().as_list()
  leading_dims = shape[:-1]
  assert shape[-1] == 3
  mult = mult.reshape([1] * len(leading_dims) + [3])
  mult = tf.constant(mult, dtype=tf.float32)
  return mult * samples


def z_reflect(samples):
  """Reflects the sample locations across the XY plane.

  Args:
    samples: Tensor with shape [..., 3]

  Returns:
    reflected: Tensor with shape [..., 3]. The reflected samples.
  """
  return reflect(samples, reflect_z=True)


def get_world_to_camera(idx):
  assert idx == 1
  eye = tf.constant([[0.671273, 0.757946, -0.966907]], dtype=tf.float32)
  look_at = tf.zeros_like(eye)
  world_up = tf.constant([[0., 1., 0.]], dtype=tf.float32)

# Path: ldif/util/np_util.py
# def batch_np(arr, batch_size):
# def make_coordinate_grid(height, width, is_screen_space, is_homogeneous):
# def make_coordinate_grid_3d(length, height, width, is_screen_space,
#                             is_homogeneous):
# def filter_valid(mask, vals):
# def zero_by_mask(mask, vals, replace_with=0.0):
# def make_mask(im, thresh=0.0):
# def make_pixel_mask(im):
# def thresh_and_radius_to_distance(radius, thresh):
# def plot_rbfs_at_thresh(centers, radii, thresh=0.5):
# def plot_rbfs(centers, radii, scale=10.0):
# def cube_and_render(volume, thresh):
# def sample_surface(quadrics, centers, radii, length, height, width,
#                    renormalize):
# def visualize_prediction(quadrics,
#                          centers,
#                          radii,
#                          renormalize,
#                          thresh=0.0,
#                          input_volumes=None):
# 
# 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/util/geom_util.py
import math
import numpy as np
import tensorflow as tf
from ldif.util import np_util
from ldif.util import camera_util
from ldif.util import tf_util

  assert isinstance(reflect_x, bool)
  assert isinstance(reflect_y, bool)
  assert isinstance(reflect_z, bool)
  floats = [-1.0 if ax else 1.0 for ax in [reflect_x, reflect_y, reflect_z]]
  mult = np.array(floats, dtype=np.float32)
  shape = samples.get_shape().as_list()
  leading_dims = shape[:-1]
  assert shape[-1] == 3
  mult = mult.reshape([1] * len(leading_dims) + [3])
  mult = tf.constant(mult, dtype=tf.float32)
  return mult * samples


def z_reflect(samples):
  """Reflects the sample locations across the XY plane.

  Args:
    samples: Tensor with shape [..., 3]

  Returns:
    reflected: Tensor with shape [..., 3]. The reflected samples.
  """
  return reflect(samples, reflect_z=True)


def get_world_to_camera(idx):
  assert idx == 1
  eye = tf.constant([[0.671273, 0.757946, -0.966907]], dtype=tf.float32)
  look_at = tf.zeros_like(eye)
  world_up = tf.constant([[0., 1., 0.]], dtype=tf.float32)

  world_to_camera = camera_util.look_at(eye, look_at, world_up)