a
    ij
                     @  s   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ej	dddd	d
ddddddddZ
ej	dddd	d
ddddddddZej	ddddddddZej	ddddddddZdS )zCommon geometric utils.    )annotations)checking)compat)numpy_utils)
FloatArrayF)strict.)keepdimsxnpzFloatArray['... n']boolznumpy_utils.NpModulezFloatArray['... 1?'])x0x1r   r	   returnc                C  s   | d| |}|r|d S |S )a  Dot product on the last dimension, with broadcasting support.

  Contrary to `np.dot`, the behavior is consistent for 1-dim vs n-dim (while
  dot act as matmul).
  First dimensions are always broadcasted.

  Args:
    x0: Vector array
    x1: Vector array
    keepdims: If True, returns `FloatArray['... 1']`
    xnp: Numpy module to use

  Returns:
    The dot product along the last axis.
  z...m,...m->...).N)Zeinsum)r   r   r   r	   y r   Q/home/ghrups/robot-bench/.venv/lib/python3.9/site-packages/etils/enp/geo_utils.py	batch_dot   s    r   zFloatArray[..., 3]c                C  s6   t j|| |d|d}t| ||d}|||}|S )z*Compute angle between 2 vectors, unsigned.Zaxisr   r   )r   normcrossr   Zarctan2)r   r   r   r	   Za0Za1Zangler   r   r   angle_between9   s    	r   )uvr   c                 C  s&   t | |ddtj|dddd  | S )zProject `u` onto `v`.Tr   r   r      )r   r   r   )r   r   r   r   r   project_onto_vectorH   s    r   )r   nr   c                 C  s   | t | | S )z3Project `u` onto the plane `n` (orthogonal vector).)r   )r   r   r   r   r   project_onto_planeU   s    r   N)__doc__
__future__r   Z	etils.enpr   r   r   Zetils.enp.typingr   Zcheck_and_normalize_arraysr   r   r   r   r   r   r   r   <module>   s"   



