(quat, tol=_TOL)
return np.stack(
      [np.log(q_norm[..., 0]), v_new[..., 0], v_new[..., 1], v_new[..., 2]],
      axis=-1)
Log of a quaternion.

  This function supports inputs with or without leading batch dimensions.

  Args:
    quat: A quaternion [w, i, j, k].
    tol: numerical tolerance to prevent nan.

  Returns:
    4D array representing the log of `quat`. This is analogous to
    `rmat_to_axisangle`.
Log of a quaternion.
Log of a quaternion .
def quat_log(quat, tol=_TOL):
  """Log of a quaternion.

  This function supports inputs with or without leading batch dimensions.

  Args:
    quat: A quaternion [w, i, j, k].
    tol: numerical tolerance to prevent nan.

  Returns:
    4D array representing the log of `quat`. This is analogous to
    `rmat_to_axisangle`.
  """
  # Ensure quat is an np.array in case a tuple or a list is passed
  quat = np.asarray(quat)
  q_norm = np.linalg.norm(quat + tol, axis=-1, keepdims=True)
  a = quat[..., 0:1]
  v = np.stack([quat[..., 1], quat[..., 2], quat[..., 3]], axis=-1)
  # Clip to 2*tol because we subtract it here
  v_new = v / np.linalg.norm(v + tol, axis=-1, keepdims=True) * np.arccos(
      _clip_within_precision(a - tol, -1., 1., precision=2.*tol)) / q_norm
  return np.stack(
      [np.log(q_norm[..., 0]), v_new[..., 0], v_new[..., 1], v_new[..., 2]],
      axis=-1)
def quat_log ( quat , tol = _TOL ) : # Ensure quat is an np.array in case a tuple or a list is passed quat = np . asarray ( quat ) q_norm = np . linalg . norm ( quat + tol , axis = - 1 , keepdims = True ) a = quat [ ... , 0 : 1 ] v = np . stack ( [ quat [ ... , 1 ] , quat [ ... , 2 ] , quat [ ... , 3 ] ] , axis = - 1 ) # Clip to 2*tol because we subtract it here v_new = v / np . linalg . norm ( v + tol , axis = - 1 , keepdims = True ) * np . arccos ( _clip_within_precision ( a - tol , - 1. , 1. , precision = 2. * tol ) ) / q_norm return np . stack ( [ np . log ( q_norm [ ... , 0 ] ) , v_new [ ... , 0 ] , v_new [ ... , 1 ] , v_new [ ... , 2 ] ] , axis = - 1 )