o
    €o™i”  ã                   @   sf   d Z ddlmZ ddlmZ ddlmZ dedefdd„Zded	edefd
d„Zdedefdd„Z	dS )z8Module containing functions for orthographic projection.é    N)ÚTensor©ÚKORNIA_CHECK_SHAPEÚpoints_in_cameraÚreturnc                 C   s   t | ddgƒ | ddd…f S )að  Project points from the camera frame into the canonical z=1 plane through orthographic projection.

    .. math::
        \begin{bmatrix} u \\ v \end{bmatrix} =
        \begin{bmatrix} x \\ y \\ z \end{bmatrix}


    Args:
        points_in_camera: Tensor representing the points to project.

    Returns:
        Tensor representing the projected points.

    Example:
        >>> points = torch.tensor([1., 2., 3.])
        >>> project_points_orthographic(points)
        tensor([1., 2.])

    Ú*Ú3.Né   r   ©r   © r   úb/home/ubuntu/.local/lib/python3.10/site-packages/kornia/geometry/camera/projection_orthographic.pyÚproject_points_orthographic   s   r   Ú	extensionc                 C   s<   t | ddgƒ t| jƒt|jƒkr|d }tj| |gddS )a«  Unproject one or more points from the canonical z=1 plane into the camera frame.

    .. math::
        \begin{bmatrix} x \\ y \\ z \end{bmatrix} =
        \begin{bmatrix} u \\ v \\ w \end{bmatrix}

    Args:
        points_in_camera: Tensor representing the points to unproject with shape (..., 2).
        extension: Tensor representing the extension of the points to unproject with shape (..., 1).

    Returns:
        Tensor representing the unprojected points with shape (..., 3).

    Example:
        >>> points = torch.tensor([1., 2.])
        >>> extension = torch.tensor([3.])
        >>> unproject_points_orthographic(points, extension)
        tensor([1., 2., 3.])

    r   Ú2).Néÿÿÿÿ)Údim)r   ÚlenÚshapeÚopsÚconcatenate)r   r   r   r   r   Úunproject_points_orthographic2   s   r   c                 C   s$   t | ddgƒ t | ddd…f ¡S )aÐ  Compute the derivative of the x projection with respect to the x coordinate.

    .. math::
        \frac{\partial u}{\partial x} = 1

    Args:
        points_in_camera: Tensor representing the points to project.

    Returns:
        Tensor representing the derivative of the x projection with respect to the x coordinate.

    Example:
        >>> points = torch.tensor([1., 2., 3.])
        >>> dx_project_points_orthographic(points)
        tensor([1.])

    r   r   .r   é   )r   r   Ú	ones_liker
   r   r   r   Údx_project_points_orthographicO   s   r   )
Ú__doc__Úkornia.coreÚcorer   r   Úkornia.core.checkr   r   r   r   r   r   r   r   Ú<module>   s   