
    ni                     *    S r SSKrSSKrS rS rS rg)z/Common functionalities to process point clouds.    Nc                    US[         R                  " US-  5      -  -  n[        R                  " [        R                  " U5      US/5      nSUS-   -  U-
  U-  U -  S-  n[        R                  " [        R                  " U5      US/5      R
                  nSUS-   -  U-
  U-  U -  S-  n[        R                  " XhU 4SS9n	U	$ )a  Converts from a depth map to a point cloud.

Args:
  distances: An numpy array which has the shape of (height, width) that
    denotes a distance map. The unit is meter.
  fov: The field of view of the camera in the vertical direction. The unit
    is radian.
  width: The width of the image resolution of the camera.
  height: The height of the image resolution of the camera.

Returns:
  point_cloud: The converted point cloud from the distance map. It is a numpy
    array of shape (height, width, 3).
   g       @   g      ?axis)mathtannptilearangeTstack)
	distancesfovwidthheightfpxxpyypoint_clouds
             i/home/james-whalen/.local/lib/python3.13/site-packages/pybullet_envs/minitaur/vision/point_cloud_utils.pydistance_map_to_point_cloudr      s     DHHS3Y''(!	wwryy&!-"BH~"Y.2!	wwryy 5!*-//"BH~!#i/!3!!	*4+	    c                     [         R                  " U SS9n[         R                  " US   US   5      n[         R                  R	                  USS9SS2SS2S4   nX#S-   -  nU$ )zEstimates the normals of a point cloud using cross product.

Args:
  points: a point cloud represented as an 2D array of which has the shape of
    [m, n, 3].

Returns:
  normals: a 2D array of normal vectors which has the same shape as the input.
)r   r   r   r   r   r   NgHz>)r   gradientcrosslinalgnorm)pointsgradnormalnorms
normalizeds        r   point_cloud_normalsr'       s_     
V&	)$88DGT!W%&
))..a.
(At
4%&*	r   c                 B    [         R                  R                  X-
  SS9$ )a   Estimates the distance of a point to every point in a point cloud.

Args:
  point: a 3D vector representing a point.
  point_cloud: a point cloud represented as an 2D array of which has the shape
    of [m, n, 3].

Returns:
  distances: a distance field represented as a 2D array [m, n].
r   r   )r   r    r!   )pointr   s     r   point_cloud_distancesr*   1   s     
+!	44r   )__doc__r	   numpyr   r   r'   r*    r   r   <module>r.      s    5  0"5r   