(eye, center, world_up)
return camera_matrices
Computes camera viewing matrices.

  Functionality mimes gluLookAt (third_party/GL/glu/include/GLU/glu.h).

  Args:
    eye: 2-D float32 tensor with shape [batch_size, 3] containing the XYZ world
        space position of the camera.
    center: 2-D float32 tensor with shape [batch_size, 3] containing a position
        along the center of the camera's gaze.
    world_up: 2-D float32 tensor with shape [batch_size, 3] specifying the
        world's up direction; the output camera will have no tilt with respect
        to this direction.

  Returns:
    A [batch_size, 4, 4] float tensor containing a right-handed camera
    extrinsics matrix that maps points from world space to points in eye space.
Computes camera viewing matrices.
Computes camera viewing matrices .
def look_at(eye, center, world_up):
  """Computes camera viewing matrices.

  Functionality mimes gluLookAt (third_party/GL/glu/include/GLU/glu.h).

  Args:
    eye: 2-D float32 tensor with shape [batch_size, 3] containing the XYZ world
        space position of the camera.
    center: 2-D float32 tensor with shape [batch_size, 3] containing a position
        along the center of the camera's gaze.
    world_up: 2-D float32 tensor with shape [batch_size, 3] specifying the
        world's up direction; the output camera will have no tilt with respect
        to this direction.

  Returns:
    A [batch_size, 4, 4] float tensor containing a right-handed camera
    extrinsics matrix that maps points from world space to points in eye space.
  """
  batch_size = center.shape[0].value
  vector_degeneracy_cutoff = 1e-6
  forward = center - eye
  forward_norm = tf.norm(forward, ord='euclidean', axis=1, keepdims=True)
  tf.assert_greater(
      forward_norm,
      vector_degeneracy_cutoff,
      message='Camera matrix is degenerate because eye and center are close.')
  forward = tf.divide(forward, forward_norm)

  to_side = tf.cross(forward, world_up)
  to_side_norm = tf.norm(to_side, ord='euclidean', axis=1, keepdims=True)
  tf.assert_greater(
      to_side_norm,
      vector_degeneracy_cutoff,
      message='Camera matrix is degenerate because up and gaze are close or'
      'because up is degenerate.')
  to_side = tf.divide(to_side, to_side_norm)
  cam_up = tf.cross(to_side, forward)

  w_column = tf.constant(
      batch_size * [[0., 0., 0., 1.]], dtype=tf.float32)  # [batch_size, 4]
  w_column = tf.reshape(w_column, [batch_size, 4, 1])
  view_rotation = tf.stack(
      [to_side, cam_up, -forward,
       tf.zeros_like(to_side, dtype=tf.float32)],
      axis=1)  # [batch_size, 4, 3] matrix
  view_rotation = tf.concat(
      [view_rotation, w_column], axis=2)  # [batch_size, 4, 4]

  identity_batch = tf.tile(tf.expand_dims(tf.eye(3), 0), [batch_size, 1, 1])
  view_translation = tf.concat([identity_batch, tf.expand_dims(-eye, 2)], 2)
  view_translation = tf.concat(
      [view_translation,
       tf.reshape(w_column, [batch_size, 1, 4])], 1)
  camera_matrices = tf.matmul(view_rotation, view_translation)
  return camera_matrices
def look_at ( eye , center , world_up ) : batch_size = center . shape [ 0 ] . value vector_degeneracy_cutoff = 1e-6 forward = center - eye forward_norm = tf . norm ( forward , ord = 'euclidean' , axis = 1 , keepdims = True ) tf . assert_greater ( forward_norm , vector_degeneracy_cutoff , message = 'Camera matrix is degenerate because eye and center are close.' ) forward = tf . divide ( forward , forward_norm ) to_side = tf . cross ( forward , world_up ) to_side_norm = tf . norm ( to_side , ord = 'euclidean' , axis = 1 , keepdims = True ) tf . assert_greater ( to_side_norm , vector_degeneracy_cutoff , message = 'Camera matrix is degenerate because up and gaze are close or' 'because up is degenerate.' ) to_side = tf . divide ( to_side , to_side_norm ) cam_up = tf . cross ( to_side , forward ) w_column = tf . constant ( batch_size * [ [ 0. , 0. , 0. , 1. ] ] , dtype = tf . float32 ) # [batch_size, 4] w_column = tf . reshape ( w_column , [ batch_size , 4 , 1 ] ) view_rotation = tf . stack ( [ to_side , cam_up , - forward , tf . zeros_like ( to_side , dtype = tf . float32 ) ] , axis = 1 ) # [batch_size, 4, 3] matrix view_rotation = tf . concat ( [ view_rotation , w_column ] , axis = 2 ) # [batch_size, 4, 4] identity_batch = tf . tile ( tf . expand_dims ( tf . eye ( 3 ) , 0 ) , [ batch_size , 1 , 1 ] ) view_translation = tf . concat ( [ identity_batch , tf . expand_dims ( - eye , 2 ) ] , 2 ) view_translation = tf . concat ( [ view_translation , tf . reshape ( w_column , [ batch_size , 1 , 4 ] ) ] , 1 ) camera_matrices = tf . matmul ( view_rotation , view_translation ) return camera_matrices