o
    €o™i–	  ã                   @  sH   d dl mZ d dlmZ d dlmZmZ G dd„ dƒZG dd„ dƒZdS )	é    )Úannotations)ÚTensor)ÚVector2ÚVector3c                   @  ó    e Zd Zddd„Zdd	d
„ZdS )ÚZ1ProjectionÚpointsr   Úreturnr   c                 C  sL   |j ddd…f }|j}t|jƒr|j| ¡  ¡  jn|jd | }t|ƒS )aÌ  Project one or more Vector3 from the camera frame into the canonical z=1 plane through perspective division.

        Args:
            points: Vector3 representing the points to project.

        Returns:
            Vector2 representing the projected points.

        Example:
            >>> points = Vector3.from_coords(1., 2., 3.)
            >>> Z1Projection().project(points)
            x: 0.3333333432674408
            y: 0.6666666865348816

        .Né   é   )ÚdataÚzÚlenÚshapeÚTÚdiagÚinverser   )Úselfr   Úxyr   Úuv© r   úZ/home/ubuntu/.local/lib/python3.10/site-packages/kornia/sensors/camera/projection_model.pyÚproject   s   ,zZ1Projection.projectÚdepthúTensor | floatc                 C  s2   t |ttfƒrt|gƒ}t |j| |j| |¡S )a  Unproject one or more Vector2 from the canonical z=1 plane into the camera frame.

        Args:
            points: Vector2 representing the points to unproject.
            depth: Tensor representing the depth of the points to unproject.

        Returns:
            Vector3 representing the unprojected points.

        Example:
            >>> points = Vector2.from_coords(1., 2.)
            >>> Z1Projection().unproject(points, 3)
            x: tensor([3.])
            y: tensor([6.])
            z: tensor([3.])

        )Ú
isinstanceÚfloatÚintr   r   Úfrom_coordsÚxÚy©r   r   r   r   r   r   Ú	unproject.   s   
zZ1Projection.unprojectN©r   r   r	   r   )r   r   r   r   r	   r   ©Ú__name__Ú
__module__Ú__qualname__r   r"   r   r   r   r   r      s    
r   c                   @  r   )ÚOrthographicProjectionr   r   r	   r   c                 C  ó   t ‚©N©ÚNotImplementedError)r   r   r   r   r   r   F   ó   zOrthographicProjection.projectr   r   c                 C  r)   r*   r+   r!   r   r   r   r"   I   r-   z OrthographicProjection.unprojectNr#   )r   r   r   r   r	   r   r$   r   r   r   r   r(   E   s    
r(   N)	Ú
__future__r   Úkornia.corer   Úkornia.geometry.vectorr   r   r   r(   r   r   r   r   Ú<module>   s
   -