+
    åûj, ã                  ó”  € R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIt^ RIH	u H
t ^ RIHt ^ RIHtHtHtHt ^ RIHt ^ RIHt ^ RIHtHtHtHt . R	NR
NRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNR NR!NR"NR#NR$NR%NR&NR'NR(NR)NR*NR+NR,NR-NR.NR/NR0NR1NR2NR3NR4NR5NR6NR7NtR8 R9 ltR: R; ltR< R= ltR¦R> R? llt R¦R@ RA llt!RB RC lt"RD RE lt#RF RG lt$RH RI lt%RJ RK lt&]! RRLRM7      RN RO l4       t'R§RP RQ llt(]! R4RLRM7      RR RS l4       t)R¨RT RU llt*R©RV RW llt+RX RY lt,RZ R[ lt-R\ R] lt.]! R0RLRM7      R^ R_ l4       t/R¦R` Ra llt0R¦Rb Rc llt1Rd Re lt2]! RRLRM7      Rf Rg l4       t3Rh Ri lt4Rj Rk lt5R¦Rl Rm llt6R¦Rn Ro llt7R¦Rp Rq llt8R¦Rr Rs llt9Rt Ru lt:Rv Rw lt;RªRx Ry llt<R«Rz R{ llt=R¬R| R} llt>R~ R lt?RªR€ R� llt@R‚ Rƒ ltAR„ R… ltBR† R‡ ltCRˆ R‰ ltDRŠ R‹ ltERŒ R� ltFRŽ R� ltGR� R‘ ltHR’ R“ ltIR” R• ltJR– R— ltKR˜ R™ ltLRš R› ltMR§Rœ R� lltNR§Rž RŸ lltOR  R¡ ltPR¢ R£ ltQR¤ R¥ ltRR# )­af  Convert between homogeneous points, normalized coordinates, rotations and poses.

Points and vectors sit in the last dimension, and matrices act on column vectors from the left. 2D pixel coordinates
are ``(x, y)``, with ``x`` the column and pixel centres at integers, while size arguments are ``(height, width)`` or
``(depth, height, width)``. The :math:`[-1, 1]` normalizations are corner-aligned, mapping the first and last pixel
centre of an axis to ``-1`` and ``1``; only :func:`normal_transform_pixel`, :func:`normalize_homography` and
:func:`denormalize_homography` also offer the half-pixel convention of ``align_corners=False``, and their 3D forms
do not (`#4503 <https://github.com/kornia/kornia/issues/4503>`_). Quaternions are ``(w, x, y, z)``, real part first,
in the Hamilton convention. 3D rotations are active and right-handed: a positive angle about ``+z`` turns ``+x``
towards ``+y``. Axis-angle vectors and Euler angles are in radians, while :func:`angle_to_rotation_matrix` takes
degrees and turns ``+x`` towards ``-y``, counter-clockwise as displayed with ``y`` down. The pose functions take
exactly one batch dimension: ``(B, 3, 3)`` rotations with ``(B, 3, 1)`` translations, ``(B, 4, 4)`` matrices or
``(B, 4)`` quaternions.

Which function to use:

- Homogeneous points: :func:`convert_points_to_homogeneous` appends ``w = 1`` to ``(*, N, D)`` points and
  :func:`convert_points_from_homogeneous` divides by it. An affine matrix as a homography:
  :func:`convert_affinematrix_to_homography` for ``(B, 2, 3)``, :func:`convert_affinematrix_to_homography3d` for
  ``(B, 3, 4)``.
- Pixel coordinates to :math:`[-1, 1]` and back: :func:`normalize_pixel_coordinates` and
  :func:`denormalize_pixel_coordinates` for ``(*, 2)`` points, :func:`normalize_pixel_coordinates3d` and
  :func:`denormalize_pixel_coordinates3d` for ``(*, 3)`` points in ``(d, x, y)`` order. The same maps as matrices:
  :func:`normal_transform_pixel` ``(1, 3, 3)`` on ``(x, y, 1)`` and :func:`normal_transform_pixel3d` ``(1, 4, 4)`` on
  ``(x, y, z, 1)``.
- A pixel homography in :math:`[-1, 1]` coordinates and back: :func:`normalize_homography` and
  :func:`denormalize_homography` for ``(B, 3, 3)``, :func:`normalize_homography3d` and
  :func:`denormalize_homography3d` for ``(B, 4, 4)``.
- Pixels to normalized camera coordinates with intrinsics ``K``, and back: :func:`normalize_points_with_intrinsics`,
  :func:`denormalize_points_with_intrinsics`.
- A 3D rotation from one form to another, axis-angle ``(*, 3)``, quaternion ``(*, 4)`` or matrix ``(*, 3, 3)``:
  :func:`axis_angle_to_rotation_matrix`, :func:`axis_angle_to_quaternion`, :func:`quaternion_to_rotation_matrix`,
  :func:`quaternion_to_axis_angle`, :func:`rotation_matrix_to_quaternion`, :func:`rotation_matrix_to_axis_angle`.
  The deprecated names ``angle_axis_to_rotation_matrix``, ``angle_axis_to_quaternion``, ``quaternion_to_angle_axis``
  and ``rotation_matrix_to_angle_axis`` forward to them.
- Quaternion helpers: unit length, :func:`normalize_quaternion`; the exponential and logarithm maps, whose 3-vector
  is half the axis-angle vector, :func:`quaternion_log_to_exp` and :func:`quaternion_exp_to_log`; roll, pitch and
  yaw, with the quaternion as four separate tensors, :func:`quaternion_from_euler` and :func:`euler_from_quaternion`.
- A 2D rotation matrix from an angle in degrees: :func:`angle_to_rotation_matrix`. The cross-product matrix of a
  3-vector: :func:`vector_to_skew_symmetric_matrix`.
- Poses: pack and split ``(B, 4, 4)`` matrices with :func:`Rt_to_matrix4x4` and :func:`matrix4x4_to_Rt`; invert a
  rigid ``(R, t)`` pose with :func:`camtoworld_to_worldtocam_Rt` or :func:`worldtocam_to_camtoworld_Rt`; switch a
  camera-to-world pose between OpenGL and OpenCV camera axes with :func:`camtoworld_graphics_to_vision_4x4`,
  :func:`camtoworld_graphics_to_vision_Rt`, :func:`camtoworld_vision_to_graphics_4x4` or
  :func:`camtoworld_vision_to_graphics_Rt`; convert quaternion poses between ARKit and Colmap with
  :func:`ARKitQTVecs_to_ColmapQTVecs` and :func:`ColmapQTVecs_to_ARKitQTVecs`.
- Angles and polar coordinates: :func:`deg2rad`, :func:`rad2deg`, :func:`cart2pol`, :func:`pol2cart`.
- Rotations and poses as objects that compose and invert: :class:`~kornia.geometry.quaternion.Quaternion`,
  :class:`~kornia.geometry.liegroup.So2`, :class:`~kornia.geometry.liegroup.So3`,
  :class:`~kornia.geometry.liegroup.Se2` and :class:`~kornia.geometry.liegroup.Se3`.
)ÚannotationsN)ÚOptional)Ú
deprecated)ÚKORNIA_CHECKÚKORNIA_CHECK_SHAPEÚ
ShapeErrorÚare_checks_enabled)ÚTypeCheckError)Ú_constant_tensor)Ú_autocast_disabledÚ_inverse_3x3_closed_formÚ_torch_inverse_castÚis_compilingÚARKitQTVecs_to_ColmapQTVecsÚColmapQTVecs_to_ARKitQTVecsÚRt_to_matrix4x4Úangle_axis_to_quaternionÚangle_axis_to_rotation_matrixÚangle_to_rotation_matrixÚaxis_angle_to_quaternionÚaxis_angle_to_rotation_matrixÚ!camtoworld_graphics_to_vision_4x4Ú camtoworld_graphics_to_vision_RtÚcamtoworld_to_worldtocam_RtÚ!camtoworld_vision_to_graphics_4x4Ú camtoworld_vision_to_graphics_RtÚcart2polÚ"convert_affinematrix_to_homographyÚ$convert_affinematrix_to_homography3dÚconvert_points_from_homogeneousÚconvert_points_to_homogeneousÚdeg2radÚdenormalize_homographyÚdenormalize_homography3dÚdenormalize_pixel_coordinatesÚdenormalize_pixel_coordinates3dÚ"denormalize_points_with_intrinsicsÚeuler_from_quaternionÚmatrix4x4_to_RtÚnormal_transform_pixelÚnormal_transform_pixel3dÚnormalize_homographyÚnormalize_homography3dÚnormalize_pixel_coordinatesÚnormalize_pixel_coordinates3dÚ normalize_points_with_intrinsicsÚnormalize_quaternionÚpol2cartÚquaternion_exp_to_logÚquaternion_from_eulerÚquaternion_log_to_expÚquaternion_to_angle_axisÚquaternion_to_axis_angleÚquaternion_to_rotation_matrixÚrad2degÚrotation_matrix_to_angle_axisÚrotation_matrix_to_axis_angleÚrotation_matrix_to_quaternionÚvector_to_skew_symmetric_matrixÚworldtocam_to_camtoworld_Rtc               ó    € V ^8„  d   QhRRRR/# ©é   Útensorútorch.TensorÚreturn© )Úformats   "ÚWC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\geometry\conversions.pyÚ__annotate__rG   ˆ   s   € ÷ &ñ &�Lð & \ñ &ó    c                ó¬   € \        V \        P                  4      '       g   \        R\	        V 4       24      hV R\
        P                  ,          ,          # )aU  Convert angles from radians to degrees, elementwise.

``degrees = rad2deg(radians)`` multiplies a tensor of any shape by ``180 / pi`` and returns the angles in degrees
with the same shape, device and floating dtype; an integer tensor gives the default floating dtype. For the
reverse, use :func:`deg2rad`.

Args:
    tensor: angles in radians, of any shape.

Returns:
    the angles in degrees, with the shape of ``tensor``.

See Also:
    - :func:`deg2rad`: the reverse conversion, degrees to radians.

Example:
    >>> input = torch.tensor(3.1415926535)
    >>> rad2deg(input)
    tensor(180.)

ú&Input type is not a torch.Tensor. Got ç     €f@©Ú
isinstanceÚtorchÚTensorÚ	TypeErrorÚtypeÚmathÚpi©rA   s   &rF   r8   r8   ˆ   s?   € ô, �fœeŸl™l×+Ò+ÜÐ@ÄÀfÃÀÐOÓPÐPà�UœTŸW™W•_Õ%Ð%rH   c               ó    € V ^8„  d   QhRRRR/# r?   rD   )rE   s   "rF   rG   rG   ¤   s   € ÷ &ñ &�Lð & \ñ &rH   c                ó¬   € \        V \        P                  4      '       g   \        R\	        V 4       24      hV \
        P                  R,          ,          # )a$  Convert angles from degrees to radians, elementwise.

``radians = deg2rad(degrees)`` multiplies a tensor of any shape by ``pi / 180`` and returns the angles in radians
with the same shape, device and floating dtype; an integer tensor gives the default floating dtype. The axis-angle,
Euler and polar functions of this module take radians; :func:`angle_to_rotation_matrix` takes degrees. For the
reverse, use :func:`rad2deg`.

Args:
    tensor: angles in degrees, of any shape.

Returns:
    the angles in radians, with the shape of ``tensor``.

See Also:
    - :func:`rad2deg`: the reverse conversion, radians to degrees.
    - :func:`angle_to_rotation_matrix`: the 2D rotation matrix of an angle given in degrees.

Examples:
    >>> input = torch.tensor(180.)
    >>> deg2rad(input)
    tensor(3.1416)

rJ   rK   rL   rT   s   &rF   r!   r!   ¤   s?   € ô0 �fœeŸl™l×+Ò+ÜÐ@ÄÀfÃÀÐOÓPÐPà”T—W‘W˜u•_Õ%Ð%rH   c               ó$   € V ^8„  d   QhRRRRRR/# )r@   ÚrhorB   ÚphirC   ú!tuple[torch.Tensor, torch.Tensor]rD   )rE   s   "rF   rG   rG   Â   s"   € ÷ $ñ $�,ð $ \ð $Ð6Wñ $rH   c                ó@  € \        V \        P                  4      \        V\        P                  4      ,          '       g$   \        R\	        V 4       R\	        V4       24      hV \        P
                  ! V4      ,          pV \        P                  ! V4      ,          pW#3# )aé  Convert polar coordinates (rho, phi), phi in radians, to cartesian coordinates (x, y).

``x, y = pol2cart(rho, phi)`` takes radii and angles in radians and returns two tensors, ``x = rho * cos(phi)`` and
``y = rho * sin(phi)``, in the broadcast shape of ``rho`` and ``phi``. It undoes :func:`cart2pol`:
``pol2cart(*cart2pol(x, y))`` returns ``(x, y)`` to rounding, near the origin included (in ``float32``
``(3e-8, 4e-8)`` comes back as ``(3e-8, 4e-8)``), as long as :func:`cart2pol` can form ``x ** 2 + y ** 2``: it
does so in ``float32`` for ``float16`` and ``bfloat16`` input and in the input dtype otherwise.

Convention:
    - ``rho = 5``, ``phi = atan2(4, 3)`` gives ``(3., 4.)``, and ``rho = 2``, ``phi = pi / 6`` gives
      ``(1.7321, 1.)``
    - ``phi`` follows the angle convention documented on :func:`cart2pol`

Args:
    rho: the radii, of any shape that broadcasts with ``phi``.
    phi: the angles in radians.

Returns:
    - x: the first coordinate, in the broadcast shape of ``rho`` and ``phi``.
    - y: the second coordinate, in the same shape.

See Also:
    - :func:`cart2pol`: the reverse conversion, cartesian to polar.

Example:
    >>> rho = torch.rand(1, 3, 3)
    >>> phi = torch.rand(1, 3, 3)
    >>> x, y = pol2cart(rho, phi)

rJ   ú, )rM   rN   rO   rP   rQ   ÚcosÚsin)rX   rY   ÚxÚys   &&  rF   r1   r1   Â   sr   € ô> �sœEŸL™LÓ)¬J°s¼E¿L¹LÓ,I×IÔIÜÐ@ÄÀcÃÀÈ2ÌdÐSVËiÈ[ÐYÓZÐZàŒe�iŠi˜‹nÕ€AØŒe�iŠi˜‹nÕ€AØˆ4€KrH   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r@   r_   rB   r`   ÚepsÚfloatrC   rZ   rD   )rE   s   "rF   rG   rG   é   s/   € ÷ Mñ M�ð M ð M°Eð MÐGhñ MrH   c           	     ó  € \        V \        P                  4      \        V\        P                  4      ,          '       g$   \        R\	        V 4       R\	        V4       24      h\        P
                  ! W4      pVP                  \        P                  \        P                  39   pV'       d!   V P                  4       VP                  4       3MW3w  rVV^,          V^,          ,           pWr8„  p\        P                  ! \        P                  ! W‡\        P                  ! V4      4      4      p	\        P                  ! W‰\        P                  ! V4      P                  4       4      p
V'       d   V
P                  VP                  4      p
W£3# )uÆ  Convert cartesian coordinates (x, y) to polar coordinates (rho, phi), phi in radians.

``rho, phi = cart2pol(x, y)`` returns two tensors in the broadcast shape of ``x`` and ``y``: the radius
``sqrt(x ** 2 + y ** 2)`` and the angle ``atan2(y, x)`` in radians, in :math:`[-\pi, \pi]`. ``float16`` and
``bfloat16`` radii are computed in ``float32`` and rounded once; ``float32`` and ``float64`` radii are computed
from the unscaled square sum in the input dtype, so they are ``inf`` once it overflows. ``eps`` keeps the gradient
of ``rho`` finite at the origin without changing its value. For the reverse, use :func:`pol2cart`.

Convention:
    - ``(3., 4.)`` gives ``(5., 0.9273)``
    - every ``float16`` radius is correctly rounded, since ``float32``
      holds the square of every ``float16`` value: ``(300., 150.)`` gives
      ``335.5``
    - the square sum overflows from a radius of about ``1.8e19`` in
      ``float32`` and ``bfloat16`` and ``1.3e154`` in ``float64``, and
      ``rho`` is then ``inf``, as for an infinite coordinate. Below a
      radius of about ``1e-19`` and ``1e-154`` it underflows and ``rho``
      loses precision: in ``float32`` ``(1e-20, 0.)`` gives
      ``9.99997e-21`` and ``(1e-25, 0.)`` gives ``0``
    - inside the ``eps`` neighbourhood, ``x ** 2 + y ** 2 <= eps`` (radii
      up to ``1e-4`` at the default ``eps``), the gradient of ``rho`` is
      ``0`` and its value is still the radius: in ``float32``
      ``(1e-5, 0.)`` gives ``1e-5``
    - ``phi`` is ``atan2(y, x)`` in **radians**, so it lies in
      :math:`[-\pi, \pi]`, is ``0`` on the ``+x`` axis and grows toward
      ``+y`` (``x = 0``, ``y = 1`` gives ``phi = 1.5708``). Both endpoints
      are attained on the ``-x`` axis, where the sign of ``y``'s zero
      decides between ``-pi`` and ``+pi``
    - kornia's image ``y`` axis points down, so a growing ``phi`` turns
      **clockwise as displayed**. The relation to the other 2-D
      angle op is the opposite sense: applying
      ``angle_to_rotation_matrix(theta)`` to a nonzero point *decreases*
      that point's ``phi`` by ``theta`` degrees **modulo** :math:`2\pi` â€”
      the result is re-wrapped into :math:`[-\pi, \pi]`, so a point at
      ``phi = -170`` degrees rotated by ``theta = 30`` returns
      ``phi = +160``, not ``-200``. At the origin ``phi`` carries no
      direction and the relation does not apply

Args:
    x: the first coordinates, of any shape that broadcasts with ``y``.
    y: the second coordinates.
    eps: squared-radius threshold: at or below it the gradient of ``rho``
        is zero, which avoids the ``0 / 0`` of the exact gradient at the
        origin. It does not change the value of ``rho``. It is compared
        with the square sum in the dtype that sum is formed in, ``float32``
        for ``float16`` and ``bfloat16`` input.

Returns:
    - rho: the radius, in the broadcast shape of ``x`` and ``y``.
    - phi: the angle in radians, in the same shape.

See Also:
    - :func:`pol2cart`: the reverse conversion, polar to cartesian.
    - :func:`angle_to_rotation_matrix`: the 2D rotation by an angle in degrees, which turns ``phi`` the other way.

Example:
    >>> x = torch.rand(1, 3, 3)
    >>> y = torch.rand(1, 3, 3)
    >>> rho, phi = cart2pol(x, y)

rJ   r\   )rM   rN   rO   rP   rQ   Úatan2ÚdtypeÚfloat16Úbfloat16rc   ÚsqrtÚwhereÚ	ones_likeÚdetachÚto)r_   r`   rb   rY   ÚhalfÚxwÚywÚsquared_radiusÚoutsideÚsafe_rhorX   s   &&&        rF   r   r   é   s  € ô| �qœ%Ÿ,™,Ó'¬*°Q¼¿¹Ó*E×EÔEÜÐ@ÄÀaÃÀ	ÈÌDÐQRËGÈ9ÐUÓVÐVä
�+Š+�aÓ
€Cà�9‰9œŸ™¬¯©Ð7Ñ7€Dç'+ˆa�g‰g‹i˜Ÿ™›Ñ#°!°�F€BØ˜•U˜R �U•]€NØÑ"€Gä�zŠzœ%Ÿ+š+ g¼u¿ºÈ~Ó?^Ó_Ó`€HÜ
�+Š+�g¬¯ª°NÓ)C×)JÑ)JÓ)LÓ
M€CßØ�f‰f�S—Y‘YÓˆØˆ8€OrH   c               ó$   € V ^8„  d   QhRRRRRR/# )r@   ÚpointsrB   rb   rc   rC   rD   )rE   s   "rF   rG   rG   9  s"   € ÷ 7$ñ 7$¨Lð 7$¸uð 7$ÐP\ñ 7$rH   c                ó  € \        V \        P                  4      '       g   \        R\	        V 4       24      h\        V P                  4      ^8  d   \        RV P                   24      hV RRR13,          p\        P                  ! V4      V8„  p\        P                  ! W2\        P                  ! V4      4      p\        P                  ! VRV,          \        P                  ! V4      4      pWPRRR13,          ,          # )aï  Convert homogeneous points ``(*, N, D)`` to Euclidean ``(*, N, D - 1)``.

``points = convert_points_from_homogeneous(points_h)`` takes points ``(*, N, D)`` whose **last** coordinate is the
homogeneous ``w``, divides the others by it and returns ``(*, N, D - 1)``. A point with ``abs(w) <= eps`` comes
back undivided rather than as ``inf``, following OpenCV. For the reverse, use :func:`convert_points_to_homogeneous`;
to apply a homography to Euclidean points in one call, :func:`~kornia.geometry.linalg.transform_points`.

Convention:
    - requires rank :math:`\geq 2`: a bare ``(D,)`` point raises
      ``ValueError``
    - when ``abs(w) > eps`` the remaining components are divided by exactly
      ``w``, with its sign kept (``[[2., 4., -2.]]`` gives ``[[-1., -2.]]``)
    - when ``abs(w) <= eps`` (default ``eps = 1e-8``; the test is a strict
      ``>``) the numerator is instead returned **unchanged**, following
      OpenCV: ``[[2., 4., 0.]]`` gives ``[[2., 4.]]``
    - ``eps`` only picks the branch, it never enters the division, so the
      result carries no bias from it. It is compared against ``w`` in the
      working dtype

Args:
    points: the points to be transformed of shape ``(*, N, D)``.
    eps: threshold on ``abs(w)`` below which the point is returned
        unchanged instead of divided, to avoid division by zero.

Returns:
    the points in Euclidean space ``(*, N, D-1)``.

See Also:
    - :func:`convert_points_to_homogeneous`: the reverse, appending ``w = 1``.
    - :func:`~kornia.geometry.linalg.transform_points`: apply a ``(B, D + 1, D + 1)`` matrix to Euclidean points,
      with this division included.

Examples:
    >>> input = torch.tensor([[0., 0., 1.]])
    >>> convert_points_from_homogeneous(input)
    tensor([[0., 0.]])

rJ   ú(Input must be at least a 2D tensor. Got .Nç      ð?éÿÿÿÿ)rM   rN   rO   rP   rQ   ÚlenÚshapeÚ
ValueErrorÚabsrj   rk   )ru   rb   Úz_vecÚmaskÚ
safe_z_vecÚscales   &&    rF   r   r   9  sË   € ôN �fœeŸl™l×+Ò+ÜÐ@ÄÀfÃÀÐOÓPÐPä
ˆ6�<‰<Ó˜1ÔÜÐCÀFÇLÁLÀ>ÐRÓSÐSð !  b¡c Õ*€Eô
 Ÿš 5Ó)¨CÑ/€DÜ—’˜T¬%¯/ª/¸%Ó*@ÓA€JÜ�KŠK˜˜c JÕ.´·²ÀÓ0FÓG€Eà˜#˜s ˜s˜(Õ#Õ#Ð#rH   c               ó    € V ^8„  d   QhRRRR/# )r@   ru   rB   rC   rD   )rE   s   "rF   rG   rG   s  s   € ÷ !Iñ !I¨,ð !I¸<ñ !IrH   c                ó>  € \        V \        P                  4      '       g   \        R\	        V 4       24      h\        V P                  4      ^8  d   \        RV P                   24      h\        P                  ! V \        P                  ! V R,          4      .RR7      # )aF  Convert Euclidean points ``(*, N, D)`` to homogeneous ``(*, N, D + 1)`` by appending a 1.

``points_h = convert_points_to_homogeneous(points)`` appends the coordinate ``w = 1`` as the **last** component of
each point ``(*, N, D)``, where :func:`convert_points_from_homogeneous` expects it, and returns ``(*, N, D + 1)`` in
the input dtype, integer dtypes included.

Convention:
    - requires rank :math:`\geq 2`: a bare ``(D,)`` point raises
      ``ValueError``

Args:
    points: the points to be transformed with shape ``(*, N, D)``.

Returns:
    the points in homogeneous coordinates ``(*, N, D+1)``.

See Also:
    - :func:`convert_points_from_homogeneous`: the reverse, dividing by ``w`` and dropping it.

Examples:
    >>> input = torch.tensor([[0., 0.]])
    >>> convert_points_to_homogeneous(input)
    tensor([[0., 0., 1.]])

rJ   rw   ©Údim).:Né   Nry   )
rM   rN   rO   rP   rQ   rz   r{   r|   Úcatrk   )ru   s   &rF   r    r    s  sy   € ô4 �fœeŸl™l×+Ò+ÜÐ@ÄÀfÃÀÐOÓPÐPÜ
ˆ6�<‰<Ó˜1ÔÜÐCÀFÇLÁLÀ>ÐRÓSÐSô �9Š9�fœeŸošo¨f°W­oÓ>Ð?ÀRÔHÐHrH   c               ó    € V ^8„  d   QhRRRR/# ©r@   ÚArB   rC   rD   )rE   s   "rF   rG   rG   —  s   € ÷ ñ °ð Àñ rH   c                óò   € V P                  4       '       g0   V P                  4       '       g   \        R V P                   R24      h\        P
                  ! V . RORRR7      pVR;;,          R,          uu&   V# )z8Input A must be a floating point or complex tensor. Got Ú.Úconstantç        )Úvaluerx   )é    r�   r�   r†   ).ry   ry   )Úis_floating_pointÚ
is_complexr|   rf   ÚFÚpad)rŠ   ÚHs   & rF   Ú(_convert_affinematrix_to_homography_implr–   —  s`   € Ø×Ñ× Ò ¨¯©¯ªÜÐSÐTU×T[ÑT[ÐS\Ð\]Ð^Ó_Ð_Ü—e’e˜Aš|¨Z¸sÔC€AØ€k‡N�cÕƒNØ€HrH   c               ó    € V ^8„  d   QhRRRR/# r‰   rD   )rE   s   "rF   rG   rG   Ÿ  s   € ÷ *7ñ *7¨,ð *7¸<ñ *7rH   c                ó  € \        V \        P                  4      '       g   \        R\	        V 4       24      h\        V P                  4      ^8X  d   V P                  RR R8X  g   \        RV P                   24      h\        V 4      # )a)  Extend 2D affine matrices ``(B, 2, 3)`` to ``(B, 3, 3)`` homographies.

``H = convert_affinematrix_to_homography(A)`` copies each ``(B, 2, 3)`` affine matrix verbatim into the top of a
``(B, 3, 3)`` matrix whose last row is ``[0, 0, 1]``, so that it composes with homographies by matrix product and
inverts with :func:`torch.linalg.inv`; the input is not modified. For ``(B, 3, 4)`` 3D affine matrices, use
:func:`convert_affinematrix_to_homography3d`.

Convention:
    - the rank is enforced to be exactly 3, so batching is **mandatory**: an
      unbatched ``(2, 3)`` matrix raises ``ValueError``

Note:
    ``A`` must be a floating point or complex tensor; an integer or
    boolean one raises ``ValueError`` naming its dtype.

Args:
    A: the affine matrix with shape ``(B,2,3)``.

Returns:
     the homography matrix with shape of ``(B,3,3)``.

See Also:
    - :func:`convert_affinematrix_to_homography3d`: the 3D form, ``(B, 3, 4)`` to ``(B, 4, 4)``.
    - :func:`~kornia.geometry.transform.invert_affine_transform`: the inverse of a ``(B, 2, 3)`` matrix, returned
      as ``(B, 2, 3)``.

Examples:
    >>> A = torch.tensor([[[1., 0., 0.],
    ...                    [0., 1., 0.]]])
    >>> convert_affinematrix_to_homography(A)
    tensor([[[1., 0., 0.],
             [0., 1., 0.],
             [0., 0., 1.]]])

rJ   Nz)Input matrix must be a Bx2x3 tensor. Got éþÿÿÿ©r@   é   ©	rM   rN   rO   rP   rQ   rz   r{   r|   r–   ©rŠ   s   &rF   r   r   Ÿ  sp   € ôH �aœŸ™×&Ò&ÜÐ@ÄÀaÃÀ	ÐJÓKÐKä�—‘‹L˜AÔ !§'¡'¨"¨# ,°&Ô"8ÜÐDÀQÇWÁWÀIÐNÓOÐOä3°AÓ6Ð6rH   c               ó    € V ^8„  d   QhRRRR/# r‰   rD   )rE   s   "rF   rG   rG   Ì  s   € ÷ ,7ñ ,7¨Lð ,7¸\ñ ,7rH   c                ó  € \        V \        P                  4      '       g   \        R\	        V 4       24      h\        V P                  4      ^8X  d   V P                  RR R8X  g   \        RV P                   24      h\        V 4      # )a_  Extend 3D affine matrices ``(B, 3, 4)`` to ``(B, 4, 4)`` homographies.

``H = convert_affinematrix_to_homography3d(A)`` copies each ``(B, 3, 4)`` affine matrix verbatim into the top of a
``(B, 4, 4)`` matrix whose last row is ``[0, 0, 0, 1]``; the input is not modified. For a rotation and a
translation given separately, use :func:`Rt_to_matrix4x4`; for ``(B, 2, 3)`` 2D matrices,
:func:`convert_affinematrix_to_homography`.

Convention:
    - the rank is enforced to be exactly 3, as in the 2D function: an
      unbatched ``(3, 4)`` matrix raises ``ValueError``

Note:
    ``A`` must be a floating point or complex tensor; an integer or
    boolean one raises ``ValueError`` naming its dtype.

Args:
    A: the affine matrix with shape ``(B,3,4)``.

Returns:
     the homography matrix with shape of ``(B,4,4)``.

See Also:
    - :func:`convert_affinematrix_to_homography`: the 2D form, ``(B, 2, 3)`` to ``(B, 3, 3)``.
    - :func:`Rt_to_matrix4x4`: the same ``(B, 4, 4)`` matrix from a ``(B, 3, 3)`` rotation and a ``(B, 3, 1)``
      translation.

Examples:
    >>> A = torch.tensor([[[1., 0., 0., 0.],
    ...                    [0., 1., 0., 0.],
    ...                    [0., 0., 1., 0.]]])
    >>> convert_affinematrix_to_homography3d(A)
    tensor([[[1., 0., 0., 0.],
             [0., 1., 0., 0.],
             [0., 0., 1., 0.],
             [0., 0., 0., 1.]]])

rJ   Nz)Input matrix must be a Bx3x4 tensor. Got r™   )r›   é   rœ   r�   s   &rF   r   r   Ì  sp   € ôL �aœŸ™×&Ò&ÜÐ@ÄÀaÃÀ	ÐJÓKÐKä�—‘‹L˜AÔ !§'¡'¨"¨# ,°&Ô"8ÜÐDÀQÇWÁWÀIÐNÓOÐOä3°AÓ6Ð6rH   c               ó    € V ^8„  d   QhRRRR/# ©r@   Ú
axis_anglerB   rC   rD   )rE   s   "rF   rG   rG   û  s   € ÷ U9ñ U9¨lð U9¸|ñ U9rH   c                ó˜  € \        V \        P                  4      '       g   \        R\	        V 4       24      hV P
                  R	,          ^8X  g   \        RV P
                   24      hV P                  pV\        P                  \        P                  39   pV'       d   V P                  4       p R R lpR R lpW ,          P                  R	R7      pVR8„  p\        P                  ! We\        P                  ! V4      4      pV! W4      pV! W4      p	\        P                  ! VR
,          W‰4      p
V'       d   V
P                  V4      # T
# )am  Convert axis-angle vectors ``(*, 3)`` in radians to rotation matrices ``(*, 3, 3)``.

``R = axis_angle_to_rotation_matrix(axis_angle)`` takes rotation vectors ``(*, 3)``, each the unit axis scaled by
the angle in radians, and returns the rotation matrices ``(*, 3, 3)`` by Rodrigues' formula, with any number of
leading dimensions. The matrices act on column vectors from the left and turn by the right-hand rule. For the
quaternion of the same rotation, use :func:`axis_angle_to_quaternion`; for the reverse,
:func:`rotation_matrix_to_axis_angle`.

Convention:
    - any number of leading batch dimensions is accepted: ``(3,)``
      gives ``(3, 3)`` and ``(2, 5, 3)`` gives ``(2, 5, 3, 3)``
    - the input is the rotation axis scaled by the angle, in **radians**:
      ``[[0., 0., pi/2]]`` is a quarter turn about ``+z``,
      while ``[[0., 0., 90.]]`` is 90 *radians* about ``+z`` and returns a
      matrix whose leading entry is ``cos(90) = -0.4481``. The 2-D op
      :func:`~kornia.geometry.conversions.angle_to_rotation_matrix` reads
      **degrees** instead
    - applied on the left to a column vector, ``+theta`` about ``+z`` maps
      ``x_hat`` to ``y_hat`` (right-hand rule): ``[[0., 0., 0.6]]`` sends
      ``(1., 0., 0.)`` to ``(0.8253, 0.5646, 0.)``. The quaternion route
      :func:`~kornia.geometry.conversions.quaternion_to_rotation_matrix`
      turns the same way
    - ``angle_axis_to_rotation_matrix`` is the deprecated alias of this
      function since 0.7.0; it emits a ``DeprecationWarning`` and forwards
      to this function, returning an equal result
    - differentiable at the identity rotation. The ``sqrt`` whose
      derivative is unbounded there never sees its zero radicand, so the
      gradient is the analytic limit of the surrounding map rather than
      ``nan``. The guard is elementwise, and away from the identity it
      moves no forward bit
    - ``float16`` and ``bfloat16`` are computed in ``float32`` and rounded once to the input dtype

Args:
    axis_angle: tensor of 3d vector of axis-angle rotations in radians with shape ``(*, 3)``.

Returns:
    tensor of rotation matrices of shape ``(*, 3, 3)``.

See Also:
    - :func:`rotation_matrix_to_axis_angle`: the reverse conversion, matrix to axis-angle.
    - :func:`axis_angle_to_quaternion`: the ``(w, x, y, z)`` quaternion of the same rotation.
    - :func:`quaternion_to_rotation_matrix`: the same matrix from a quaternion.
    - :func:`angle_to_rotation_matrix`: a 2D ``(*, 2, 2)`` rotation from an angle in degrees.
    - :class:`~kornia.geometry.liegroup.So3`: the same rotation as an object that composes, inverts and maps back
      with ``log``; ``So3.exp(v).matrix()`` is this matrix.

Example:
    >>> input = torch.tensor([[0., 0., 0.]])
    >>> axis_angle_to_rotation_matrix(input)  # doctest: +ELLIPSIS
    tensor([[[1., ...0., 0.],
             [0., 1., ...0.],
             [...0., 0., 1.]]])

    >>> input = torch.tensor([[1.5708, 0., 0.]])
    >>> axis_angle_to_rotation_matrix(input)
    tensor([[[ 1.0000e+00,  0.0000e+00,  0.0000e+00],
             [ 0.0000e+00, -3.6200e-06, -1.0000e+00],
             [ 0.0000e+00,  1.0000e+00, -3.6200e-06]]])

rJ   z(Input size must be a (*, 3) tensor. Got c               ó$   € V ^8„  d   QhRRRRRR/# ©r@   r£   rB   Útheta2rC   rD   )rE   s   "rF   rG   Ú3axis_angle_to_rotation_matrix.<locals>.__annotate__E  s"   € ÷  
ñ  
¨\ð  
À<ð  
ÐT`ñ  
rH   c           	     ór  € \         P                  ! V4      pWP                  R4      ,          pVP                  RR7      w  rEp\         P                  ! V4      p\         P
                  ! V4      pRV,
          p	WE,          p
WF,          pWV,          pWtV,          V	,          ,           pW©,          Wh,          ,
          pWX,          W¹,          ,           pWh,          W©,          ,           pWuV,          V	,          ,           pV) V,          WÉ,          ,           pV) V,          W¹,          ,           pWH,          WÉ,          ,           pWvV,          V	,          ,           p\         P                  ! \         P                  ! WÞV.RR7      \         P                  ! VVV.RR7      \         P                  ! VVV.RR7      .RR7      # )r†   r„   rx   ry   r™   )rN   ri   Ú	unsqueezeÚunbindr]   r^   Ústack)r£   r§   ÚthetaÚwxyzÚwxÚwyÚwzÚ	cos_thetaÚ	sin_thetaÚone_minus_cosÚwxwyÚwxwzÚwywzÚr00Úr01Úr02Úr10Úr11Úr12Úr20Úr21Úr22s   &&                    rF   Ú_compute_rotation_matrixÚ?axis_angle_to_rotation_matrix.<locals>._compute_rotation_matrixE  sY  € Ü—
’
˜6Ó"ˆØŸO™O¨BÓ/Õ/ˆØ—[‘[ R�[Ó(‰
ˆ�ä—I’I˜eÓ$ˆ	Ü—I’I˜eÓ$ˆ	Ø˜i�ˆà�wˆØ�wˆØ�wˆà˜r�' MÕ1Õ1ˆØÕ" R¥^Õ3ˆØ�n˜tÕ3Õ3ˆà�n˜tÕ3Õ3ˆØ˜r�' MÕ1Õ1ˆØˆc�I�o Õ 4Õ4ˆàˆc�I�o Õ 4Õ4ˆØ�n˜tÕ3Õ3ˆØ˜r�' MÕ1Õ1ˆä�{Š{ä—’˜S s˜O°Ô4Ü—’˜S # s˜O°Ô4Ü—’˜S # s˜O°Ô4ðð
 ô
ð 	
rH   c               ó$   € V ^8„  d   QhRRRRRR/# r¦   rD   )rE   s   "rF   rG   r¨   g  s"   € ÷ 8ñ 8°Lð 8È,ð 8Ð[gñ 8rH   c                óþ  € V P                  R4      w  r#p\        P                  ! V4      pWQR,          ,
          pRV,          VR,          ,
          pW",          W3,          WD,          r©pW#,          W$,          W4,          rÜp\        P                  ! WWWš,           ,          ,
          V) V,          W{,          ,           Wc,          W|,          ,           Wd,          W{,          ,           WWWŠ,           ,          ,
          V) V,          W},          ,           V) V,          W|,          ,           Wb,          W},          ,           WWW‰,           ,          ,
          .	RR7      P	                  \        V P                  RR 4      ^^.,           4      # )r†   g      @ç      à?g      8@r„   Nry   )r«   rN   rk   r¬   ÚreshapeÚlistr{   )r£   r§   ÚrxÚryÚrzÚk_oneÚaÚbÚrx2Úry2Úrz2ÚrxryÚrxrzÚryrzs   &&            rF   Ú_compute_rotation_matrix_taylorÚFaxis_angle_to_rotation_matrix.<locals>._compute_rotation_matrix_taylorg  s   € Ø×&Ñ& rÓ*‰
ˆ�Ü—’ Ó#ˆð ˜S•LÕ ˆØ�%�K˜& 4�-Õ'ˆà� ¥¨"­'�#ˆØ�7 B¥G¨R­W�Dˆä�{Š{à˜S�Y�Õ'Ø��R•˜!�(Õ"Ø•˜�Õ!Ø•˜�Õ!Ø˜S�Y�Õ'Ø��R•˜!�(Õ"Ø��R•˜!�(Õ"Ø•˜�Õ!Ø˜S�Y�Õ'ð
ð ô
÷ ‰'”$�z×'Ñ'¨¨Ð,Ó-°°A°Õ6Ó
7ð	8rH   r„   g�íµ ÷Æ°>ry   ).NN)rM   rN   rO   rP   rQ   r{   r|   rf   rg   rh   rc   Úsumrj   rk   rm   )r£   Ú
orig_dtypern   rÁ   rÔ   r§   r   Úsafe_theta2Ú
rot_normalÚ
rot_taylorÚrotations   &          rF   r   r   û  s  € ôz �j¤%§,¡,×/Ò/ÜÐ@ÄÀjÓAQÐ@RÐSÓTÐTà×Ñ˜BÕ 1Ô$ÜÐCÀJ×DTÑDTÐCUÐVÓWÐWð ×!Ñ!€JØœ%Ÿ-™-¬¯©Ð8Ñ8€DßØ×%Ñ%Ó'ˆ
õ 
õD8ð> Õ%×*Ñ*¨rÐ*Ó2€FØ�D‰=€Dô —+’+˜d¬E¯OªO¸FÓ,CÓD€KÙ)¨*ÓB€JÙ0°ÓD€Jä�{Š{˜4 Õ0°*ÓI€Hß&*ˆ8�;‰;�zÓ"Ð8°Ð8rH   z0.7.0)Úreplace_withÚversionc               ó    € V ^8„  d   QhRRRR/# r¢   rD   )rE   s   "rF   rG   rG   ”  s   € ÷ 5ñ 5¨lð 5¸|ñ 5rH   c                ó   € \        V 4      # )z¾Deprecated: use :func:`~kornia.geometry.conversions.axis_angle_to_rotation_matrix`.

Each call emits a ``DeprecationWarning`` (deprecated since 0.7.0) and returns what the new name returns.
)r   ©r£   s   &rF   r   r   “  s   € ô )¨Ó4Ð4rH   c               ó$   € V ^8„  d   QhRRRRRR/# )r@   Úrotation_matrixrB   Úcheck_rotationÚboolrC   rD   )rE   s   "rF   rG   rG   œ  s-   € ÷ NHñ NH°<ð NHÐQUð NHÐbnñ NHrH   c                óð  € \        V \        P                  4      '       g   \        R\	        V 4       24      hV P
                  RR R8X  g   \        RV P
                   24      hV'       d   \        V R4       V P                  \        P                  \        P                  39   p\        V'       d   V P                  4       MT 4      p\        V4      pV'       d   VP                  V P                  4      # T# )aH  Convert rotation matrices ``(*, 3, 3)`` to axis-angle vectors ``(*, 3)`` in radians.

``axis_angle = rotation_matrix_to_axis_angle(R)`` returns, for each rotation matrix ``(*, 3, 3)``, the Rodrigues
vector ``(*, 3)``: the unit axis scaled by the angle in radians, at most ``pi``, the form
:func:`axis_angle_to_rotation_matrix` takes back. It goes through :func:`rotation_matrix_to_quaternion` and
:func:`quaternion_to_axis_angle`. The input is not checked to be a rotation unless ``check_rotation=True``. For the
``(w, x, y, z)`` quaternion instead, use :func:`rotation_matrix_to_quaternion`.

Convention:
    - any number of leading batch dimensions is accepted: ``(3, 3)``
      gives ``(3,)`` and ``(2, 5, 3, 3)`` gives ``(2, 5, 3)``
    - the output is the parametrization
      :func:`~kornia.geometry.conversions.axis_angle_to_rotation_matrix`
      consumes, at every rank: the ``(3,)`` and ``(2, 5, 3)``
      results above can be fed straight back
    - ``rotation_matrix_to_axis_angle(axis_angle_to_rotation_matrix(v))``
      returns ``v`` to roundoff for angles below ``pi``, the low-angle
      Taylor branch (``theta <= 1e-3``) included. A longer ``v`` comes
      back as the equivalent vector of angle at most ``pi``:
      ``[0., 0., 4.]`` returns ``[0., 0., -2.2832]``, a turn by
      ``2 * pi - 4`` about ``-z``
    - by default the input is **not** checked for being a rotation matrix:
      ``zeros(3, 3)`` returns ``[0., 0., 3.1416]`` and ``2 * eye(3)``
      returns ``[0., 0., 0.]``. Pass ``check_rotation=True`` to reject
      such an input instead
    - ``rotation_matrix_to_angle_axis`` is the deprecated alias of this
      function since 0.7.0
    - ``float16`` and ``bfloat16`` are computed in ``float32`` and rounded once to the input dtype, the
      intermediate quaternion included

.. warning::
    By default a reflection (``det = -1``) is returned as a rotation:
    ``diag(-1, 1, 1)`` gives ``[0., 0., 0.]``, the identity. Pass
    ``check_rotation=True`` to raise a ``ValueError`` instead.

Args:
    rotation_matrix: rotation matrix of shape ``(*, 3, 3)``.
    check_rotation: if ``True``, raise ``ValueError`` unless every input
        is a rotation: ``max|R @ R^T - I|`` within 100 eps of the dtype of
        ``rotation_matrix`` (16 eps for float16 and bfloat16) and
        ``det(R) > 0``. Defaults to ``False`` (unchecked).

Returns:
    Rodrigues vector transformation of shape ``(*, 3)``.

See Also:
    - :func:`axis_angle_to_rotation_matrix`: the reverse conversion, axis-angle to matrix.
    - :func:`rotation_matrix_to_quaternion`: the ``(w, x, y, z)`` quaternion of the same matrix.
    - :func:`quaternion_to_axis_angle`: the same vector from a quaternion.

Example:
    >>> input = torch.tensor([[1., 0., 0.],
    ...                       [0., 1., 0.],
    ...                       [0., 0., 1.]])
    >>> rotation_matrix_to_axis_angle(input)
    tensor([0., 0., 0.])

    >>> input = torch.tensor([[1., 0., 0.],
    ...                       [0., 0., -1.],
    ...                       [0., 1., 0.]])
    >>> rotation_matrix_to_axis_angle(input)
    tensor([1.5708, 0.0000, 0.0000])

rJ   Nú+Input size must be a (*, 3, 3) tensor. Got r:   r™   ©r›   r›   )rM   rN   rO   rP   rQ   r{   r|   Ú_check_is_rotationrf   rg   rh   r;   rc   r6   rm   )râ   rã   rn   Ú
quaternionr£   s   &&   rF   r:   r:   œ  sÊ   € ôB �o¤u§|¡|×4Ò4ÜÐ@ÄÀoÓAVÐ@WÐXÓYÐYà× Ñ   Ð%¨Ô/ÜÐFÀ×G\ÑG\ÐF]Ð^Ó_Ð_çÜ˜?Ð,KÔLð × Ñ ¤U§]¡]´E·N±NÐ$CÑC€DÜ<×X\¸_×=RÑ=RÔ=TÐbqÓr€JÜ)¨*Ó5€Jß37ˆ:�=‰=˜×.Ñ.Ó/ÐG¸ZÐGrH   c               ó    € V ^8„  d   QhRRRR/# )r@   râ   rB   rC   rD   )rE   s   "rF   rG   rG   î  s   € ÷ :ñ :°<ð :ÀLñ :rH   c                ó   € \        V 4      # )a7  Deprecated: use :func:`~kornia.geometry.conversions.rotation_matrix_to_axis_angle`.

Each call emits a ``DeprecationWarning`` (deprecated since 0.7.0) and returns what the new name returns with its
default ``check_rotation=False``: this name takes no ``check_rotation`` argument, so its input is never checked.
)r:   )râ   s   &rF   r9   r9   í  s   € ô )¨Ó9Ð9rH   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r@   râ   rB   rb   rc   rã   rä   rC   rD   )rE   s   "rF   rG   rG   ÷  s2   € ÷ F=ñ F=Ø!ðF=Ø(-ðF=ØHLðF=àñF=rH   c                ó   aaaaaaaaaaaaa€ \        V \        P                  4      '       g   \        R\	        V 4       24      hV P
                  RR R8X  g   \        RV P
                   24      hV'       d   \        V R4       V P                  pV\        P                  \        P                  39   pV'       d   V P                  4       p R R loV P                  ! . V P
                  RR O^	N5!  p\        P                  ! V^	RR7      w	  oooooooooSS,           S,           o\        VR4      oR	 V3R
 lloR VVVVVVVVV3	R llpR VVVVVVVVVVV3R llpR VVVVVVVVVVV3R llpR VVVVVVVVVVV3R llp	\        P                  ! SS8„  V! 4       V	! 4       4      p
\        P                  ! SS8„  SS8„  ,          V! 4       V
4      p\        P                  ! SR8„  V! 4       V4      pV'       d   VP!                  V4      # T# )aï  Convert rotation matrices ``(*, 3, 3)`` to quaternions ``(*, 4)`` in ``(w, x, y, z)`` order.

``q = rotation_matrix_to_quaternion(R)`` returns, for each rotation matrix ``(*, 3, 3)``, the unit quaternion
``(*, 4)`` with the real part first, with any number of leading dimensions. Of the two quaternions ``q`` and ``-q``
of a rotation it returns either, not always the one with ``w >= 0``. The input is not checked to be a rotation
unless ``check_rotation=True``. For the reverse, use :func:`quaternion_to_rotation_matrix`; for the axis-angle
vector, :func:`rotation_matrix_to_axis_angle`.

Convention:
    - the ``(w, x, y, z)`` layout, and its silent misreading, are spelled
      out on :func:`~kornia.geometry.conversions.quaternion_to_rotation_matrix`
    - the sign is **not** canonicalised to ``w >= 0``. For
      ``trace(R) > 0`` the returned ``w`` is non-negative, but for
      ``trace(R) <= 0`` it is the dominant of ``x, y, z`` that is forced
      non-negative and ``w`` may be negative: 170 degrees about
      ``(1, 2, -3)/sqrt(14)`` (``trace = -0.9696``) returns
      ``[-0.0872, -0.2662, -0.5325, 0.7987]``
    - by default the input is **not** checked for being a rotation matrix;
      see the degenerate inputs listed on
      :func:`~kornia.geometry.conversions.rotation_matrix_to_axis_angle`.
      Pass ``check_rotation=True`` to reject such an input instead
    - ``float16`` and ``bfloat16`` are computed in ``float32`` and rounded once to the input dtype

Args:
    rotation_matrix: the rotation matrix to convert with shape ``(*, 3, 3)``.
    eps: floor on each square-root radicand. It is never added to the
        radicand: a radicand above ``eps`` is used as is, and one at or
        below it (for example the negative radicand of a discarded branch
        on a slightly non-orthogonal input) gives ``2 * sqrt(eps)`` with a
        zero gradient. For an exact rotation matrix the selected radicand is
        at least ``1``, so ``eps`` does not change the result. The divisions
        are separately guarded against a zero denominator.
    check_rotation: if ``True``, raise ``ValueError`` unless every input
        is a rotation: ``max|R @ R^T - I|`` within 100 eps of the dtype of
        ``rotation_matrix`` (16 eps for float16 and bfloat16) and
        ``det(R) > 0``. Defaults to ``False`` (unchecked).

Return:
    the rotation in quaternion with shape ``(*, 4)``.

See Also:
    - :func:`quaternion_to_rotation_matrix`: the reverse conversion, quaternion to matrix.
    - :func:`rotation_matrix_to_axis_angle`: the axis-angle vector of the same matrix.
    - :func:`axis_angle_to_quaternion`: the quaternion of an axis-angle vector instead.
    - :meth:`~kornia.geometry.quaternion.Quaternion.from_matrix`: the same quaternion as a
      :class:`~kornia.geometry.quaternion.Quaternion` object.

Example:
    >>> input = torch.tensor([[1., 0., 0.],
    ...                       [0., 1., 0.],
    ...                       [0., 0., 1.]])
    >>> rotation_matrix_to_quaternion(input)
    tensor([1., 0., 0., 0.])

rJ   Nræ   r;   c               ó$   € V ^8„  d   QhRRRRRR/# )r@   Ú	numeratorrB   ÚdenominatorrC   rD   )rE   s   "rF   rG   Ú3rotation_matrix_to_quaternion.<locals>.__annotate__B  s"   € ÷ =ñ = lð =Àð =ÐR^ñ =rH   c                ó’   € \         P                  ! V P                  4      P                  pV \         P                  ! WR 7      ,          # )©Úmin)rN   Úfinforf   ÚtinyÚclamp)rï   rð   rb   s   && rF   Úsafe_zero_divisionÚ9rotation_matrix_to_quaternion.<locals>.safe_zero_divisionB  s.   € Ü—[’[ §¡Ó1×6Ñ6ˆØœ5Ÿ;š; {Ô<Õ<Ð<rH   )Úchunksr…   rŽ   c               ó    € V ^8„  d   QhRRRR/# )r@   ÚrrB   rC   rD   )rE   s   "rF   rG   rñ   O  s   € ÷ 3ñ 3˜ð 3¨,ñ 3rH   c           
     óf  <€ V S8„  p\         P                  ! W\         P                  ! V 4      4      p\         P                  ! V\         P                  ! V4      R ,          \         P                  ! V R SR,          ,          4      4      p\         P                  ! \         P
                  ! V 4      W4      # )ç       @rÅ   )rN   rj   rk   ri   Ú	full_likeÚisnan)rü   r   Úsafe_rÚoutÚradicand_floors   &   €rF   Ú_safe_sqrt_sqÚ4rotation_matrix_to_quaternion.<locals>._safe_sqrt_sqO  sx   ø€ ð
 �>Ñ!ˆÜ—’˜T¤e§o¢o°aÓ&8Ó9ˆÜ�kŠk˜$¤§
¢
¨6Ó 2°SÕ 8¼%¿/º/È!ÈSÐSaÐcfÕSfÕMfÓ:gÓhˆÜ�{Š{œ5Ÿ;š; q›>¨1Ó2Ð2rH   c               ó   € V ^8„  d   QhRR/# ©r@   rC   rB   rD   )rE   s   "rF   rG   rñ   Y  s   € ÷ 3ñ 3 ñ 3rH   c                 óÈ   <	€ S! SR ,           4      p RV ,          pS! SS	,
          V 4      pS! SS
,
          V 4      pS! SS,
          V 4      p\         P                  ! WW43RR7      # ©rx   g      Ð?r„   ry   ©rN   r‡   )ÚsqÚqwÚqxÚqyÚqzr  Úm01Úm02Úm10Úm12Úm20Úm21rø   Útraces        €€€€€€€€€rF   Útrace_positive_condÚ:rotation_matrix_to_quaternion.<locals>.trace_positive_condY  s`   ø€ Ù˜5 3�;Ó'ˆØ�B�YˆÙ  c¥	¨2Ó.ˆÙ  c¥	¨2Ó.ˆÙ  c¥	¨2Ó.ˆÜ�yŠy˜" "Ð)¨rÔ2Ð2rH   c               ó   € V ^8„  d   QhRR/# r  rD   )rE   s   "rF   rG   rñ   a  ó   € ÷ 3ñ 3�Lñ 3rH   c                 óä   <€ S! R S,           S
,
          S,
          4      p S! SS,
          V 4      pRV ,          pS! SS	,           V 4      pS! SS,           V 4      p\         P                  ! WW43RR7      # r	  r
  ©r  r  r  r  r  r  Úm00r  r  r  Úm11r  r  r  Úm22rø   s        €€€€€€€€€€€rF   Úcond_1Ú-rotation_matrix_to_quaternion.<locals>.cond_1a  si   ø€ Ù˜3 �9 s�?¨SÕ0Ó1ˆÙ  c¥	¨2Ó.ˆØ�B�YˆÙ  c¥	¨2Ó.ˆÙ  c¥	¨2Ó.ˆÜ�yŠy˜" "Ð)¨rÔ2Ð2rH   c               ó   € V ^8„  d   QhRR/# r  rD   )rE   s   "rF   rG   rñ   i  r  rH   c                 óä   <€ S! R S
,           S,
          S,
          4      p S! SS,
          V 4      pS! SS	,           V 4      pRV ,          pS! SS,           V 4      p\         P                  ! WW43RR7      # r	  r
  r  s        €€€€€€€€€€€rF   Úcond_2Ú-rotation_matrix_to_quaternion.<locals>.cond_2i  si   ø€ Ù˜3 �9 s�?¨SÕ0Ó1ˆÙ  c¥	¨2Ó.ˆÙ  c¥	¨2Ó.ˆØ�B�YˆÙ  c¥	¨2Ó.ˆÜ�yŠy˜" "Ð)¨rÔ2Ð2rH   c               ó   € V ^8„  d   QhRR/# r  rD   )rE   s   "rF   rG   rñ   q  r  rH   c                 óä   <€ S! R S,           S,
          S
,
          4      p S! S	S,
          V 4      pS! SS,           V 4      pS! SS,           V 4      pRV ,          p\         P                  ! WW43RR7      # r	  r
  r  s        €€€€€€€€€€€rF   Úcond_3Ú-rotation_matrix_to_quaternion.<locals>.cond_3q  si   ø€ Ù˜3 �9 s�?¨SÕ0Ó1ˆÙ  c¥	¨2Ó.ˆÙ  c¥	¨2Ó.ˆÙ  c¥	¨2Ó.ˆØ�B�YˆÜ�yŠy˜" "Ð)¨rÔ2Ð2rH   r™   rç   ry   )rM   rN   rO   rP   rQ   r{   r|   rè   rf   rg   rh   rc   rÆ   ÚchunkÚmaxrj   rm   )râ   rb   rã   r×   rn   Úrotation_matrix_vecr  r   r$  r(  Úwhere_2Úwhere_1ré   r  r  r  r  r  r  r  r  r  r  r  rø   r  s   &&&          @@@@@@@@@@@@@rF   r;   r;   ÷  sÈ  ÿü€ ôt �o¤u§|¡|×4Ò4ÜÐ@ÄÀoÓAVÐ@WÐXÓYÐYà× Ñ   Ð%¨Ô/ÜÐFÀ×G\ÑG\ÐF]Ð^Ó_Ð_çÜ˜?Ð,KÔLð
 !×&Ñ&€JØœ%Ÿ-™-¬¯©Ð8Ñ8€DßØ)×/Ñ/Ó1ˆõ=ð )8×(?Ò(?Ð(_À×AVÑAVÐWZÐXZÐA[Ð(_Ð]^Ó(_Ðä27·+²+Ð>QÐZ[ÐacÔ2dÑ/€Cˆˆc�3˜˜S # s¨Cà �) c�/€Eô    S›M€N÷3ð 3÷3÷ 3ð 3÷3÷ 3ò 3÷3÷ 3ò 3÷3÷ 3ò 3ô �kŠk˜# ™)¡V£X©v«xÓ8€GÜ�kŠk˜3 ™9¨¨s©Õ3±V³X¸wÓG€Gä$Ÿ{š{¨5°3©;Ñ8KÓ8MÈwÓW€Jß(,ˆ:�=‰=˜Ó$Ð<°*Ð<rH   c               ó$   € V ^8„  d   QhRRRRRR/# ©r@   ré   rB   rb   rc   rC   rD   )rE   s   "rF   rG   rG   €  s!   € ÷ 20ñ 20 \ð 20¸ð 20ÈLñ 20rH   c                óæ   € \        V \        P                  4      '       g   \        R\	        V 4       24      hV P
                  R,          ^8X  g   \        RV P
                   24      h\        W4      # )ut  Scale quaternions ``(*, 4)`` to unit length, keeping their sign and component order.

``q_unit = normalize_quaternion(q)`` divides each quaternion ``(*, 4)`` by its L2 norm and returns ``(*, 4)``. It
reads no component order, so the quaternion can be in ``(x, y, z, w)`` or ``(w, x, y, z)`` format. The norm is
floored at ``eps``, so with a positive ``eps`` the zero quaternion returns zeros rather than ``nan``. The
conversions of this module that take a quaternion accept a non-unit one, so they need no call here first.

Convention:
    - it is an L2 normalisation of the **last** axis and nothing else, which
      is why the ``(x, y, z, w)`` or ``(w, x, y, z)`` phrasing above is
      accurate here: ``[4., 3., 2., 1.]`` normalises to the reversal of what
      ``[1., 2., 3., 4.]`` gives
    - the sign is preserved â€” ``normalize_quaternion(-q)`` is exactly
      ``-normalize_quaternion(q)``, there is no ``w >= 0``
      canonicalisation
    - the divisor is the norm floored at ``eps``, so a quaternion with
      ``0 < ||q|| < eps`` returns ``q / eps``, which is **not** a unit
      quaternion, and no error is raised: with the default ``eps = 1e-12``,
      ``[1e-13, 0., 0., 0.]`` returns ``[0.1, 0., 0., 0.]``. No realistic
      rotation has such a norm; the case that occurs in practice, the zero
      quaternion, returns ``zeros(4)``. With ``eps=0.0`` the zero quaternion
      returns ``nan``. In ``float16`` a positive ``eps`` is floored at the
      smallest subnormal.

Args:
    quaternion: a tensor containing a quaternion to be normalized.
      The tensor can be of shape ``(*, 4)``.
    eps: floor on the norm used as the divisor; see the Convention above.

Return:
    the normalized quaternion of shape ``(*, 4)``.

See Also:
    - :func:`quaternion_to_rotation_matrix`: normalizes with this function before building the matrix.
    - :meth:`~kornia.geometry.quaternion.Quaternion.normalize`: the same normalization of a
      :class:`~kornia.geometry.quaternion.Quaternion` object.

Example:
    >>> quaternion = torch.tensor((1., 0., 1., 0.))
    >>> normalize_quaternion(quaternion)
    tensor([0.7071, 0.0000, 0.7071, 0.0000])

rJ   ú,Input must be a tensor of shape (*, 4). Got ry   )rM   rN   rO   rP   rQ   r{   r|   Ú_normalize_last_dim)ré   rb   s   &&rF   r0   r0   €  sg   € ôX �j¤%§,¡,×/Ò/ÜÐ@ÄÀjÓAQÐ@RÐSÓTÐTà×Ñ˜BÕ 1Ô$ÜÐGÈ
×HXÑHXÐGYÐZÓ[Ð[ä˜zÓ/Ð/rH   c               ó$   € V ^8„  d   QhRRRRRR/# )r@   r_   rB   rb   rc   rC   rD   )rE   s   "rF   rG   rG   µ  s&   € ÷ Dñ D˜<ð D¨eð D¸ñ DrH   c           
     ó  € V P                   \        P                  8X  d   VR8”  d   \        VR4      MTp\        P                  P                  V ^RRR7      pVR8g  p\        P                  ! WC\        P                  ! V4      4      p\        P                  ! WR8  \        P                  ! WR4      V4      pW,          pVR8X  d6   \        P                  ! WG\        P                  ! V \        R4      4      4      # V P                   \        P                  8X  d:   VR,          R8  d,   \        P                  ! WG\        P                  ! V 4      4      # \        P                  ! WGV \        P                  ! W4      ,          4      # )	aØ  Divide ``x`` by the L2 norm of its last axis, floored at ``eps``.

The arithmetic of :func:`normalize_quaternion`, shared with :meth:`kornia.geometry.vector.Vector3.normalized`,
:meth:`kornia.geometry.vector.Vector2.normalized` and :meth:`kornia.geometry.line.ParametrizedLine.through`.
Its values match ``torch.nn.functional.normalize(x, p=2, dim=-1, eps=eps)`` wherever the norm is nonzero. Their
default ``eps=1e-12`` rounds to ``0`` in float16, where ``normalize`` turns a zero vector into ``0 / 0 = NaN``
(#4021, #5062); here a row whose norm is exactly zero takes a separate arm (``x / eps``, or a constant zero where
float16 cannot hold ``1 / eps``), so with a positive ``eps`` the zero vector stays zero in every dtype.
rŽ   g      p>T)Úordr…   ÚkeepdimÚnang     üï@rx   ry   )rf   rN   rg   r+  ÚlinalgÚvector_normrj   rk   rÿ   rc   Ú
zeros_like)r_   rb   Úsafe_epsÚnormr   Ú	safe_normÚdenomr  s   &&      rF   r3  r3  µ  s  € ð :;¿¹ÄEÇMÁMÔ9QÐVYÐ\_ÔV_”c˜#Ð4Ô5Ðeh€HÜ�<‰<×#Ñ# A¨1°"¸dÐ#ÓC€Dð �3‰;€DÜ—’˜D¬¯ª¸Ó(=Ó>€IÜ�KŠK˜	Ñ,¬e¯oªo¸iÓ.RÐT]Ó^€EØ
�)€CØ
ˆc„zÜ�{Š{˜4¤e§o¢o°a¼¸u»Ó&FÓGÐGØ‡w�w”%—-‘-Ô H¨wÕ$6¸Ô$<ä�{Š{˜4¤e×&6Ò&6°qÓ&9Ó:Ð:ä�;Š;�t !¤e§o¢o°aÓ&BÕ"BÓCÐCrH   c               ó    € V ^8„  d   QhRRRR/# ©r@   ré   rB   rC   rD   )rE   s   "rF   rG   rG   Ö  s   € ÷ q5ñ q5¨lð q5¸|ñ q5rH   c                ó   € \        V \        P                  4      '       g   \        R\	        V 4       24      hV P
                  R,          ^8X  g   \        RV P
                   24      hV P                  pV\        P                  \        P                  39   pV'       d   V P                  4       p \        V 4      pVR,          pVR	,          pVR
,          pVR,          pRV,          pRV,          p	RV,          p
W„,          pW”,          pW¤,          pW…,          pW•,          pW¥,          pW–,          pW¦,          pW§,          pRp\        P                  ! VVV,           ,
          Wý,
          VV,           Wý,           VVV,           ,
          VV,
          VV,
          VV,           VVV,           ,
          3	RR7      p. \        V P
                  RR 4      O^N^NpVP                  V4      pV'       d   VP                  V4      # T# )uã  Convert ``(w, x, y, z)`` quaternions ``(*, 4)`` to rotation matrices ``(*, 3, 3)``.

``R = quaternion_to_rotation_matrix(q)`` takes quaternions ``(*, 4)`` with the **real part first**, in the Hamilton
convention, and returns the rotation matrices ``(*, 3, 3)``, which act on column vectors from the left. The input
is normalized first, so it need not be unit, and ``q`` and ``-q`` give the same matrix. A quaternion in
``(x, y, z, w)`` order is not detected and returns a valid-looking wrong rotation. For the reverse, use
:func:`rotation_matrix_to_quaternion`; from an axis-angle vector, :func:`axis_angle_to_rotation_matrix`.

Convention:
    - ``[1., 0., 0., 0.]`` gives the identity and ``[0., 0., 0., 1.]`` gives
      ``[[-1., 0., 0.], [0., -1., 0.], [0., 0., 1.]]``, a half turn about
      ``+z`` â€” so a caller passing ``(x, y, z, w)`` gets a valid-looking
      rotation matrix and no error
    - ``q`` and ``-q`` are the same rotation (double cover) and return
      bit-identical matrices
    - the input is normalised internally with
      :func:`~kornia.geometry.conversions.normalize_quaternion`, so
      ``quaternion_to_rotation_matrix(2 * q)`` is bitwise
      ``quaternion_to_rotation_matrix(q)``; other rescalings move the
      matrix by the working dtype's rounding, as long as the norm of the
      rescaled quaternion neither overflows nor falls below the
      normalisation floor ``eps = 1e-12`` (see that function's Convention)
    - :func:`~kornia.geometry.conversions.quaternion_to_axis_angle`,
      :func:`~kornia.geometry.conversions.quaternion_exp_to_log`, and
      :func:`~kornia.geometry.conversions.euler_from_quaternion` are
      scale-safe too
    - applied on the left to a column vector, ``+theta`` about ``+z`` maps
      ``x_hat`` to ``y_hat`` (right-hand rule)
    - the output dtype follows the input at every shape
    - the zero quaternion, which is not a rotation, returns the identity
      matrix rather than raising: it stays zero through the normalisation,
      and the matrix formula gives the identity for it
    - ``float16`` and ``bfloat16`` are computed in ``float32`` and rounded once to the input dtype

Args:
    quaternion: a tensor containing a quaternion to be converted.
      The tensor can be of shape ``(*, 4)``.

Return:
    the rotation matrix of shape ``(*, 3, 3)``.

See Also:
    - :func:`rotation_matrix_to_quaternion`: the reverse conversion, matrix to quaternion.
    - :func:`quaternion_to_axis_angle`: the axis-angle vector of the same quaternion.
    - :func:`axis_angle_to_rotation_matrix`: the same matrix from an axis-angle vector.
    - :func:`normalize_quaternion`: the normalization applied to the input first.
    - :meth:`~kornia.geometry.quaternion.Quaternion.matrix`: the same matrix of a
      :class:`~kornia.geometry.quaternion.Quaternion` object.

Example:
    >>> quaternion = torch.tensor((0., 0., 0., 1.))
    >>> quaternion_to_rotation_matrix(quaternion)
    tensor([[-1.,  0.,  0.],
            [ 0., -1.,  0.],
            [ 0.,  0.,  1.]])

rJ   r2  rþ   rx   r„   Nry   ©.r�   ©.r†   ©.r@   ©.r›   )rM   rN   rO   rP   rQ   r{   r|   rf   rg   rh   rc   r0   r¬   rÇ   rÆ   rm   )ré   r×   rn   Úquaternion_normÚwr_   r`   ÚzÚtxÚtyÚtzÚtwxÚtwyÚtwzÚtxxÚtxyÚtxzÚtyyÚtyzÚtzzÚoneÚmatrix_flatÚoutput_shapeÚmatrixs   &                       rF   r7   r7   Ö  sØ  € ôt �j¤%§,¡,×/Ò/ÜÐ@ÄÀjÓAQÐ@RÐSÓTÐTà×Ñ˜BÕ 1Ô$ÜÐGÈ
×HXÑHXÐGYÐZÓ[Ð[ð ×!Ñ!€JØœ%Ÿ-™-¬¯©Ð8Ñ8€DßØ×%Ñ%Ó'ˆ
ô %9¸Ó$D€Oð 	˜Õ€AØ˜Õ€AØ˜Õ€AØ˜Õ€Að ˜Q•w€BØ˜Q•w€BØ˜Q•w€BØ�€CØ�€CØ�€CØ�€CØ�€CØ�€CØ�€CØ�€CØ�€CØ€Cä %§¢à�3˜•9ÕØ�IØ�#�IØ�IØ�3˜•9ÕØ�#�IØ�#�IØ�#�IØ�3˜•9Õð
	
ð ô!€Kð  8”T˜*×*Ñ*¨3¨BÐ/Ó0Ð7°!Ð7°QÐ7€LØ× Ñ  Ó.€Fß$(ˆ6�9‰9�ZÓ Ð4¨fÐ4rH   c               ó    € V ^8„  d   QhRRRR/# rA  rD   )rE   s   "rF   rG   rG   J  s   € ÷ H=ñ H=¨ð H=¸,ñ H=rH   c           	     óH  € \        V \        P                  4      '       g   \        R\	        V 4       24      hV P
                  R,          ^8X  g   \        RV P
                   24      hV P                  pV\        P                  \        P                  39   pV'       d   V P                  4       p V R,          pV R,          pV R,          pV R	,          pWD,          WU,          ,           Wf,          ,           pVR8„  p\        P                  ! W‡\        P                  ! V4      4      p	\        P                  ! V\        P                  ! V	4      \        P                  ! V4      4      p
\        P                  ! Wƒ\        P                  ! V4      4      pR\        P                  ! VR8  \        P                  ! V
) V) 4      \        P                  ! W«4      4      ,          pR\        P                  ! VR8  \        P                  ! V
) V) 4      \        P                  ! W£4      4      ,          pWÍP!                  4       VP!                  4       ,
          ,           pV\        P                  ! WŠ\        P                  ! V
4      4      ,          pV( VR8g  ,          p\        P                  ! VV\        P                  ! V4      4      p\        P                  ! VRVP!                  4       ,          \        P                  ! V4      4      p\        P                  ! W�V4      p\        P                  ! V 4      R
,          pVR;;,          VV,          ,          uu&   VR;;,          VV,          ,          uu&   VR;;,          VV,          ,          uu&   V'       d   VP#                  V4      # T# )u-  Convert ``(w, x, y, z)`` quaternions ``(*, 4)`` to axis-angle vectors ``(*, 3)`` in radians.

``axis_angle = quaternion_to_axis_angle(q)`` returns, for each quaternion ``(*, 4)`` with the real part first, the
rotation vector ``(*, 3)``: the unit axis scaled by the angle in radians, at most ``pi``. The input need not be
unit, and ``q`` and ``-q`` give the same vector unless ``w = 0``. For the reverse, use
:func:`axis_angle_to_quaternion`; for the logarithm map, which is half this vector for ``w >= 0`` and tells ``q``
from ``-q``, :func:`quaternion_exp_to_log`.

Adapted from ceres C++ library: ceres-solver/include/ceres/rotation.h

Convention:
    - the ``(w, x, y, z)`` layout is spelled out on
      :func:`~kornia.geometry.conversions.quaternion_to_rotation_matrix`
    - for ``w != 0`` the double cover is collapsed: ``q`` and ``-q`` return
      the same vector, the representative with ``|theta| <= pi``
    - at exactly ``w = 0`` â€” a half turn, and ``0.`` is exactly
      representable â€” the collapse does not happen and the two return exact
      negations: ``[0., 1., 0., 0.]`` gives ``[pi, 0., 0.]`` while
      ``[-0., -1., 0., 0.]`` gives ``[-pi, 0., 0.]``, the same rotation
      written the other way round
    - the input need not be unit: scaling ``q`` by a power of two returns a
      bit-identical vector, and other scales move it by the working
      dtype's rounding, as long as the squares of the components neither
      overflow nor underflow
    - ``quaternion_to_angle_axis`` is the deprecated alias of this function
      since 0.7.0
    - differentiable at the identity quaternion. The ``sqrt`` whose
      derivative is unbounded there never sees its zero radicand, so the
      gradient is the analytic limit of the surrounding map rather than
      ``nan``. The guard is elementwise, and away from the identity it
      moves no forward bit
    - ``float16`` and ``bfloat16`` are computed in ``float32`` and rounded once to the input dtype

Args:
    quaternion: tensor with quaternions.

Return:
    tensor with axis angle of rotation.

Shape:
    - Input: ``(*, 4)`` where `*` means, any number of dimensions
    - Output: ``(*, 3)``

See Also:
    - :func:`axis_angle_to_quaternion`: the reverse conversion, axis-angle to quaternion.
    - :func:`quaternion_to_rotation_matrix`: the rotation matrix of the same quaternion.
    - :func:`quaternion_exp_to_log`: the logarithm map, half this vector for ``w >= 0``; it tells ``q`` from
      ``-q``.
    - :func:`rotation_matrix_to_axis_angle`: the same vector from a rotation matrix.
    - :meth:`~kornia.geometry.quaternion.Quaternion.to_axis_angle`: the same vector of a
      :class:`~kornia.geometry.quaternion.Quaternion` object.

Example:
    >>> quaternion = torch.tensor((1., 0., 0., 0.))
    >>> quaternion_to_axis_angle(quaternion)
    tensor([0., 0., 0.])

rJ   z.Input must be a tensor of shape Nx4 or 4. Got rŽ   rþ   ry   rC  rD  rE  rF  ).ºNr›   N)rM   rN   rO   rP   rQ   r{   r|   rf   rg   rh   rc   rj   rk   ri   r;  re   rl   rm   )ré   r×   rn   r²   Úq1Úq2Úq3Úsin_squared_thetaÚposÚsafe_sin_squared_thetar³   Úsafe_cos_for_atan2Útwo_theta_shieldedÚtwo_theta_valueÚ	two_thetaÚk_posÚ
neg_branchÚsafe_cos_thetaÚk_negÚkr£   s   &                    rF   r6   r6   J  sÈ  € ôv �j¤%§,¡,×/Ò/ÜÐ@ÄÀjÓAQÐ@RÐSÓTÐTà×Ñ˜BÕ 1Ô$ÜÐIÈ*×JZÑJZÐI[Ð\Ó]Ð]ð ×!Ñ!€JØœ%Ÿ-™-¬¯©Ð8Ñ8€DßØ×%Ñ%Ó'ˆ
ð ˜6Õ"€IØ	�FÕ	€BØ	�FÕ	€BØ	�FÕ	€Bà&(¥g°µÕ&7¸"½'Õ&AÐð *¨CÑ/€CÜ+0¯;ª;°sÌuÏÊÐ_pÓOqÓ+rÐÜ#Ÿkšk¨#¬u¯zªzÐ:PÓ/QÔSX×ScÒScÐduÓSvÓw€Iô (-§{¢{°3Ä5Ç?Â?ÐS\ÓC]Ó'^ÐØ'*¬U¯[ª[Ø�C‰œŸš i ZÐ2DÐ1DÓEÄuÇ{Â{ÐS\ÓGqó.õ (Ðð %(¬%¯+ª+Ø�C‰œŸš i Z°)°Ó<¼e¿kºkÈ)Ó>_ó+õ %€Oð 1×4JÑ4JÓ4LÐOa×OhÑOhÓOjÕ4jÕk€Ià#¤e§k¢k°#Ä%Ç/Â/ÐR[ÓB\Ó&]Õ]€Eð* !$˜t y°CÑ'7Õ8€JÜ#(§;¢;¨z¸9ÄeÇoÂoÐV_ÓF`Ó#a€NÜŸ+š+ j°#¸×8MÑ8MÓ8OÕ2OÔQV×QaÒQaÐbkÓQlÓm€EÜ—k’k #¨eÓ4€Aä$×/Ò/°
Ó;¸GÕD€JØˆv×˜"˜q�&Õ ÓØˆv×˜"˜q�&Õ ÓØˆv×˜"˜q�&Õ Óß(,ˆ:�=‰=˜Ó$Ð<°*Ð<rH   c               ó    € V ^8„  d   QhRRRR/# rA  rD   )rE   s   "rF   rG   rG   Ö  ó   € ÷ 0ñ 0¨ð 0¸,ñ 0rH   c                ó   € \        V 4      # )z¹Deprecated: use :func:`~kornia.geometry.conversions.quaternion_to_axis_angle`.

Each call emits a ``DeprecationWarning`` (deprecated since 0.7.0) and returns what the new name returns.
)r6   )ré   s   &rF   r5   r5   Õ  ó   € ô $ JÓ/Ð/rH   c               ó$   € V ^8„  d   QhRRRRRR/# r0  rD   )rE   s   "rF   rG   rG   Þ  s+   € ÷ KTñ KT lð KT¸ð KTÈLñ KTrH   c                ó$  € \        V \        P                  4      '       g   \        R\	        V 4       24      hV P
                  R,          ^8X  g   \        RV P
                   24      hV P                  pV\        P                  \        P                  39   d   \        P                  MTpV P                  V4      pVP                  4       P                  RRR7      P                  pV\        P                  ! WEP!                  VR7      ,          ^RRR7      ,          pVP!                  VR7      pV\        P"                  ! V4      ,          V,          p\        P$                  ! V4      p\        P&                  ! W‡3RR7      P                  V4      # )	u�	  Map log 3-vectors ``(*, 3)`` to ``(w, x, y, z)`` quaternions ``(*, 4)``, the exponential map.

``q = quaternion_log_to_exp(v)`` takes 3-vectors ``(*, 3)``, the logarithms of unit quaternions, and returns the
quaternions ``(cos(||v||), sin(||v||) v / ||v||)`` of shape ``(*, 4)``, real part first. Despite its name, the
argument ``quaternion`` is the 3-vector, which is **half** the axis-angle vector of the rotation; for the
quaternion of an axis-angle vector, use :func:`axis_angle_to_quaternion`. For the reverse, use
:func:`quaternion_exp_to_log`.

Convention:
    - the ``(w, x, y, z)`` layout is spelled out on
      :func:`~kornia.geometry.conversions.quaternion_to_rotation_matrix`
    - the map is ``w = cos(||v||)`` with vector part
      ``sin(||v||) * v / ||v||``, and every finite ``v`` returns a unit
      quaternion up to the working dtype's rounding: ``||v||`` is computed
      as ``s * ||v / s||`` with ``s = max |v_i|``, so it cannot overflow,
      and ``float16``/``bfloat16`` are computed in ``float32``, so the zero
      vector returns ``[1., 0., 0., 0.]`` at every dtype
    - ``pi/2 < ||v|| < 3 * pi/2`` lands in the ``w < 0`` half of the double
      cover â€” at ``||v|| = 2`` the real part is ``-0.4161468365471424``.
      ``w`` is ``cos(||v||)``, so the sign turns over again beyond that
      interval rather than staying negative
    - ``v`` is therefore **half** the axis-angle vector: the result agrees
      with ``axis_angle_to_quaternion(2 * v)`` to the rounding of the
      working dtype, but **not** bit-for-bit: ``[0.15, 0.2, 0.25]`` already
      disagrees at ``bfloat16``, and in ``float64`` most random vectors do
      too
    - for a **unit** ``q``, ``quaternion_log_to_exp(quaternion_exp_to_log(q))``
      returns ``q`` up to rounding, except that the pure-real
      ``[-1., 0., 0., 0.]`` comes back as ``[1., 0., 0., 0.]`` â€” the other
      half of the same rotation

Args:
    quaternion: the log quaternion, a tensor of shape ``(*, 3)``.
    eps: a small number for clamping.

Return:
    the quaternion exponential map of shape ``(*, 4)``.

See Also:
    - :func:`quaternion_exp_to_log`: the reverse, the logarithm map.
    - :func:`axis_angle_to_quaternion`: the same quaternion from the full axis-angle vector ``2 * v``.

Example:
    >>> quaternion = torch.tensor((0., 0., 0.))
    >>> quaternion_log_to_exp(quaternion, eps=torch.finfo(quaternion.dtype).eps)
    tensor([1., 0., 0., 0.])

rJ   z,Input must be a tensor of shape (*, 3). Got T)r…   r7  ró   ©Úpr…   r7  r„   ry   )rM   rN   rO   rP   rQ   r{   r|   rf   rg   rh   Úfloat32rm   r}   r+  Úvaluesr=  r÷   r^   r]   r‡   )	ré   rb   r×   Ú
work_dtypeÚworkr�   Únorm_qÚquaternion_vectorÚquaternion_scalars	   &&       rF   r4   r4   Þ  s:  € ôb �j¤%§,¡,×/Ò/ÜÐ@ÄÀjÓAQÐ@RÐSÓTÐTà×Ñ˜BÕ 1Ô$ÜÐGÈ
×HXÑHXÐGYÐZÓ[Ð[ð ×!Ñ!€JØ",´·±ÄÇÁÐ0OÔ"O”—’ÐU_€JØ�=‰=˜Ó$€DàŸ(™(›*Ÿ.™.¨R¸˜.Ó>×EÑE€EØ ¤5§:¢:¨d·[±[ÀS°[Ó5IÕ.IÈQÐTVÐ`dÔ#eÕe€FØ�\‰\˜cˆ\Ó"€Fð '+¬U¯YªY°vÓ->Õ&>ÀÕ&GÐÜ&+§i¢i°Ó&7Ðô �9Š9Ð'Ð;ÀÔD×GÑGÈ
ÓSÐSrH   c               ó$   € V ^8„  d   QhRRRRRR/# r0  rD   )rE   s   "rF   rG   rG   ,  s&   € ÷ Yñ Y lð Y¸ð YÈLñ YrH   c                óÎ  € \        V \        P                  4      '       g   \        R\	        V 4       24      hV P
                  R,          ^8X  g   \        RV P
                   24      hV P                  pV\        P                  \        P                  39   d   \        P                  MTpV P                  V4      pVR,          pVR,          p\        P                  ! V^RRR7      pVP                  VR7      pV^ 8H  V^ 8H  ,          p	\        P                  ! V	\        P                  ! V4      V4      p
\        P                   ! Wz4      pV^ 8„  V^ 8„  ,          pV^ 8„  V^ 8H  ,          p\        P                  ! WÇV4      p\        P                  ! WÕ\        P                  ! V4      4      p\        P                  ! WÖV,          Wk,          V,          4      P                  V4      pV# )	a*  Map ``(w, x, y, z)`` quaternions ``(*, 4)`` to log 3-vectors ``(*, 3)``, the logarithm map.

``v = quaternion_exp_to_log(q)`` takes quaternions ``(*, 4)`` with the real part first and returns the 3-vectors
of shape ``(*, 3)``: ``atan2(||u||, w) u / ||u||`` for ``w > 0``, which is ``u / w`` at ``u = 0``, and
``atan2(||u||, w) u / max(||u||, eps)`` for ``w <= 0``, with ``u`` the vector part. For ``w > 0``, and for
``w <= 0`` while ``||u||`` is at least ``eps``, the input need not be unit and :func:`quaternion_log_to_exp` maps
the result back to the unit quaternion of ``q``; for ``w <= 0`` below ``eps`` the log shrinks by
``||u|| / eps``, so ``(-1, 0, 0, 0)`` comes back as ``(1, 0, 0, 0)``. For ``w >= 0`` the result is half the
axis-angle vector; for ``w < 0`` it is not, because this map tells ``q`` from ``-q``. For the axis-angle vector,
use :func:`quaternion_to_axis_angle`.

Convention:
    - for a **unit** ``q`` on the ``w >= 0`` half of the double cover the
      result is ``quaternion_to_axis_angle(q) / 2``. On the ``w < 0`` half the two
      part company: this function keeps the sign of ``w``, with the angle
      ``atan2(||u||, w)`` in ``[0, pi]`` for the vector part ``u``, while
      :func:`~kornia.geometry.conversions.quaternion_to_axis_angle`
      collapses the double cover. For the ``q`` whose log is ``v``,
      ``quaternion_exp_to_log(-q)`` is ``-(pi - ||v||) * v / ||v||``
    - ``quaternion_exp_to_log(quaternion_log_to_exp(v))`` returns ``v`` for
      ``0 < ||v|| < pi``. A longer ``v`` comes back shifted along its own
      direction by a multiple of ``2 * pi`` to a length of at most ``pi``:
      ``pi + 0.5`` and ``3 * pi + 0.5`` both come back as
      ``-2.6415926535897936``, ``2 * pi + 0.5`` as ``0.5``. At exactly
      ``||v|| = pi`` in ``float64`` it collapses to nearly ``0``: ``cos(pi)``
      rounds to ``-1`` and the vector part falls under the ``eps`` clamp.
      Both are properties of the map, not defects
    - ``float16``/``bfloat16`` are computed in ``float32``, so the identity
      returns ``[0., 0., 0.]`` at every dtype. At a zero vector part with
      ``w > 0``, the identity included, the gradient is the limit of the
      map, ``I / w`` with respect to ``(x, y, z)`` and 0 with respect to
      ``w``; at ``w = -1`` it is finite
    - the map is invariant to a positive scale for ``w > 0``, and for ``w <= 0`` while ``||u||`` stays at least
      ``eps``: a non-unit quaternion produces the same log as its normalisation, and ``-q`` another one

Args:
    quaternion: a tensor containing a quaternion to be converted.
      The tensor can be of shape ``(*, 4)``.
    eps: a small number for clamping ``||u||``, applied only for ``w <= 0``.

Return:
    the quaternion log map of shape ``(*, 3)``.

See Also:
    - :func:`quaternion_log_to_exp`: the reverse, the exponential map.
    - :func:`quaternion_to_axis_angle`: the axis-angle vector, twice this one for ``w >= 0``.

Example:
    >>> quaternion = torch.tensor((1., 0., 0., 0.))
    >>> quaternion_exp_to_log(quaternion, eps=torch.finfo(quaternion.dtype).eps)
    tensor([0., 0., 0.])

rJ   r2  Trr  ró   ry   ©.:r�   r†   N).:r†   r    N)rM   rN   rO   rP   rQ   r{   r|   rf   rg   rh   rt  rm   r=  r÷   rj   rk   re   )ré   rb   r×   rv  rw  rz  ry  Únorm_vrx  Ú	at_originÚsafe_scalarr­   ÚexactÚon_axisr?  Úsafe_wÚquaternion_logs   &&               rF   r2   r2   ,  s˜  € ôl �j¤%§,¡,×/Ò/ÜÐ@ÄÀjÓAQÐ@RÐSÓTÐTà×Ñ˜BÕ 1Ô$ÜÐGÈ
×HXÑHXÐGYÐZÓ[Ð[ð ×!Ñ!€JØ",´·±ÄÇÁÐ0OÔ"O”—’ÐU_€JØ�=‰=˜Ó$€DØ˜X�ÐØ˜X�Ðä Ÿ:š:Ð&7¸1À"ÈdÔS€FØ!Ÿ<™<¨C˜<Ó0€Fð ˜1‘Ð!2°aÑ!7Õ8€IÜ—+’+˜i¬¯ªÐ9JÓ)KÐM^Ó_€KÜ�KŠK˜Ó,€Eð
  Ñ" v°¡zÕ2€EØ  1Ñ$¨°1©Õ5€GÜ�KŠK˜ vÓ.€EÜ�[Š[˜´U·_²_ÐEVÓ5WÓX€FÜ#(§;¢;Ø VÕ+Ð->Õ-FÈÕ-Nó$ç�bˆƒnð ð ÐrH   c               ó    € V ^8„  d   QhRRRR/# r¢   rD   )rE   s   "rF   rG   rG   Œ  s   € ÷ d=ñ d=¨ð d=¸,ñ d=rH   c                óò  € \        V \        P                  4      '       g   \        R\	        V 4       24      hV P
                  R,          ^8X  g   \        RV P
                   24      hV P                  pV\        P                  \        P                  39   pV'       d   V P                  4       p V R,          pV R	,          pV R
,          pW3,          WD,          ,           WU,          ,           pVR8„  p\        P                  ! Wv\        P                  ! V4      4      p\        P                  ! V\        P                  ! V4      \        P                  ! V4      4      p	V	R,          p
\        P                  ! V
4      pRV,          p\        P                  ! V
4      \        P                  ! WyV4      ,          p\        P                  ! W}V4      p\        P                  ! V\        P                   ! V
4      V4      p\        P"                  ! . V P
                  RR O^N5VP                  V P$                  R7      pW>,          VR	&   WN,          VR
&   W^,          VR&   VVR&   V'       d   VP'                  V4      # T# )a?  Convert axis-angle vectors ``(*, 3)`` in radians to ``(w, x, y, z)`` quaternions ``(*, 4)``.

``q = axis_angle_to_quaternion(axis_angle)`` takes rotation vectors ``(*, 3)``, each the unit axis scaled by the
angle ``theta`` in radians, and returns the unit quaternions ``(cos(theta / 2), sin(theta / 2) * axis)`` of shape
``(*, 4)``, real part first. The sign is not canonicalised. For the reverse, use :func:`quaternion_to_axis_angle`;
for the rotation matrix, :func:`axis_angle_to_rotation_matrix`; from the half-angle log vector,
:func:`quaternion_log_to_exp`.

Adapted from ceres C++ library: ceres-solver/include/ceres/rotation.h

Convention:
    - the ``(w, x, y, z)`` layout is spelled out on
      :func:`~kornia.geometry.conversions.quaternion_to_rotation_matrix`
    - nothing is canonicalised, so ``pi < theta < 3 * pi`` returns the
      ``w < 0`` half of the double cover: ``[2 * pi, 0., 0.]`` gives
      ``[-1., 0., 0., 0.]``. The sign of ``w = cos(theta / 2)`` keeps
      alternating beyond that interval: ``[4 * pi, 0., 0.]`` gives
      ``[1., 0., 0., 0.]``
    - the round trip with
      :func:`~kornia.geometry.conversions.quaternion_to_axis_angle` holds
      to roundoff for ``0 <= theta <= pi``
    - ``angle_axis_to_quaternion`` is the deprecated alias of this function
      since 0.7.0
    - an integral or boolean input is **promoted**, not rejected: the
      ``sqrt`` on the way in already produces a floating tensor, and the
      output is allocated from that rather than from the input, so the
      result comes back at the ambient default floating dtype
    - differentiable at the zero rotation. The ``sqrt`` whose derivative is
      unbounded there never sees its zero radicand, so the gradient is the
      analytic limit of the surrounding map rather than ``nan``. The guard
      is elementwise, and away from zero it moves no forward bit
    - ``float16`` and ``bfloat16`` are computed in ``float32`` and rounded once to the input dtype

Args:
    axis_angle: tensor with axis angle in radians.

Return:
    tensor with quaternion.

Shape:
    - Input: ``(*, 3)`` where `*` means, any number of dimensions
    - Output: ``(*, 4)``

See Also:
    - :func:`quaternion_to_axis_angle`: the reverse conversion, quaternion to axis-angle.
    - :func:`axis_angle_to_rotation_matrix`: the rotation matrix of the same vector.
    - :func:`rotation_matrix_to_quaternion`: the quaternion of a rotation matrix instead, its sign not canonical.
    - :func:`quaternion_log_to_exp`: the same quaternion from half the vector, the exponential map.
    - :meth:`~kornia.geometry.quaternion.Quaternion.from_axis_angle`: the same quaternion as a
      :class:`~kornia.geometry.quaternion.Quaternion` object.

Example:
    >>> axis_angle = torch.tensor((0., 1., 0.))
    >>> axis_angle_to_quaternion(axis_angle)
    tensor([0.8776, 0.0000, 0.4794, 0.0000])

rJ   z.Input must be a tensor of shape Nx3 or 3. Got rŽ   rÅ   N)Úsizerf   Údevicery   r}  ).:r†   r@   N).:r@   r›   N).:r›   r    N)rM   rN   rO   rP   rQ   r{   r|   rf   rg   rh   rc   rj   rk   ri   r;  r^   r]   Úzerosrˆ  rm   )r£   r×   rn   Úa0Úa1Úa2Útheta_squaredr   Úsafe_theta_squaredr­   Ú
half_thetaÚonesrj  rg  rk  rH  ré   s   &                rF   r   r   Œ  sü  € ôt �j¤%§,¡,×/Ò/ÜÐ@ÄÀjÓAQÐ@RÐSÓTÐTà×Ñ˜BÕ 1Ô$ÜÐIÈ*×JZÑJZÐI[Ð\Ó]Ð]ð ×!Ñ!€JØœ%Ÿ-™-¬¯©Ð8Ñ8€DßØ×%Ñ%Ó'ˆ
ð " (Õ+€BØ! (Õ+€BØ! (Õ+€BØ"$¥'¨B­GÕ"3°bµgÕ"=€Mà&¨Ñ,€Dô (-§{¢{°4ÌÏÊÐXeÓHfÓ'gÐÜŸ+š+ d¬E¯JªJÐ7IÓ,JÌE×L\ÒL\Ð]jÓLkÓl€EØ$ s�{€JäŸš¨Ó4€Dà �*€EÜŸ)š) JÓ/´%·+²+¸dÈ4Ó2PÕP€EÜ—k’k $¨uÓ5€AÜ—k’k $¬¯	ª	°*Ó(=¸tÓD€Aô
  %Ÿ{š{Ð0K°*×2BÑ2BÀ3ÀBÐ2GÐ0KÈÑ0KÐST×SZÑSZÐcm×ctÑctÔu€JØ�6€JˆxÑØ�6€JˆxÑØ�6€JˆxÑØ€JˆxÑß(,ˆ:�=‰=˜Ó$Ð<°*Ð<rH   c               ó    € V ^8„  d   QhRRRR/# r¢   rD   )rE   s   "rF   rG   rG   ô  rm  rH   c                ó   € \        V 4      # )z¹Deprecated: use :func:`~kornia.geometry.conversions.axis_angle_to_quaternion`.

Each call emits a ``DeprecationWarning`` (deprecated since 0.7.0) and returns what the new name returns.
)r   rà   s   &rF   r   r   ó  ro  rH   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )r@   rH  rB   r_   r`   rI  rC   z/tuple[torch.Tensor, torch.Tensor, torch.Tensor]rD   )rE   s   "rF   rG   rG   ÿ  s;   € ÷ Pñ PØðPØ$ðPØ)5ðPØ:FðPà4ñPrH   c                ó¦  € \        V P                  VP                  8H  4       \        VP                  VP                  8H  4       \        VP                  VP                  8H  4       \        P                  ! WW#3RR7      pVP                  pV\        P
                  \        P                  39   pV'       d   VP                  4       p\        V4      pVP                  R4      w  rr#W",          pRW,          W#,          ,           ,          pRRW,          V,           ,          ,
          p	RW,          W,          ,           ,          p
RRWsV,          ,           ,          ,
          pRW,          W1,          ,
          ,          pVP                  RRR7      pWˆ,          W™,          ,           pVR\        P                  ! V4      P                  ,          8  pVR8„  p\        P                  ! V 4      p\        P                  ! V 4      p\        P                  ! VVV4      P!                  \        P                  ! VVV	4      4      pRV,          V ,          p\        P                  ! V\        P                  ! VV) V4      V
4      p\        P                  ! WàV ,          W,          ,
          V4      pVP!                  V4      pVP#                  4       R8¬  p\        P                  ! V\        P                  ! V4      V4      p\        P                  ! VVP%                  4       P'                  4       VP'                  4       4      p\        P(                  ! V\*        P,                  ^,          4      p\        P                  ! V\        P                  ! VVV) 4      V4      pV'       d3   VP/                  V4      VP/                  V4      VP/                  V4      3# VVV3# )	u$  Convert a quaternion given as four tensors w, x, y, z to roll, pitch and yaw in radians.

``roll, pitch, yaw = euler_from_quaternion(w, x, y, z)`` takes the four quaternion components as **separate**
tensors, not as one ``(*, 4)`` tensor, and returns three tensors of their shape: the angles in radians about ``x``,
``y`` and ``z`` of the rotation ``Rz(yaw) @ Ry(pitch) @ Rx(roll)``, with ``roll`` and ``yaw`` in
:math:`[-\pi, \pi]` and ``pitch`` in :math:`[-\pi/2, \pi/2]`. For a ``(*, 4)`` quaternion ``q``, pass
``*q.unbind(-1)``. For the reverse, use :func:`quaternion_from_euler`.

Convention:
    - the four shapes must be exactly equal: broadcastable shapes such as
      ``(2,)`` and ``(1,)`` raise ``BaseError``
    - the composition the triple stands for is documented on
      :func:`~kornia.geometry.conversions.quaternion_from_euler`
    - away from ``|pitch| = pi/2`` it returns the triple of the input
      rotation folded into ``roll, yaw`` in ``[-pi, pi]`` â€” the interval is
      closed at both ends: they come from ``atan2``, which reaches ``Â±pi``
      with the endpoint's sign decided by signed zeros, so ``w = -0.0,
      x = 1.0, y = 0.0, z = -0.0`` returns roll exactly ``-pi`` while the
      ``+0.0`` twin returns ``+pi`` â€” and ``pitch`` in
      ``[-pi/2, pi/2]``, which inside those ranges is the input itself: the
      ``float64`` round trip of ``(0.3, 0.7, 1.1)`` through
      :func:`~kornia.geometry.conversions.quaternion_from_euler` returns to
      ``2.2e-16``, while ``(0.2, 2.5, 0.3)`` comes back as
      ``(-2.9416, 0.6416, -2.8416)`` â€” a different triple for the same
      rotation, to ``1.1e-16``
    - at ``|pitch| = pi/2`` (gimbal lock) ``roll`` and ``yaw`` are not individually
      determined, only ``yaw - roll`` at ``+pi/2`` and ``yaw + roll`` at ``-pi/2`` are, so the
      input triple cannot be recovered. It returns ``pitch`` exactly ``Â±pi/2``, ``roll`` exactly
      ``0`` and that one combination in ``yaw``, wrapped into ``[-pi, pi]``, which reproduces
      the rotation: the round trip through
      :func:`~kornia.geometry.conversions.quaternion_from_euler` is exact to rounding, and ``q``
      and ``-q`` return the same triple. Gimbal lock is detected as ``cos(pitch) < 2 *
      sqrt(eps)`` for the dtype's ``eps`` (``6.25e-2`` for ``float16``, ``1.77e-1`` for ``bfloat16``,
      ``6.9e-4`` for ``float32``, ``3.0e-8`` for ``float64``), so a pitch that close to ``Â±pi/2`` is
      also snapped to the pole and the returned rotation is off by at most its distance to it
    - the input is normalised with
      :func:`~kornia.geometry.conversions.normalize_quaternion` first, so a
      rescaled quaternion returns the same triple
    - ``float16`` and ``bfloat16`` are computed in ``float32`` and rounded once to the input dtype;
      the gimbal-lock threshold stays that of the input dtype

.. note::
    The gradient is finite everywhere, including exactly at gimbal lock. There ``roll`` and ``pitch``
    are constants, so their gradient is exactly ``0`` and all of it is in ``yaw``: for the quaternion of
    ``(roll, pitch, yaw) = (0.1, pi/2, 0.2)`` the gradient of ``roll + pitch + yaw`` with respect to
    ``(w, x, y, z)`` is ``(-0.141, -2.82, 0, 0)``. Within ``2 * sqrt(eps)`` of the pole it is the gradient
    of that constant-pitch triple, not of the plain formulas.

Args:
    w: quaternion :math:`q_w` coefficient.
    x: quaternion :math:`q_x` coefficient.
    y: quaternion :math:`q_y` coefficient.
    z: quaternion :math:`q_z` coefficient.

Return:
    A tuple with the euler angles ``roll``, ``pitch``, ``yaw`` in radians.

See Also:
    - :func:`quaternion_from_euler`: the reverse conversion, Euler angles to quaternion components.
    - :meth:`~kornia.geometry.quaternion.Quaternion.to_euler`: the same angles of a
      :class:`~kornia.geometry.quaternion.Quaternion` object.

r„   rþ   rx   )rô   r+  g      @rŽ   ry   ç      ð¿)r   r{   rN   r¬   rf   rg   rh   rc   r0   r«   r÷   rõ   rb   r;  rk   rj   re   r}   rl   Úasinrÿ   rR   rS   rm   )rH  r_   r`   rI  ré   Ú	out_dtypern   ÚyyÚ	sinr_cospÚ	cosr_cospÚ	siny_cospÚ	cosy_cospÚsinpÚcos_pitch_sqÚgimbalÚupÚzerorV  ÚrollÚ
double_sinÚyaw_numÚyaw_denÚyawÚat_boundaryÚ	safe_sinpÚpitchÚhalf_pis   &&&&                       rF   r'   r'   ÿ  sÉ  € ôD �—‘˜AŸG™GÑ#Ô$Ü�—‘˜AŸG™GÑ#Ô$Ü�—‘˜AŸG™GÑ#Ô$ä—’˜a A˜\¨rÔ2€Jð × Ñ €IØœŸ™¬¯©Ð7Ñ7€DßØ×%Ñ%Ó'ˆ
Ü% jÓ1€JØ×"Ñ" 2Ó&�J€Aˆ!à	
�€Bà�q•u˜q�u•}Õ%€IØ�c˜Q�U R�ZÕ(Õ(€IØ�q•u˜q�u•}Õ%€IØ�c˜R a¥%�ZÕ(Õ(€Ià�!•%˜!�%•-Õ €DØ�:‰:˜$ Cˆ:Ó(€Dð( Õ(¨9Õ+@Õ@€LØ˜C¤%§+¢+¨iÓ"8×"<Ñ"<Õ<Ñ<€FØ	�‰€BÜ×Ò˜AÓ€DÜ
�/Š/˜!Ó
€Cô �;Š;�v˜t YÓ/×5Ñ5´e·k²kÀ&È#ÈyÓ6YÓZ€Dð �q•˜1•€JÜ�kŠk˜&¤%§+¢+¨b°:°+¸zÓ"JÈIÓV€GÜ�kŠk˜& a¥%¨!­%¥-°Ó;€GØ
�-‰-˜Ó
 €Cð —(‘(“* Ñ#€KÜ—’˜K¬×)9Ò)9¸$Ó)?ÀÓF€IÜ�KŠK˜ T§[¡[£]×%7Ñ%7Ó%9¸9¿>¹>Ó;KÓL€Eô �oŠo˜e¤T§W¡W¨q¥[Ó1€GÜ�KŠK˜¤§¢¨B°¸'¸Ó BÀEÓJ€EçØ�w‰w�yÓ! 5§8¡8¨IÓ#6¸¿¹¸yÓ8IÐIÐIØ�˜ÐÐrH   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r@   r¢  rB   r©  r¦  rC   z=tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]rD   )rE   s   "rF   rG   rG   ’  s2   € ÷ Dñ DØ
ðDØ+ðDØ2>ðDàBñDrH   c                ó^  € \        V P                  VP                  8H  4       \        VP                  VP                  8H  4       V P                  pV\        P                  \        P
                  39   ;'       d'    VP                  V8H  ;'       d    VP                  V8H  pV'       d0   V P                  4       VP                  4       VP                  4       r!p V R,          pVR,          pVR,          pVP                  4       pVP                  4       p	VP                  4       p
VP                  4       pVP                  4       pVP                  4       pWŠ,          V,          W›,          V,          ,           pWŠ,          V,          W›,          V,          ,
          pWš,          V,          W‹,          V,          ,           pWš,          V,          W‹,          V,          ,
          pV'       dC   VP                  V4      VP                  V4      VP                  V4      VP                  V4      3# WïVV3# )u?  Convert roll, pitch and yaw in radians to a quaternion returned as four tensors w, x, y, z.

``w, x, y, z = quaternion_from_euler(roll, pitch, yaw)`` takes the angles in radians about ``x``, ``y`` and ``z``
as tensors of one shape and returns, as four tensors of that shape, the components of the unit quaternion of the
rotation ``Rz(yaw) @ Ry(pitch) @ Rx(roll)``, real part first. For one ``(*, 4)`` tensor, stack them with
``torch.stack((w, x, y, z), -1)``. For the reverse, use :func:`euler_from_quaternion`.

Convention:
    - ``roll``, ``pitch`` and ``yaw`` are in **radians** and turn about
      ``x``, ``y`` and ``z`` respectively; the rotation they compose to is
      ``R = Rz(yaw) @ Ry(pitch) @ Rx(roll)`` â€” extrinsic X-Y-Z about the
      fixed axes, equivalently intrinsic Z-Y'-X''. The order matters: at
      ``(0.3, 0.7, 1.1)`` the returned quaternion's matrix differs from
      ``Rx @ Ry @ Rz`` by ``0.64``, from ``Ry @ Rz @ Rx`` by ``0.55`` and
      from ``Rx @ Rz @ Ry`` by ``0.25``
    - the three arguments must have exactly equal shapes; broadcastable
      shapes such as ``(2,)`` and ``(1,)`` raise ``BaseError``
    - the return is a tuple of **four separate tensors** ``(w, x, y, z)``,
      not a ``(*, 4)`` tensor: ``(0.3, 0.7, 1.1)`` gives
      ``[0.8186, -0.0575, 0.3624, 0.4418]``
    - ``float16`` and ``bfloat16`` are computed in ``float32`` and rounded once to the input dtype

Args:
    roll: the roll euler angle.
    pitch: the pitch euler angle.
    yaw: the yaw euler angle.

Return:
    A tuple with quaternion coefficients in order of ``wxyz``.

See Also:
    - :func:`euler_from_quaternion`: the reverse conversion, quaternion components to Euler angles.
    - :meth:`~kornia.geometry.quaternion.Quaternion.from_euler`: the same quaternion as a
      :class:`~kornia.geometry.quaternion.Quaternion` object.

rÅ   )
r   r{   rf   rN   rg   rh   rc   r]   r^   rm   )r¢  r©  r¦  r—  rn   Ú	roll_halfÚ
pitch_halfÚyaw_halfÚcyÚsyÚcpÚspÚcrÚsrr  r  r  r  s   &&&               rF   r3   r3   ’  s�  € ôN �—‘˜uŸ{™{Ñ*Ô+Ü�—‘ §	¡	Ñ)Ô*ð
 —
‘
€IØœŸ™¬¯©Ð7Ñ7×oÐo¸E¿K¹KÈ9Ñ<T×oÐoÐY\×YbÑYbÐfoÑYo€DßØŸ:™:›<¨¯©«¸¿	¹	»�Sˆà�s•
€IØ˜•€JØ�S�y€Hà	�‰‹€BØ	�‰‹€BØ	�‰Ó	€BØ	�‰Ó	€BØ	�‰‹€BØ	�‰‹€Bà	��2�˜� "�Õ	$€BØ	��2�˜� "�Õ	$€BØ	��2�˜� "�Õ	$€BØ	��2�˜� "�Õ	$€BçØ�u‰u�YÓ §¡ yÓ!1°2·5±5¸Ó3CÀRÇUÁUÈ9ÓEUÐUÐUØ�2�rˆ>ÐrH   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# ©	r@   Úpixel_coordinatesrB   ÚheightÚintÚwidthrb   rc   rC   rD   )rE   s   "rF   rG   rG   Ý  s;   € ÷ q/ñ q/Ø#ðq/Ø-0ðq/Ø9<ðq/ØCHðq/àñq/rH   c           
     ó	  € V P                   R,          ^8w  d   \        RV P                    24      h\        P                  P	                  4       '       g!   V^ 8:  g   V^ 8:  d   \        RV RV R24      h\        P                  P                  4       '       gY   \        P                  P	                  4       '       g5   \        4       '       g%   VR8w  d   \        P                  ! R\        ^R7       \        P                  P                  4       '       g7   \        P                  P	                  4       '       Egv   \        4       '       Ege   V^8X  d   RMR	VR,
          ,          pV^8X  d   RMR	VR,
          ,          pV^8X  d   R
MRpV^8X  d   R
MRp\        P                  P                  4       '       dx   \        P                  ! RV P                  V P                  R7      p\        P                  ! W„,          W…,          .4      p	\        P                  ! W†,          W‡,          .4      p
EMMV P                  4       '       d   V P                  M\        P                  ! 4       p\        P                   ! WE.V P                  VR7      p	\        P                   ! Wg.V P                  VR7      p
EMÌV P                  4       '       d   V P                  M\        P                  ! 4       pV\        P"                  \        P$                  39   d   \        P&                  MTp\        P(                  ! W P                  VR7      p\        P(                  ! WP                  VR7      p\        P                  ! RV P                  VR7      p\        P*                  ! RV P                  VR7      p\        P                  ! \        P,                  ! V^8H  VR	VR,
          ,          4      \        P,                  ! V^8H  VR	VR,
          ,          4      .4      p	\        P                  ! \        P,                  ! V^8H  VV) 4      \        P,                  ! V^8H  VV) 4      .4      p
V	P/                  V4      p	V
P/                  V4      p
W�,          V
,           # )uŒ  Map 2D ``(x, y)`` pixel coordinates to ``[-1, 1]``, corner-aligned.

``coords_norm = normalize_pixel_coordinates(coords, height, width)`` takes pixel coordinates ``(*, 2)`` in
``(x, y)`` order and the image size in ``(height, width)`` order, and returns them as normalized
:math:`[-1, 1]` coordinates, corner-aligned: the centres of the first and last pixel of each axis map to ``-1``
and ``1``. This is the ``align_corners=True`` convention, and there is no other choice here: for the half-pixel
convention of ``align_corners=False``, apply
``normal_transform_pixel(height, width, device=..., dtype=..., align_corners=False)``, on the device and in the
floating dtype of the coordinates (cast integer ones first), with
:func:`~kornia.geometry.linalg.transform_points`, which needs a point axis, ``(*, N, 2)`` (write a single ``(2,)``
coordinate as ``coords[None]``). For the reverse, use
:func:`denormalize_pixel_coordinates`; for ``(*, 3)`` voxel coordinates, :func:`normalize_pixel_coordinates3d`.

Convention:
    See :doc:`Conventions & Pitfalls </get-started/conventions>` for the library-wide pixel-centre,
    normalized-coordinate and ``align_corners`` conventions.

    - ``pixel_coordinates`` is ``(*, 2)`` in ``(x, y)`` order: ``x``
      indexes columns and is scaled by ``width``, ``y`` indexes rows and is
      scaled by ``height``. The positional argument order is the other way
      round â€” ``(pixel_coordinates, height, width)``
    - the mapping is ``x_norm = 2 * x / (width - 1) - 1``: for
      ``width = 4`` the columns ``0``, ``1``, ``3`` map to ``-1``,
      ``-1/3``, ``+1``. :func:`torch.nn.functional.grid_sample` at its
      default ``align_corners=False`` would instead place the first and
      last of those values at pixels ``-0.5`` and ``3.5`` â€” half a pixel
      outside the image on each side â€” so ``align_corners=True`` must be
      passed explicitly when feeding this output to it. kornia's own
      :func:`~kornia.geometry.transform.remap` normalizes pixel maps with
      this function but resolves ``align_corners=None`` to ``False``
      (`#4504 <https://github.com/kornia/kornia/issues/4504>`_)
    - a singleton axis uses scale ``1`` and offset ``0``: its only valid
      pixel coordinate maps to the normalized centre, and the unit-scale
      extension keeps this function exactly invertible outside that lone
      valid coordinate. Zero and negative sizes raise ``ValueError``
    - the output is **not** clamped: coordinates outside the image
      extrapolate linearly past ``[-1, 1]``, as the example below shows

.. note::
    Legacy ``torch.jit.trace`` graphs assume positive runtime sizes because
    tracing cannot retain the Python ``ValueError`` validation. Eager,
    TorchScript, and ``torch.compile`` calls validate sizes.

.. deprecated:: 0.9.0
    ``eps`` no longer participates in the explicitly defined singleton-axis
    mapping. Passing a non-default value warns in eager mode; the parameter
    will be removed in a future breaking release.

Args:
    pixel_coordinates: the grid with pixel coordinates. Shape can be ``(*, 2)``.
    height: the image height, the number of rows, which scales ``y``.
    width: the image width, the number of columns, which scales ``x``.
    eps: deprecated compatibility parameter. It is ignored.

Return:
    the normalized pixel coordinates with shape ``(*, 2)``.

See Also:
    - :func:`denormalize_pixel_coordinates`: the reverse map, :math:`[-1, 1]` back to pixels.
    - :func:`normalize_pixel_coordinates3d`: the 3D form, for ``(*, 3)`` coordinates in ``(d, x, y)`` order.
    - :func:`normal_transform_pixel`: the same map as a ``(1, 3, 3)`` matrix, with an ``align_corners`` choice.
    - :func:`~kornia.geometry.grid.create_meshgrid`: the whole ``(1, H, W, 2)`` pixel grid, normalized the same
      way by default.

Examples:
    >>> coords = torch.tensor([[50., 100.]])
    >>> normalize_pixel_coordinates(coords, 100, 50)
    tensor([[1.0408, 1.0202]])

ú5Input pixel_coordinates must be of shape (*, 2). Got ú.Input image size must be positive. Got height=ú, width=rŒ   ç:Œ0âŽyE>zA`eps` is deprecated and ignored by `normalize_pixel_coordinates`.©Ú
stacklevelrx   rþ   rŽ   ©rˆ  rf   ry   r•  rD   ©r{   r|   rN   ÚjitÚ
is_tracingÚis_scriptingr   ÚwarningsÚwarnÚFutureWarningr�  rˆ  rf   r¬   r‘   Úget_default_dtyperA   rg   rh   rt  Úscalar_tensorr‰  rj   rm   )r¸  r¹  r»  rb   Úsxr±  rJ  rK  ÚanchorÚfactorÚoffsetrv  r—  Úwidth_tÚheight_trV  r¡  s   &&&&             rF   r-   r-   Ý  sL  € ðR ×Ñ˜rÕ" aÔ'ÜÐPÐQb×QhÑQhÐPiÐjÓkÐkÜ�9‰9×Ñ×!Ò! v°¤{°e¸q´jÜÐIÈ&ÈÐQYÐZ_ÐY`Ð`aÐbÓcÐcÜ�9‰9×!Ñ!×#Ò#¬E¯I©I×,@Ñ,@×,BÒ,BÌ<Ï>Ê>Ð^aÐeiÔ^iÜ�ŠÐYÔ[hÐuvÕwä‡y�y×Ñ×Ò¬¯	©	×(<Ñ(<×(>Ó(>Ä|Ç~Ã~Ø˜Q”J‰S C¨5°3­;Õ$7ˆØ˜a”K‰S S¨F°S­LÕ%9ˆØ˜Q”J‰S DˆØ˜a”K‰S TˆÜ�9‰9×!Ñ!×#Ò#Ü—Z’Z Ð+<×+CÑ+CÐK\×KbÑKbÔcˆFÜ—[’[ &¥+¨v­{Ð!;Ó<ˆFÜ—[’[ &¥+¨v­{Ð!;Ó<ŠFà4E×4WÑ4W×4YÒ4YÐ*×0Ò0Ô_d×_vÒ_vÓ_xˆJÜ—\’\ 2 (Ð3D×3KÑ3KÐS]Ô^ˆFÜ—\’\ 2 (Ð3D×3KÑ3KÐS]Ô^ŠFà/@×/RÑ/R×/TÒ/TÐ%×+Ò+ÔZ_×ZqÒZqÓZsˆ	ð '0´E·M±MÄ5Ç>Á>Ð3RÔ&R”U—]’]ÐXaˆ
Ü×%Ò% e×4LÑ4LÐT^Ô_ˆÜ×&Ò& v×6NÑ6NÐV`ÔaˆÜ�jŠj˜Ð$5×$<Ñ$<ÀJÔOˆÜ�{Š{˜2Ð&7×&>Ñ&>ÀjÔQˆÜ—’ä—’˜G q™L¨#¨s°gÀµmÕ/DÓEÜ—’˜H¨™M¨3°°xÀ#µ~Õ0FÓGðó
ˆô —’œeŸkšk¨'°Q©,¸¸s¸dÓCÄUÇ[Â[ÐQYÐ]^ÑQ^Ð`dÐgjÐfjÓEkÐlÓmˆØ—‘˜9Ó%ˆØ—‘˜9Ó%ˆàÕ%¨Õ.Ð.rH   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# r·  rD   )rE   s   "rF   rG   rG   Q  s;   € ÷ O/ñ O/Ø#ðO/Ø-0ðO/Ø9<ðO/ØCHðO/àñO/rH   c                ó	  € V P                   R,          ^8w  d   \        RV P                    24      h\        P                  P	                  4       '       g!   V^ 8:  g   V^ 8:  d   \        RV RV R24      h\        P                  P                  4       '       gY   \        P                  P	                  4       '       g5   \        4       '       g%   VR8w  d   \        P                  ! R\        ^R7       \        P                  P                  4       '       g7   \        P                  P	                  4       '       Egv   \        4       '       Ege   V^8X  d   RMVR,
          R	,          pV^8X  d   RMVR,
          R	,          pV^8X  d   R
MTpV^8X  d   R
MTp\        P                  P                  4       '       dx   \        P                  ! RV P                  V P                  R7      p\        P                  ! W„,          W…,          .4      p	\        P                  ! W†,          W‡,          .4      p
EMMV P                  4       '       d   V P                  M\        P                  ! 4       p\        P                   ! WE.V P                  VR7      p	\        P                   ! Wg.V P                  VR7      p
EMÌV P                  4       '       d   V P                  M\        P                  ! 4       pV\        P"                  \        P$                  39   d   \        P&                  MTp\        P(                  ! W P                  VR7      p\        P(                  ! WP                  VR7      p\        P                  ! RV P                  VR7      p\        P*                  ! RV P                  VR7      p\        P,                  ! V^8H  WýR,
          R	,          4      p\        P,                  ! V^8H  WþR,
          R	,          4      p\        P                  ! VV.4      p	\        P                  ! \        P,                  ! V^8H  VV4      \        P,                  ! V^8H  VV4      .4      p
V	P/                  V4      p	V
P/                  V4      p
W�,          V
,           # )ad  Map 2D ``(x, y)`` coordinates from ``[-1, 1]`` back to pixels, corner-aligned.

``coords = denormalize_pixel_coordinates(coords_norm, height, width)`` is the inverse of
:func:`normalize_pixel_coordinates`: it takes corner-aligned coordinates ``(*, 2)`` in ``(x, y)`` order, with
``-1`` and ``1`` at the centres of the first and last pixel of each axis, and the image size in
``(height, width)`` order, and returns the pixel coordinates ``(*, 2)``, ``x = (width - 1) * (x_norm + 1) / 2``,
so that ``1`` maps to ``x = width - 1``. For ``(*, 3)`` voxel coordinates, use
:func:`denormalize_pixel_coordinates3d`.

Convention:
    See :doc:`Conventions & Pitfalls </get-started/conventions>` for the library-wide pixel-centre,
    normalized-coordinate and ``align_corners`` conventions.

    - singleton axes, non-positive-size validation, tracing assumptions, and
      the deprecated ``eps`` parameter follow the normalization function

Args:
    pixel_coordinates: the normalized grid coordinates. Shape can be ``(*, 2)``.
    height: the image height, the number of rows, which scales ``y``.
    width: the image width, the number of columns, which scales ``x``.
    eps: deprecated compatibility parameter. It is ignored.

Return:
    the denormalized pixel coordinates with shape ``(*, 2)``.

See Also:
    - :func:`normalize_pixel_coordinates`: the forward map, pixels to :math:`[-1, 1]`.
    - :func:`denormalize_pixel_coordinates3d`: the 3D form, for ``(*, 3)`` coordinates in ``(d, x, y)`` order.

Examples:
    >>> coords = torch.tensor([[-1., -1.]])
    >>> denormalize_pixel_coordinates(coords, 100, 50)
    tensor([[0., 0.]])

r½  r¾  r¿  rŒ   rÀ  zC`eps` is deprecated and ignored by `denormalize_pixel_coordinates`.rÁ  rx   rþ   rŽ   rÃ  ry   rD   rÄ  )r¸  r¹  r»  rb   rÍ  r±  rJ  rK  rÎ  rÏ  rÐ  rv  r—  rÑ  rÒ  rV  r¡  Úsx_tÚsy_ts   &&&&               rF   r$   r$   Q  sH  € ðL ×Ñ˜rÕ" aÔ'ÜÐPÐQb×QhÑQhÐPiÐjÓkÐkÜ�9‰9×Ñ×!Ò! v°¤{°e¸q´jÜÐIÈ&ÈÐQYÐZ_ÐY`Ð`aÐbÓcÐcÜ�9‰9×!Ñ!×#Ò#¬E¯I©I×,@Ñ,@×,BÒ,BÌ<Ï>Ê>Ð^aÐeiÔ^iÜ�ŠØQÜØõ	
ô ‡y�y×Ñ×Ò¬¯	©	×(<Ñ(<×(>Ó(>Ä|Ç~Ã~Ø˜Q”J‰S U¨S¥[°CÕ$7ˆØ˜a”K‰S f¨s¥l°cÕ%9ˆØ˜Q”J‰S BˆØ˜a”K‰S RˆÜ�9‰9×!Ñ!×#Ò#Ü—Z’Z Ð+<×+CÑ+CÐK\×KbÑKbÔcˆFÜ—[’[ &¥+¨v­{Ð!;Ó<ˆFÜ—[’[ &¥+¨v­{Ð!;Ó<ŠFà4E×4WÑ4W×4YÒ4YÐ*×0Ò0Ô_d×_vÒ_vÓ_xˆJÜ—\’\ 2 (Ð3D×3KÑ3KÐS]Ô^ˆFÜ—\’\ 2 (Ð3D×3KÑ3KÐS]Ô^ŠFà/@×/RÑ/R×/TÒ/TÐ%×+Ò+ÔZ_×ZqÒZqÓZsˆ	ð '0´E·M±MÄ5Ç>Á>Ð3RÔ&R”U—]’]ÐXaˆ
Ü×%Ò% e×4LÑ4LÐT^Ô_ˆÜ×&Ò& v×6NÑ6NÐV`ÔaˆÜ�jŠj˜Ð$5×$<Ñ$<ÀJÔOˆÜ�{Š{˜2Ð&7×&>Ñ&>ÀjÔQˆÜ�{Š{˜7 a™<¨¸­}ÀÕ.CÓDˆÜ�{Š{˜8 q™=¨#¸3µÀ#Õ/EÓFˆÜ—’˜d D˜\Ó*ˆÜ—’œeŸkšk¨'°Q©,¸¸dÓCÄUÇ[Â[ÐQYÐ]^ÑQ^Ð`dÐfjÓEkÐlÓmˆØ—‘˜9Ó%ˆØ—‘˜9Ó%ˆàÕ%¨Õ.Ð.rH   c               ó0   € V ^8„  d   QhRRRRRRRRRRR	R/# ©
r@   r¸  rB   Údepthrº  r¹  r»  rb   rc   rC   rD   )rE   s   "rF   rG   rG   £  sD   € ÷ `/ñ `/Ø#ð`/Ø,/ð`/Ø9<ð`/ØEHð`/ØOTð`/àñ`/rH   c                óZ
  € V P                   R,          ^8w  d   \        RV P                    24      h\        P                  P	                  4       '       g+   V^ 8:  g   V^ 8:  g   V^ 8:  d   \        RV RV RV R24      h\        P                  P                  4       '       gY   \        P                  P	                  4       '       g5   \        4       '       g%   VR8w  d   \        P                  ! R\        ^R7       \        P                  P                  4       '       g7   \        P                  P	                  4       '       Egª   \        4       '       Eg™   V^8X  d   R	MR
VR	,
          ,          pV^8X  d   R	MR
VR	,
          ,          pV^8X  d   R	MR
VR	,
          ,          pV^8X  d   RMRpV^8X  d   RMRp	V^8X  d   RMRp
\        P                  P                  4       '       d†   \        P                  ! RV P                  V P                  R7      p\        P                  ! Wµ,          W¶,          W·,          .4      p\        P                  ! W¸,          W¹,          Wº,          .4      pEM´V P                  4       '       d   V P                  M\        P                  ! 4       p\        P                   ! WVV.V P                  VR7      p\        P                   ! W‰V
.V P                  VR7      pEM1V P                  4       '       d   V P                  M\        P                  ! 4       pV\        P"                  \        P$                  39   d   \        P&                  MTp\        P(                  ! WP                  VR7      p\        P(                  ! W0P                  VR7      p\        P(                  ! W P                  VR7      p\        P                  ! RV P                  VR7      p\        P*                  ! RV P                  VR7      p\        P                  ! \        P,                  ! V^8H  VR
VR	,
          ,          4      \        P,                  ! V^8H  VR
VR	,
          ,          4      \        P,                  ! V^8H  VR
VR	,
          ,          4      .4      p\        P                  ! \        P,                  ! V^8H  VV) 4      \        P,                  ! V^8H  VV) 4      \        P,                  ! V^8H  VV) 4      .4      pVP/                  V4      pVP/                  V4      pWÀ,          V,           # )u  Map 3D ``(d, x, y)`` voxel coordinates to ``[-1, 1]``, corner-aligned.

``coords_norm = normalize_pixel_coordinates3d(coords, depth, height, width)`` takes voxel coordinates ``(*, 3)`` in
``(d, x, y)`` order, the order of :func:`~kornia.geometry.grid.create_meshgrid3d`, and returns them as
normalized :math:`[-1, 1]` coordinates, corner-aligned and unclamped in each axis as
:func:`normalize_pixel_coordinates` is.
:func:`normal_transform_pixel3d` reads ``(x, y, z)`` instead, so a grid built for one permutes the axes when fed
to the other. For the reverse, use :func:`denormalize_pixel_coordinates3d`.

Convention:
    - ``pixel_coordinates`` is ``(*, 3)`` in ``(d, x, y)`` order â€”
      **depth first, then x, then y**, *not* ``(x, y, z)``. The
      three components are scaled by ``depth - 1``, ``width - 1`` and
      ``height - 1`` respectively, so with ``depth=3, height=5, width=9``
      the coordinate ``[2., 8., 4.]`` maps to ``[1., 1., 1.]``
    - the positional argument order is
      ``(pixel_coordinates, depth, height, width)``
    - singleton axes, non-positive-size validation, tracing assumptions, and
      the deprecated ``eps`` parameter follow
      :func:`~kornia.geometry.conversions.normalize_pixel_coordinates`

Args:
    pixel_coordinates: the grid with pixel coordinates. Shape can be ``(*, 3)``.
    depth: the volume depth, which scales ``d``.
    height: the volume height, which scales ``y``.
    width: the volume width, which scales ``x``.
    eps: deprecated compatibility parameter. It is ignored.

Return:
    the normalized pixel coordinates, ``(*, 3)`` in ``(d, x, y)`` order.

See Also:
    - :func:`denormalize_pixel_coordinates3d`: the reverse map, :math:`[-1, 1]` back to voxels.
    - :func:`normalize_pixel_coordinates`: the 2D form, for ``(*, 2)`` coordinates in ``(x, y)`` order.
    - :func:`normal_transform_pixel3d`: the same scaling as a ``(1, 4, 4)`` matrix on ``(x, y, z, 1)``.
    - :func:`~kornia.geometry.grid.create_meshgrid3d`: the whole ``(1, D, H, W, 3)`` voxel grid, normalized the
      same way by default.

ú5Input pixel_coordinates must be of shape (*, 3). Got ú-Input image size must be positive. Got depth=ú	, height=r¿  rŒ   rÀ  zC`eps` is deprecated and ignored by `normalize_pixel_coordinates3d`.rÁ  rx   rþ   rŽ   rÃ  ry   r•  rD   rÄ  )r¸  rÙ  r¹  r»  rb   ÚsdrÍ  r±  ÚtdrJ  rK  rÎ  rÏ  rÐ  rv  r—  Údepth_trÑ  rÒ  rV  r¡  s   &&&&&                rF   r.   r.   £  sÛ  € ðT ×Ñ˜rÕ" aÔ'ÜÐPÐQb×QhÑQhÐPiÐjÓkÐkÜ�9‰9×Ñ×!Ò! u°¤z°V¸q´[ÀEÈQÄJÜÐHÈÈÈyÐY_ÐX`Ð`hÐinÐhoÐopÐqÓrÐrÜ�9‰9×!Ñ!×#Ò#¬E¯I©I×,@Ñ,@×,BÒ,BÌ<Ï>Ê>Ð^aÐeiÔ^iÜ�ŠØQÜØõ	
ô ‡y�y×Ñ×Ò¬¯	©	×(<Ñ(<×(>Ó(>Ä|Ç~Ã~Ø˜Q”J‰S C¨5°3­;Õ$7ˆØ˜Q”J‰S C¨5°3­;Õ$7ˆØ˜a”K‰S S¨F°S­LÕ%9ˆØ˜Q”J‰S DˆØ˜Q”J‰S DˆØ˜a”K‰S TˆÜ�9‰9×!Ñ!×#Ò#Ü—Z’Z Ð+<×+CÑ+CÐK\×KbÑKbÔcˆFÜ—[’[ &¥+¨v­{¸F½KÐ!HÓIˆFÜ—[’[ &¥+¨v­{¸F½KÐ!HÓIŠFà4E×4WÑ4W×4YÒ4YÐ*×0Ò0Ô_d×_vÒ_vÓ_xˆJÜ—\’\ 2¨2 ,Ð7H×7OÑ7OÐWaÔbˆFÜ—\’\ 2¨2 ,Ð7H×7OÑ7OÐWaÔbŠFà/@×/RÑ/R×/TÒ/TÐ%×+Ò+ÔZ_×ZqÒZqÓZsˆ	ð '0´E·M±MÄ5Ç>Á>Ð3RÔ&R”U—]’]ÐXaˆ
Ü×%Ò% e×4LÑ4LÐT^Ô_ˆÜ×%Ò% e×4LÑ4LÐT^Ô_ˆÜ×&Ò& v×6NÑ6NÐV`ÔaˆÜ�jŠj˜Ð$5×$<Ñ$<ÀJÔOˆÜ�{Š{˜2Ð&7×&>Ñ&>ÀjÔQˆÜ—’ä—’˜G q™L¨#¨s°gÀµmÕ/DÓEÜ—’˜G q™L¨#¨s°gÀµmÕ/DÓEÜ—’˜H¨™M¨3°°xÀ#µ~Õ0FÓGðó
ˆô —’ä—’˜G q™L¨$°°Ó5Ü—’˜G q™L¨$°°Ó5Ü—’˜H¨™M¨4°#°Ó6ðó
ˆð —‘˜9Ó%ˆØ—‘˜9Ó%ˆàÕ%¨Õ.Ð.rH   c               ó0   € V ^8„  d   QhRRRRRRRRRRR	R/# rØ  rD   )rE   s   "rF   rG   rG     sD   € ÷ T/ñ T/Ø#ðT/Ø,/ðT/Ø9<ðT/ØEHðT/ØOTðT/àñT/rH   c           	     ó`
  € V P                   R,          ^8w  d   \        RV P                    24      h\        P                  P	                  4       '       g+   V^ 8:  g   V^ 8:  g   V^ 8:  d   \        RV RV RV R24      h\        P                  P                  4       '       gY   \        P                  P	                  4       '       g5   \        4       '       g%   VR8w  d   \        P                  ! R\        ^R7       \        P                  P                  4       '       g7   \        P                  P	                  4       '       Egª   \        4       '       Eg™   V^8X  d   R	MVR	,
          R
,          pV^8X  d   R	MVR	,
          R
,          pV^8X  d   R	MVR	,
          R
,          pV^8X  d   RMTpV^8X  d   RMTp	V^8X  d   RMTp
\        P                  P                  4       '       d†   \        P                  ! RV P                  V P                  R7      p\        P                  ! Wµ,          W¶,          W·,          .4      p\        P                  ! W¸,          W¹,          Wº,          .4      pEM·V P                  4       '       d   V P                  M\        P                  ! 4       p\        P                   ! WVV.V P                  VR7      p\        P                   ! W‰V
.V P                  VR7      pEM4V P                  4       '       d   V P                  M\        P                  ! 4       pV\        P"                  \        P$                  39   d   \        P&                  MTp\        P(                  ! WP                  VR7      p\        P(                  ! W0P                  VR7      p\        P(                  ! W P                  VR7      p\        P                  ! RV P                  VR7      p\        P*                  ! RV P                  VR7      p\        P,                  ! V^8H  VVR	,
          R
,          4      p\        P,                  ! V^8H  VVR	,
          R
,          4      p\        P,                  ! V^8H  VVR	,
          R
,          4      p\        P                  ! VVV.4      p\        P                  ! \        P,                  ! V^8H  VV4      \        P,                  ! V^8H  VV4      \        P,                  ! V^8H  VV4      .4      pVP/                  V4      pVP/                  V4      pWÀ,          V,           # )a•  Map 3D ``(d, x, y)`` coordinates from ``[-1, 1]`` back to voxels, corner-aligned.

``coords = denormalize_pixel_coordinates3d(coords_norm, depth, height, width)`` is the inverse of
:func:`normalize_pixel_coordinates3d`: it takes corner-aligned coordinates ``(*, 3)`` in ``(d, x, y)`` order and
returns the voxel coordinates ``(*, 3)`` in the same order. For ``(*, 2)`` pixel coordinates, use
:func:`denormalize_pixel_coordinates`.

Convention:
    - the ``(d, x, y)`` component order and the
      ``(pixel_coordinates, depth, height, width)`` positional order are
      those of the normalization: with ``depth=3, height=5, width=9`` the
      input ``[0., 0., 0.]`` maps back to ``[1., 4., 2.]``
    - singleton axes, non-positive-size validation, tracing assumptions, and
      the deprecated ``eps`` parameter follow the 2-D counterpart

Args:
    pixel_coordinates: the normalized grid coordinates. Shape can be ``(*, 3)``.
    depth: the volume depth, which scales ``d``.
    height: the volume height, which scales ``y``.
    width: the volume width, which scales ``x``.
    eps: deprecated compatibility parameter. It is ignored.

Return:
    the denormalized pixel coordinates, ``(*, 3)`` in ``(d, x, y)`` order.

See Also:
    - :func:`normalize_pixel_coordinates3d`: the forward map, voxels to :math:`[-1, 1]`.
    - :func:`denormalize_pixel_coordinates`: the 2D form, for ``(*, 2)`` coordinates in ``(x, y)`` order.

rÛ  rÜ  rÝ  r¿  rŒ   rÀ  zE`eps` is deprecated and ignored by `denormalize_pixel_coordinates3d`.rÁ  rx   rþ   rŽ   rÃ  ry   rD   rÄ  )r¸  rÙ  r¹  r»  rb   rÞ  rÍ  r±  rß  rJ  rK  rÎ  rÏ  rÐ  rv  r—  rà  rÑ  rÒ  rV  r¡  Úsd_trÕ  rÖ  s   &&&&&                   rF   r%   r%     sÛ  € ðB ×Ñ˜rÕ" aÔ'ÜÐPÐQb×QhÑQhÐPiÐjÓkÐkÜ�9‰9×Ñ×!Ò! u°¤z°V¸q´[ÀEÈQÄJÜÐHÈÈÈyÐY_ÐX`Ð`hÐinÐhoÐopÐqÓrÐrÜ�9‰9×!Ñ!×#Ò#¬E¯I©I×,@Ñ,@×,BÒ,BÌ<Ï>Ê>Ð^aÐeiÔ^iÜ�ŠØSÜØõ	
ô ‡y�y×Ñ×Ò¬¯	©	×(<Ñ(<×(>Ó(>Ä|Ç~Ã~Ø˜Q”J‰S U¨S¥[°CÕ$7ˆØ˜Q”J‰S U¨S¥[°CÕ$7ˆØ˜a”K‰S f¨s¥l°cÕ%9ˆØ˜Q”J‰S BˆØ˜Q”J‰S BˆØ˜a”K‰S RˆÜ�9‰9×!Ñ!×#Ò#Ü—Z’Z Ð+<×+CÑ+CÐK\×KbÑKbÔcˆFÜ—[’[ &¥+¨v­{¸F½KÐ!HÓIˆFÜ—[’[ &¥+¨v­{¸F½KÐ!HÓIŠFà4E×4WÑ4W×4YÒ4YÐ*×0Ò0Ô_d×_vÒ_vÓ_xˆJÜ—\’\ 2¨2 ,Ð7H×7OÑ7OÐWaÔbˆFÜ—\’\ 2¨2 ,Ð7H×7OÑ7OÐWaÔbŠFà/@×/RÑ/R×/TÒ/TÐ%×+Ò+ÔZ_×ZqÒZqÓZsˆ	ð '0´E·M±MÄ5Ç>Á>Ð3RÔ&R”U—]’]ÐXaˆ
Ü×%Ò% e×4LÑ4LÐT^Ô_ˆÜ×%Ò% e×4LÑ4LÐT^Ô_ˆÜ×&Ò& v×6NÑ6NÐV`ÔaˆÜ�jŠj˜Ð$5×$<Ñ$<ÀJÔOˆÜ�{Š{˜2Ð&7×&>Ñ&>ÀjÔQˆÜ�{Š{˜7 a™<¨¨w¸­}ÀÕ.CÓDˆÜ�{Š{˜7 a™<¨¨w¸­}ÀÕ.CÓDˆÜ�{Š{˜8 q™=¨#°¸3µÀ#Õ/EÓFˆÜ—’˜d D¨$Ð/Ó0ˆÜ—’ä—’˜G q™L¨$°Ó5Ü—’˜G q™L¨$°Ó5Ü—’˜H¨™M¨4°Ó6ðó
ˆð —‘˜9Ó%ˆØ—‘˜9Ó%ˆàÕ%¨Õ.Ð.rH   c               ó    € V ^8„  d   QhRRRR/# )r@   ÚanglerB   rC   rD   )rE   s   "rF   rG   rG   ]  s   € ÷ 2-ñ 2- Lð 2-°\ñ 2-rH   c                óº  € V P                   \        P                  \        P                  39   p\	        V'       d   V P                  4       MT 4      p\        P                  ! V4      p\        P                  ! V4      p\        P                  ! W4V) V.RR7      pV'       d   VP                  V P                   4      pVP                  ! . V P                  O^N^N5!  # )uV  Build 2D rotation matrices ``(*, 2, 2)`` from angles in degrees, counter-clockwise as displayed.

``R = angle_to_rotation_matrix(angle)`` takes angles of any shape ``(*)`` in **degrees** and returns the matrices
``[[cos, sin], [-sin, cos]]`` of shape ``(*, 2, 2)``. Applied to ``(x, y)`` column vectors in image coordinates,
with ``y`` down, a positive angle turns counter-clockwise as displayed, which is clockwise in a ``y``-up plot. For
a ``(B, 2, 3)`` matrix that also scales and turns about a centre, use
:func:`~kornia.geometry.transform.get_rotation_matrix2d`; for an angle in radians, pass ``rad2deg(angle)``.

Convention:
    - the matrix has ``det = +1``; for
      ``angle = 30`` it is ``[[0.8660, 0.5000], [-0.5000, 0.8660]]``
    - applied on the left to a column vector ``(x, y)``, ``angle = 30`` maps
      ``(1., 0.)`` to ``(0.8660, -0.5000)`` â€” counter-clockwise **as
      displayed** under kornia's y-down image axes. In the raw coordinate
      plane this is the opposite sense to
      :func:`~kornia.geometry.conversions.cart2pol`, whose Convention block
      spells out the modulo-:math:`2\pi` relation between the two ops
    - ``float16`` and ``bfloat16`` are computed in ``float32`` and rounded once to the input dtype,
      so a multiple of 90 degrees gives exact zeros and ones

Args:
    angle: tensor of angles in degrees, any shape ``(*)``.

Returns:
    tensor of rotation matrices with shape ``(*, 2, 2)``.

See Also:
    - :func:`~kornia.geometry.transform.get_rotation_matrix2d`: the ``(B, 2, 3)`` matrix that also scales and
      turns about a centre, in the same sense.
    - :func:`axis_angle_to_rotation_matrix`: a 3D ``(*, 3, 3)`` rotation from an axis-angle vector in radians.
    - :func:`cart2pol`: the polar angle of a point, which this rotation decreases.
    - :class:`~kornia.geometry.liegroup.So2`: a 2D rotation object built from radians, turning the other way:
      its :meth:`~kornia.geometry.liegroup.So2.matrix` is the transpose of this matrix for the same angle.

Example:
    >>> input = torch.rand(1, 3)  # Nx3
    >>> output = angle_to_rotation_matrix(input)  # Nx3x2x2

r„   ry   )rf   rN   rg   rh   r!   rc   r]   r^   r¬   rm   Úviewr{   )rå  rn   Úang_radÚcos_aÚsin_arÛ   s   &     rF   r   r   ]  sž   € ðV �;‰;œ5Ÿ=™=¬%¯.©.Ð9Ñ9€DÜ§t�e—k‘k”m°Ó7€GÜŸ)š) GÓ,€EÜŸ)š) GÓ,€EÜ�{Š{˜E¨5¨&°%Ð8¸bÔA€HßØ—;‘;˜uŸ{™{Ó+ˆØ�=Š=Ð,˜%Ÿ+™+Ð, qÐ,¨!Ó,Ð,rH   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r@   rÌ   rB   rÍ   ÚcrC   rD   )rE   s   "rF   rG   rG   ’  s)   € ÷ 	ñ 	˜|ð 	°ð 	Àð 	ÐR^ñ 	rH   c                ó  € \         P                  P                  4       '       d   WV,          ,          # \        V P                  P
                  4      ;_uu_ 4        WV,          ,          uuRRR4       #   + '       g   i     R# ; i)aD  Return ``a @ (b @ c)`` outside a caller's autocast region, for the (de)normalization chains of one dtype.

Autocast would run the products in half precision and return that dtype, up to 0.63 off for a float32 homography
in bfloat16 (#6601). TorchScript has no context managers; a scripted call keeps the caller's precision.
N)rN   rÅ  rÇ  r   rˆ  rQ   )rÌ   rÍ   rì  s   &&&rF   Ú_chain_outside_autocastrî  ’  sN   € ô ‡y�y×Ñ×ÒØ˜•E�{ÐÜ	˜AŸH™HŸM™M×	*Õ	*Ø˜•E�{÷ 
+×	*×	*Ó	*ús   ÁA5Á5B	c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# ©	r@   Údst_pix_trans_src_pixrB   Ú	dsize_srcztuple[int, int]Ú	dsize_dstÚalign_cornersrä   rC   rD   )rE   s   "rF   rG   rG   ž  sA   € ÷ F$ñ F$Ø'ðF$àðF$ð ðF$ð ð	F$ð
 ñF$rH   c                óä  € \        V \        P                  4      '       g   \        R\	        V 4       24      hV P
                  R9   d   V P                  RR R8X  g   \        RV P                   24      hV P                  pV\        P                  \        P                  39   d   V P                  4       p Vw  rVVw  rxV P                  4       '       g   V P                  4       '       d   V P                  MRp	\        VVV P                  V	VR7      P!                  V 4      p
\#        V
4      p\        VVV P                  V	VR7      P!                  V 4      p\%        WÀV4      pVP!                  V4      # )u’  Express a sourceâ†’destination pixel homography ``(B, 3, 3)`` in ``[-1, 1]`` coordinates.

``H_norm = normalize_homography(H, dsize_src, dsize_dst)`` takes homographies ``(B, 3, 3)``, or one ``(3, 3)``,
that map **source pixels to destination pixels**, and the ``(height, width)`` of both images, and returns
``N_dst @ H @ inv(N_src)`` ``(B, 3, 3)``: the same maps between normalized :math:`[-1, 1]` coordinates, with ``N``
from :func:`normal_transform_pixel`. Pass the ``align_corners`` of the sampling that will use the result: for a
``(B, 3, 3)`` ``H`` and ``H_norm = normalize_homography(H, img.shape[-2:], dsize, align_corners=a)``,
``homography_warp(img, torch.linalg.inv(H_norm), dsize, align_corners=a)`` samples what
``warp_perspective(img, H, dsize, align_corners=a)`` samples, since
:func:`~kornia.geometry.transform.warp_perspective` normalizes a pixel homography itself, except along a one-pixel
source axis with ``a=True``: there ``grid_sample`` lands every normalized position on that pixel, and only
``warp_perspective`` pads (`#6433 <https://github.com/kornia/kornia/issues/6433>`_). For the reverse, use
:func:`denormalize_homography`; for ``(B, 4, 4)`` voxel homographies, :func:`normalize_homography3d`.

Convention:
    - ``dsize_src`` drives the right factor and ``dsize_dst`` the left one:
      a ``+2`` pixel shift in ``x`` on a 5-wide image comes back as ``+1.0``
      (``+0.8`` with ``align_corners=False``).
      :func:`~kornia.geometry.conversions.denormalize_homography` computes
      the reverse ``inv(N_dst) @ H @ N_src``
    - a caller's autocast region does not change the product or the returned dtype, outside TorchScript. Under
      ``torch.compile`` on MPS it still does (torch ignores the nested guard there)
    - both ``dsize`` arguments are ``(height, width)``, while the matrix acts
      on ``(x, y, 1)`` column vectors
    - a ``(3, 3)`` or ``(B, 3, 3)`` matrix is accepted and batching is
      per sample; an unbatched input is returned as ``(1, 3, 3)``, and any
      other shape raises ``ValueError``
    - in eager mode ``inv(N_src)`` is a closed-form adjugate built from
      ``torch.linalg.cross``, so no ``cusolver`` is needed. A ``float16`` or
      ``bfloat16`` matrix is inverted in ``float32`` and the result cast back:
      the ``float16`` determinant of a large image's normalization matrix is
      subnormal or zero, and some backends lack a ``bfloat16`` ``cross`` kernel
      (MPS on torch 2.5.1). For any other dtype, a backend without a ``cross``
      kernel for it raises here
    - ``float16`` and ``bfloat16`` are computed in ``float32`` and rounded once to the input dtype

.. warning::
    An integer matrix is outside the contract and is not rejected: the
    normalization matrices are cast to it and truncated, and the call then
    fails inside torch or returns ``nan``, depending on the backend.

.. warning::
    The :math:`[-1, 1]` frames follow this function's own ``align_corners``,
    which defaults to ``True`` (corner-aligned) â€” **not** the ``False`` that
    :py:func:`torch.nn.functional.grid_sample` and
    :func:`~kornia.geometry.transform.homography_warp` default to. The
    value passed here must match the ``grid_sample`` call that consumes the
    result; a mismatch applies a spurious sub-pixel scale and shift.
    :func:`~kornia.geometry.transform.warp_perspective`,
    :func:`~kornia.geometry.transform.warp_affine` and
    :func:`~kornia.geometry.transform.homography_warp` forward their own
    flag, so they are consistent under both settings; see
    `#3904 <https://github.com/kornia/kornia/issues/3904>`_.
    :func:`~kornia.geometry.conversions.normalize_homography3d` still has
    no ``align_corners`` parameter and is corner-aligned unconditionally, so
    :func:`~kornia.geometry.transform.warp_affine3d` keeps this mismatch at
    ``align_corners=False``. Tracked in
    `#4503 <https://github.com/kornia/kornia/issues/4503>`_.

Args:
    dst_pix_trans_src_pix: homography/ies from source to destination to be
      normalized. ``(B, 3, 3)``, or an unbatched ``(3, 3)``, which
      is promoted to ``(1, 3, 3)``
    dsize_src: size of the source image (height, width).
    dsize_dst: size of the destination image (height, width).
    align_corners: which :py:func:`torch.nn.functional.grid_sample` convention the
      normalized :math:`[-1, 1]` coordinates follow, forwarded to
      :func:`normal_transform_pixel`. Must match the ``align_corners`` of the
      ``grid_sample`` call that ultimately consumes the result, otherwise the warp
      picks up a spurious sub-pixel scale and shift.

Returns:
    the normalized homography of shape ``(B, 3, 3)``.

See Also:
    - :func:`denormalize_homography`: the reverse, a normalized homography back to pixels.
    - :func:`normalize_homography3d`: the 3D form for ``(B, 4, 4)`` voxel homographies, always corner-aligned.
    - :func:`normal_transform_pixel`: the ``(1, 3, 3)`` normalization matrix ``N`` composed here.
    - :func:`~kornia.geometry.transform.warp_perspective`: warps by the pixel homography, normalizing it with
      this function.
    - :func:`~kornia.geometry.transform.homography_warp`: warps by the inverse of the result, a
      destinationâ†’source normalized homography.

rJ   Nú8Input dst_pix_trans_src_pix must be a Bx3x3 tensor. Got ©rˆ  rf   rô  rš   r™   rç   )rM   rN   rO   rP   rQ   Úndimr{   r|   rf   rg   rh   rc   r‘   r’   r)   rˆ  rm   r   rî  )rñ  rò  ró  rô  r—  Úsrc_hÚsrc_wÚdst_hÚdst_wÚnormalization_dtypeÚsrc_norm_trans_src_pixÚsrc_pix_trans_src_normÚdst_norm_trans_dst_pixÚ
homographys   &&&&          rF   r+   r+   ž  st  € ôt Ð+¬U¯\©\×:Ò:ÜÐ@ÄÐF[ÓA\Ð@]Ð^Ó_Ð_à!×&Ñ&¨&Ô0Ð5J×5PÑ5PÐQSÐQTÐ5UÐY_Ô5_ÜÐSÐTi×ToÑToÐSpÐqÓrÐrð
 &×+Ñ+€IØ”U—]‘]¤E§N¡NÐ3Ô3Ø 5× ;Ñ ;Ó =Ðð �L€EØ�L€Eð
 !×2Ñ2×4Ò4Ð8M×8XÑ8X×8ZÒ8Zð 	×#Ò#àð ô
 ,BØØØ$×+Ñ+Ø!Ø#ô,÷ 	�bÐ	Óð ô 6Ð6LÓMÐÜ+AØØØ$×+Ñ+Ø!Ø#ô,÷ 	�bÐ	Óð ô )Ð)?ÐXnÓo€JØ�=‰=˜Ó#Ð#rH   c               ó4   € V ^8„  d   QhRRRRRRRRRR	R
RRR/# )r@   r¹  rº  r»  rb   rc   rˆ  úOptional[torch.device]rf   úOptional[torch.dtype]rô  rä   rC   rB   rD   )rE   s   "rF   rG   rG   '	  sW   € ÷ Dñ DØðDàðDð 
ðDð #ð	Dð
 !ðDð ðDð ñDrH   c           	     ó4  € \         P                  P                  4       '       g!   V ^ 8:  g   V^ 8:  d   \        RV  RV R24      hVeÄ   V\         P                  \         P
                  \         P                  \         P                  \         P                  \         P                  \         P                  39  dT   \         P                  ! ^ VR7      pVP                  4       '       g&   VP                  4       '       g   \        RV R24      h\         P                  P                  4       '       gY   \         P                  P                  4       '       g5   \        4       '       g%   VR8w  d   \         P"                  ! R\$        ^R7       \         P                  P                  4       '       g7   \         P                  P                  4       '       EgÕ   \        4       '       EgÄ   V'       dJ   V^8X  d   R	MR
VR	,
          ,          pV ^8X  d   R	MR
V R	,
          ,          pV^8X  d   RMRp	V ^8X  d   RMRp
M2R
V,          pR
V ,          pR	V,
          V,          p	R	V ,
          V ,          p
\         P                  P                  4       '       d™   \         P&                  ! RW4R7      pVR,          p\         P(                  ! \         P(                  ! W·,          WËV	,          .4      \         P(                  ! WËV,          Wº,          .4      \         P(                  ! WÌV.4      .4      pEMhVeD   V\         P                  \         P                  \         P
                  \         P                  39   d   \+        VRV	.RWŠ.. RO.W4R7      pEM\         P,                  ! VRV	.RWŠ.. RO.W4R7      pEMäVe   TM\         P.                  ! 4       pV\         P
                  \         P                  39   d   TM\         P
                  p\         P0                  ! WVR7      p\         P0                  ! WVR7      p\         P&                  ! RW?R7      p\         P2                  ! RW?R7      pV'       dŒ   \         P4                  ! V^8H  VR
VR	,
          ,          4      p\         P4                  ! V^8H  VR
VR	,
          ,          4      p\         P4                  ! V^8H  VV) 4      p\         P4                  ! V^8H  VV) 4      pM2R
V,          pR
V,          pVV,
          V,          pVV,
          V,          p\         P(                  ! \         P(                  ! VVV.4      \         P(                  ! VVV.4      \         P(                  ! WÌV.4      .4      P7                  VR7      pVP9                  ^ 4      # )a�  Compute the ``(1, 3, 3)`` matrix that maps 2D pixel coordinates ``(x, y)`` to ``[-1, 1]``.

``N = normal_transform_pixel(height, width)`` returns a **single** matrix ``(1, 3, 3)``, never batched, that maps
the homogeneous pixel coordinates ``(x, y, 1)`` of a ``height`` by ``width`` image to :math:`[-1, 1]`: the
corner-aligned map of :func:`normalize_pixel_coordinates` by default, the half-pixel map with
``align_corners=False``. It is the ``N`` that :func:`normalize_homography` and :func:`denormalize_homography`
compose with a homography. To normalize points directly, use :func:`normalize_pixel_coordinates`; for
``(1, 4, 4)`` volume matrices, :func:`normal_transform_pixel3d`.

Convention:
    - ``x`` indexes columns and is scaled by ``width``, ``y`` indexes rows
      and is scaled by ``height``. The positional argument order is the
      other way round, ``(height, width)``
    - the mapping is **corner-aligned by default**: scale ``2 / (size - 1)``,
      offset ``-1``, so the pixel *centres* ``0`` and ``size - 1`` map to
      exactly ``-1`` and ``+1``. ``align_corners=False`` selects the
      half-pixel mapping instead; see the ``align_corners`` bullet below.
      ``normal_transform_pixel(4, 5)`` has rows
      ``[0.5, 0.0, -1.0]`` and ``[0.0, 0.6667, -1.0]``, and sends the pixels
      ``(0, 0)``, ``(4, 3)`` and ``(2, 1.5)`` to ``(-1, -1)``, ``(1, 1)``
      and ``(0, 0)``
    - for sizes ``>= 2`` this is the same map as
      :func:`~kornia.geometry.conversions.normalize_pixel_coordinates`. In
      ``float32``/``float64`` the two routes agree to the working dtype's
      rounding; in ``float16``/``bfloat16`` they can differ by about one
      ``eps``, because the matrix is applied through a matmul while the
      helper rounds elementwise
    - the convention is selected by ``align_corners`` (``True`` by
      default). ``False`` is the half-pixel mapping with scale ``2 / size``
      and offset ``1 / size - 1``, so that :math:`\pm 1` fall on the outer
      pixel *edges*. :func:`~kornia.geometry.conversions.normalize_homography`
      and :func:`~kornia.geometry.conversions.denormalize_homography` forward
      their own ``align_corners`` here, while
      :func:`~kornia.geometry.conversions.normal_transform_pixel3d` is still
      corner-aligned unconditionally; see the convention warning there
    - a singleton axis maps its only pixel to the centre of the normalized
      range: under ``align_corners=True`` with scale ``1`` and offset ``0``,
      which keeps the matrix invertible for homography composition. Zero
      and negative sizes raise ``ValueError``
    - with ``dtype=None`` the matrix takes ``torch.get_default_dtype()``
      (``float32`` unless the default was changed); an integer or bool
      ``dtype`` raises ``ValueError``, since the fractional scales would
      truncate to ``0``, for every size and even under ``disable_checks()``.
      Every floating and complex dtype is accepted

.. note::
    Legacy ``torch.jit.trace`` graphs assume positive runtime sizes because
    tracing cannot retain the Python ``ValueError`` validation. Eager,
    TorchScript, and ``torch.compile`` calls validate sizes.

.. deprecated:: 0.9.0
    ``eps`` no longer participates in the explicitly defined singleton-axis
    mapping. Passing a non-default value warns in eager mode; the parameter
    will be removed in a future breaking release.

Args:
    height: image height.
    width: image width.
    eps: deprecated compatibility parameter. It is ignored.
    device: device to place the result on.
    dtype: dtype of the result. ``None`` means ``torch.get_default_dtype()``.
    align_corners: which :py:func:`torch.nn.functional.grid_sample` convention to
      normalize to. ``True`` maps pixel centers :math:`[0, size-1]` to
      :math:`[-1, 1]`; ``False`` uses the half-pixel mapping
      :math:`x_{norm} = (2x + 1) / W - 1`, where :math:`\pm 1` are the outer pixel
      *edges*.

Returns:
    normalized transform with shape ``(1, 3, 3)``.

See Also:
    - :func:`normal_transform_pixel3d`: the 3D ``(1, 4, 4)`` matrix, always corner-aligned.
    - :func:`normalize_pixel_coordinates`: the same corner-aligned map applied to ``(*, 2)`` points.
    - :func:`normalize_homography`: conjugates a pixel homography with this matrix.

Example:
    >>> normal_transform_pixel(4, 5)
    tensor([[[ 0.5000,  0.0000, -1.0000],
             [ 0.0000,  0.6667, -1.0000],
             [ 0.0000,  0.0000,  1.0000]]])

r¾  r¿  rŒ   ©rf   ú4dtype must be a floating point or complex type. Got ç›+¡†›„=z<`eps` is deprecated and ignored by `normal_transform_pixel`.rÁ  rx   rþ   rŽ   rÃ  r•  rD   )rŽ   rŽ   rx   ©rN   rÅ  rÆ  r|   rg   rt  Úfloat64rh   Ú	complex32Ú	complex64Ú
complex128Úemptyr‘   r’   rÇ  r   rÈ  rÉ  rÊ  r�  r¬   r
   rA   rË  rÌ  r‰  rj   rm   rª   )r¹  r»  rb   rˆ  rf   rô  ÚproberÍ  r±  rJ  rK  rÎ  r¡  Útr_matr—  rv  rÑ  rÒ  rV  rÕ  rÖ  Útx_tÚty_ts   &&&&&&                 rF   r)   r)   '	  s8  € ôt �9‰9×Ñ×!Ò! v°¤{°e¸q´jÜÐIÈ&ÈÐQYÐZ_ÐY`Ð`aÐbÓcÐcð" Ò˜UÜ�‰Ü�‰Ü�‰Ü�‰Ü�‰Ü�‰Ü×Ñð+ô ô —’˜A UÔ+ˆØ×'Ñ'×)Ò)¨U×-=Ñ-=×-?Ò-?ÜÐSÐTYÐSZÐZ[Ð\Ó]Ð]Ü�9‰9×!Ñ!×#Ò#¬E¯I©I×,@Ñ,@×,BÒ,BÌ<Ï>Ê>Ð^aÐejÔ^jÜ�ŠÐTÔVcÐpqÕrä‡y�y×Ñ×Ò¬¯	©	×(<Ñ(<×(>Ó(>Ä|Ç~Ã~÷ Ø œ
‘¨¨u°s­{Õ(;ˆBØ !œ‘¨°¸µÕ)=ˆBØ œ
‘¨ˆBØ !œ‘¨‰Bð �u•ˆBØ�v•ˆBØ˜•+ Õ&ˆBØ˜•, &Õ(ˆBÜ�9‰9×!Ñ!×#Ò#ô —Z’Z ¨6Ô?ˆFØ˜C•<ˆDÜ—[’[ä—K’K ¥¨d¸RµKÐ @ÓAÜ—K’K °¥{°FµKÐ @ÓAÜ—K’K ¨VÐ 4Ó5ðóŠFð Š]˜e¬¯©´u·~±~ÄuÇ}Á}ÔV[×VcÑVcÐ'dÔdô &¨¨C° }°s¸B°mÂ_Ð&UÐ^dÔrŠFô —\’\ B¨¨R =°3¸°-ÂÐ"QÐZ`ÔnŠFð #Ò.‘E´E×4KÒ4KÓ4Mˆ	Ø"+´·±¼u¿}¹}Ð/MÔ"M‘YÔSX×S`ÑS`ˆ
Ü×%Ò% eÀ*ÔMˆÜ×&Ò& vÀJÔOˆÜ�jŠj˜ FÔ=ˆÜ�{Š{˜2 fÔ?ˆçô —;’;˜w¨!™|¨S°#¸À3½Õ2GÓHˆDÜ—;’;˜x¨1™}¨c°3¸(ÀS½.Õ3IÓJˆDÜ—;’;˜w¨!™|¨T°C°4Ó8ˆDÜ—;’;˜x¨1™}¨d°S°DÓ9‰Dð ˜•=ˆDØ˜•>ˆDØ˜'•M WÕ,ˆDØ˜(•N hÕ.ˆDô —’Ü�[Š[˜$  dÐ+Ó,¬e¯kªk¸4ÀÀtÐ:LÓ.MÌuÏ{Ê{Ð\`ÐhkÐ[lÓOmÐnó
ç
‰"�9ˆ"Ó
ð 	ð ×Ñ˜AÓÐrH   c               ó4   € V ^8„  d   QhRRRRRRRRRRR	R
RR/# )r@   rÙ  rº  r¹  r»  rb   rc   rˆ  r  rf   r  rC   rB   rD   )rE   s   "rF   rG   rG   î	  sW   € ÷ _ñ _Øð_àð_ð ð_ð 
ð	_ð
 #ð_ð !ð_ð ñ_rH   c                ó   € \         P                  P                  4       '       g+   V ^ 8:  g   V^ 8:  g   V^ 8:  d   \        RV  RV RV R24      hVeÄ   V\         P                  \         P
                  \         P                  \         P                  \         P                  \         P                  \         P                  39  dT   \         P                  ! ^ VR7      pVP                  4       '       g&   VP                  4       '       g   \        RV R24      h\         P                  P                  4       '       gY   \         P                  P                  4       '       g5   \        4       '       g%   VR8w  d   \         P"                  ! R\$        ^R	7       \         P                  P                  4       '       g7   \         P                  P                  4       '       Egó   \        4       '       Egâ   V^8X  d   R
MRVR
,
          ,          pV^8X  d   R
MRVR
,
          ,          pV ^8X  d   R
MRV R
,
          ,          p	V^8X  d   RMRp
V^8X  d   RMRpV ^8X  d   RMRp\         P                  P                  4       '       d¾   \         P&                  ! RWER7      pVR,          p\         P(                  ! \         P(                  ! W×,          WîWÚ,          .4      \         P(                  ! WíV,          WíV,          .4      \         P(                  ! WîWÙ,          WÜ,          .4      \         P(                  ! WîWí.4      .4      pEM¶VeD   V\         P                  \         P                  \         P
                  \         P                  39   d"   \+        VRRV
.RVRV.RRWœ.. RO.VVR7      pEMN\         P,                  ! VRRV
.RVRV.RRWœ.. RO.VVR7      pEM"Ve   TM\         P.                  ! 4       pV\         P
                  \         P                  39   d   TM\         P
                  p\         P0                  ! W$VR7      p\         P0                  ! WVR7      p\         P0                  ! WVR7      p\         P&                  ! RVVR7      p\         P2                  ! RVVR7      p\         P4                  ! V^8H  VRVR
,
          ,          4      p\         P4                  ! V^8H  VRVR
,
          ,          4      p\         P4                  ! V^8H  VRVR
,
          ,          4      p\         P4                  ! V^8H  VV) 4      p\         P4                  ! V^8H  VV) 4      p\         P4                  ! V^8H  VV) 4      p\         P(                  ! \         P(                  ! VWîV.4      \         P(                  ! VVVV.4      \         P(                  ! WîVV.4      \         P(                  ! WîVV.4      .4      P7                  VR7      pVP9                  ^ 4      # )uï  Compute the ``(1, 4, 4)`` matrix that maps 3D voxel coordinates ``(x, y, z)`` to ``[-1, 1]``.

``N = normal_transform_pixel3d(depth, height, width)`` returns a single matrix ``(1, 4, 4)`` that maps the
homogeneous voxel coordinates ``(x, y, z, 1)`` of a ``depth`` by ``height`` by ``width`` volume to
:math:`[-1, 1]`, corner-aligned, as :func:`normalize_homography3d` composes it. It has no ``align_corners``
parameter, so a homography normalized with it suits only ``align_corners=True`` sampling, a restriction the 3D
warps that use it inherit (`#4503 <https://github.com/kornia/kornia/issues/4503>`_). Its ``(x, y, z)`` order
differs from the ``(d, x, y)`` of :func:`normalize_pixel_coordinates3d`.

Convention:
    - the 3-D counterpart of
      :func:`~kornia.geometry.conversions.normal_transform_pixel`: same
      corner-aligned ``2 / (size - 1)`` scaling with offset ``-1``, same
      ``dtype=None`` / ``torch.get_default_dtype()`` rule, and likewise
      **never batched**. Singleton axes use the same invertible centre mapping, and zero or
      negative sizes raise ``ValueError``. Only the lines below differ
    - the result has shape ``(1, 4, 4)`` and acts on homogeneous
      ``(x, y, z, 1)`` column vectors with ``x`` scaled by ``width``, ``y``
      by ``height`` and ``z`` by ``depth``, while the positional argument
      order is ``(depth, height, width)``: ``normal_transform_pixel3d(9, 5, 3)``
      has diagonal ``[1.0, 0.5, 0.25]`` and sends ``(0, 0, 0)`` to
      ``(-1, -1, -1)`` and the far corner ``(2, 4, 8)`` to ``(1, 1, 1)``
    - that ``(x, y, z)`` slot order is a **permutation** of
      :func:`~kornia.geometry.conversions.normalize_pixel_coordinates3d`,
      which reads its input as ``(d, x, y)``. The two produce the same three
      numbers in different slots â€” with ``depth=9, height=5, width=3`` the
      point ``d=7, x=2, y=1`` gives ``[0.75, 1.0, -0.5]`` through the
      coordinate helper and ``[1.0, -0.5, 0.75]`` through this matrix â€” so a
      grid built for one silently permutes axes when fed to the other
    - an integer or bool ``dtype`` raises ``ValueError``, as in the 2-D
      function

.. note::
    Legacy ``torch.jit.trace`` graphs assume positive runtime sizes for the
    same reason as the 2-D counterpart.

.. deprecated:: 0.9.0
    ``eps`` is ignored and follows the deprecation policy of the 2-D
    counterpart.

Args:
    depth: image depth.
    height: image height.
    width: image width.
    eps: deprecated compatibility parameter. It is ignored.
    device: device to place the result on.
    dtype: dtype of the result. ``None`` means ``torch.get_default_dtype()``.

Returns:
    normalized transform with shape ``(1, 4, 4)``.

See Also:
    - :func:`normal_transform_pixel`: the 2D ``(1, 3, 3)`` matrix, which also has the ``align_corners=False``
      map.
    - :func:`normalize_homography3d`: conjugates a voxel homography with this matrix.
    - :func:`normalize_pixel_coordinates3d`: the same scaling applied to ``(*, 3)`` points in ``(d, x, y)``
      order.

Example:
    >>> normal_transform_pixel3d(2, 4, 5)
    tensor([[[ 0.5000,  0.0000,  0.0000, -1.0000],
             [ 0.0000,  0.6667,  0.0000, -1.0000],
             [ 0.0000,  0.0000,  2.0000, -1.0000],
             [ 0.0000,  0.0000,  0.0000,  1.0000]]])

rÜ  rÝ  r¿  rŒ   r  r  r  z>`eps` is deprecated and ignored by `normal_transform_pixel3d`.rÁ  rx   rþ   rŽ   rÃ  r•  rD   )rŽ   rŽ   rŽ   rx   r	  )rÙ  r¹  r»  rb   rˆ  rf   r  rÍ  r±  ÚszrJ  rK  rL  rÎ  r¡  r  r—  rv  rÑ  rÒ  rà  rV  rÕ  rÖ  Úsz_tr  r  Útz_ts   &&&&&&                      rF   r*   r*   î	  s¬  € ôT �9‰9×Ñ×!Ò! u°¤z°V¸q´[ÀEÈQÄJÜÐHÈÈÈyÐY_ÐX`Ð`hÐinÐhoÐopÐqÓrÐrð Ò˜UÜ�‰Ü�‰Ü�‰Ü�‰Ü�‰Ü�‰Ü×Ñð+ô ô —’˜A UÔ+ˆØ×'Ñ'×)Ò)¨U×-=Ñ-=×-?Ò-?ÜÐSÐTYÐSZÐZ[Ð\Ó]Ð]Ü�9‰9×!Ñ!×#Ò#¬E¯I©I×,@Ñ,@×,BÒ,BÌ<Ï>Ê>Ð^aÐejÔ^jÜ�ŠÐVÔXeÐrsÕtä‡y�y×Ñ×Ò¬¯	©	×(<Ñ(<×(>Ó(>Ä|Ç~Ã~à˜Q”J‰S C¨5°3­;Õ$7ˆØ˜a”K‰S S¨F°S­LÕ%9ˆØ˜Q”J‰S C¨5°3­;Õ$7ˆØ˜Q”J‰S DˆØ˜a”K‰S TˆØ˜Q”J‰S DˆÜ�9‰9×!Ñ!×#Ò#ä—Z’Z ¨6Ô?ˆFØ˜C•<ˆDÜ—[’[ä—K’K ¥¨d¸&½+Ð FÓGÜ—K’K °¥{°DÀ2½+Ð FÓGÜ—K’K ¨V­[¸&½+Ð FÓGÜ—K’K ¨TÐ :Ó;ð	óŠFð Š]˜e¬¯©´u·~±~ÄuÇ}Á}ÔV[×VcÑVcÐ'dÔdä%Ø�c˜3 Ð# c¨2¨s°BÐ%7¸#¸sÀBÐ9KÒMaÐbØØôŠFô —\’\Ø�c˜3 Ð# c¨2¨s°BÐ%7¸#¸sÀBÐ9KÒMaÐbØØôŠFð #Ò.‘E´E×4KÒ4KÓ4Mˆ	Ø"+´·±¼u¿}¹}Ð/MÔ"M‘YÔSX×S`ÑS`ˆ
Ü×%Ò% eÀ*ÔMˆÜ×&Ò& vÀJÔOˆÜ×%Ò% eÀ*ÔMˆÜ�jŠj˜ F°*Ô=ˆÜ�{Š{˜2 f°JÔ?ˆô �{Š{˜7 a™<¨¨c°W¸sµ]Õ.CÓDˆÜ�{Š{˜8 q™=¨#¨s°hÀµnÕ/EÓFˆÜ�{Š{˜7 a™<¨¨c°W¸sµ]Õ.CÓDˆÜ�{Š{˜7 a™<¨°¨tÓ4ˆÜ�{Š{˜8 q™=¨$°°Ó5ˆÜ�{Š{˜7 a™<¨°¨tÓ4ˆä—’ä—’˜T 4¨tÐ4Ó5Ü—’˜T 4¨¨tÐ4Ó5Ü—’˜T¨¨tÐ4Ó5Ü—’˜T¨¨sÐ3Ó4ð	ó
÷ ‰"�9ˆ"Ó
ð 	ð ×Ñ˜AÓÐrH   c               ó    € V ^8„  d   QhRRRR/# )r@   r_   rB   rC   rä   rD   )rE   s   "rF   rG   rG   �
  s   € ÷ 3ñ 3˜|ð 3°ñ 3rH   c                óR   € V P                  4       ;'       g    V P                  4       # )zlWhether ``x`` has a floating or complex dtype, the only dtypes in which a pixel normalization is invertible.)r‘   r’   )r_   s   &rF   Ú_is_floating_or_complexr  �
  s   € à×ÑÓ ×2Ð2 A§L¡L£NÐ2rH   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# rð  rD   )rE   s   "rF   rG   rG   •
  sA   € ÷ ^$ñ ^$Ø'ð^$àð^$ð ð^$ð ð	^$ð
 ñ^$rH   c                ó  € \        V \        P                  4      '       g   \        R\	        V 4       24      hV P
                  R9   d   V P                  RR R8X  g   \        RV P                   24      hV P                  pV\        P                  \        P                  39   d   V P                  4       p Vw  rVVw  rxV P                  4       '       g   V P                  4       '       d   V P                  MRp	\        VVV P                  V	VR7      P!                  V 4      p
\        VVV P                  V	VR7      P!                  V 4      p\#        V\%        V4      '       * R7      p\'        WÀV
4      pVP!                  V4      # )	u�	  Express a ``[-1, 1]`` homography ``(B, 3, 3)`` as a sourceâ†’destination pixel homography.

``H = denormalize_homography(H_norm, dsize_src, dsize_dst)`` is the inverse of :func:`normalize_homography`: it
takes homographies ``(B, 3, 3)``, or one ``(3, 3)``, from normalized :math:`[-1, 1]` source coordinates to
normalized destination coordinates, and the ``(height, width)`` of both images, and returns the sourceâ†’destination
pixel homographies ``inv(N_dst) @ H_norm @ N_src`` ``(B, 3, 3)``. Pass the ``align_corners`` that produced
``H_norm``. For ``(B, 4, 4)`` voxel homographies, use :func:`denormalize_homography3d`.

Convention:
    - the mirror of
      :func:`~kornia.geometry.conversions.normalize_homography`. The ``dsize``
      roles, the ``(x, y, 1)`` column vectors, per-sample batching, the
      ``align_corners``-selected frames and the shape guard are as
      documented there, including its integer-input warning
    - ``inv(N_dst)`` goes through ``torch.linalg.inv`` in eager mode (so
      ``cusolver`` on ``cuda``), not through the ``cross``-based adjugate
    - a caller's autocast region does not change the product or the returned dtype, outside TorchScript. Under
      ``torch.compile`` on MPS it still does (torch ignores the nested guard there)
    - the two functions invert each other to a small multiple of the
      working dtype's ``eps`` times the largest entry, not bitwise in
      general
    - ``float16`` and ``bfloat16`` are computed in ``float32`` and rounded once to the input dtype

Args:
    dst_pix_trans_src_pix: homography/ies from source to destination to be
      denormalized. ``(B, 3, 3)``, or an unbatched ``(3, 3)``,
      which is promoted to ``(1, 3, 3)``
    dsize_src: size of the source image (height, width).
    dsize_dst: size of the destination image (height, width).
    align_corners: which :py:func:`torch.nn.functional.grid_sample` convention the
      incoming normalized coordinates follow. Must match the value used to produce
      them, so that this function inverts :func:`normalize_homography`.

Returns:
    the denormalized homography of shape ``(B, 3, 3)``.

See Also:
    - :func:`normalize_homography`: the forward conversion, pixels to normalized coordinates.
    - :func:`denormalize_homography3d`: the 3D form for ``(B, 4, 4)`` homographies, always corner-aligned.
    - :func:`normal_transform_pixel`: the ``(1, 3, 3)`` normalization matrix ``N`` composed here.

rJ   Nrö  r÷  ©Úcheck_errorsrš   r™   rç   )rM   rN   rO   rP   rQ   rø  r{   r|   rf   rg   rh   rc   r‘   r’   r)   rˆ  rm   r   r  rî  )rñ  rò  ró  rô  r—  rù  rú  rû  rü  rý  rþ  r   Údst_denorm_trans_dst_pixr  s   &&&&          rF   r"   r"   •
  s…  € ô` Ð+¬U¯\©\×:Ò:ÜÐ@ÄÐF[ÓA\Ð@]Ð^Ó_Ð_à!×&Ñ&¨&Ô0Ð5J×5PÑ5PÐQSÐQTÐ5UÐY_Ô5_ÜÐSÐTi×ToÑToÐSpÐqÓrÐrð
 &×+Ñ+€IØ”U—]‘]¤E§N¡NÐ3Ô3Ø 5× ;Ñ ;Ó =Ðð �L€EØ�L€Eð
 !×2Ñ2×4Ò4Ð8M×8XÑ8X×8ZÒ8Zð 	×#Ò#àð ô
 ,BØØØ$×+Ñ+Ø!Ø#ô,÷ 	�bÐ	Óð ô ,BØØØ$×+Ñ+Ø!Ø#ô,÷ 	�bÐ	Óð ô  3ØÔ1HÐI_Ó1`Ô-`ô Ðô )Ð)AÐZpÓq€JØ�=‰=˜Ó#Ð#rH   c               ó(   € V ^8„  d   QhRRRRRRRR/# ©r@   rñ  rB   rò  ztuple[int, int, int]ró  rC   rD   )rE   s   "rF   rG   rG   ö
  s2   € ÷ ^$ñ ^$Ø'ð^$Ø4Hð^$ØUið^$àñ^$rH   c                ó   € \        V \        P                  4      '       g   \        R\	        V 4       24      hV P
                  R9   d   V P                  RR R8X  g   \        RV P                   24      hV P                  pV\        P                  \        P                  39   d   V P                  4       p Vw  rEpVw  rxp	V P                  4       '       g   V P                  4       '       d   V P                  MRp
\        WEW`P                  V
R7      P!                  V 4      p\#        V\%        V4      '       * R7      p\        WxW�P                  V
R7      P!                  V 4      p\'        WÐV4      pVP!                  V4      # )	uò  Express a sourceâ†’destination voxel homography ``(B, 4, 4)`` in ``[-1, 1]`` coordinates.

``H_norm = normalize_homography3d(H, dsize_src, dsize_dst)`` takes homographies ``(B, 4, 4)``, or one ``(4, 4)``,
that map **source voxels to destination voxels**, and the ``(depth, height, width)`` of both volumes, and returns
``N_dst @ H @ inv(N_src)`` ``(B, 4, 4)`` with ``N`` from :func:`normal_transform_pixel3d`. It has no
``align_corners`` parameter: the result suits only ``align_corners=True`` sampling
(`#4503 <https://github.com/kornia/kornia/issues/4503>`_). For the reverse, use :func:`denormalize_homography3d`;
for ``(B, 3, 3)`` pixel homographies, :func:`normalize_homography`.

Convention:
    - the 3-D counterpart of
      :func:`~kornia.geometry.conversions.normalize_homography`: same
      composition ``N_dst @ H @ inv(N_src)``, same source-to-destination
      direction re-expressed in normalized frames, same ``dsize_src`` on the
      right and ``dsize_dst`` on the left, and corner-aligned frames â€” with
      :func:`~kornia.geometry.conversions.normal_transform_pixel3d` in place
      of the 2-D helper. It is
      **not** the 2-D function with wider matrices, though: the shapes and
      â€” least visibly â€” the inversion routine differ, as the bullets below
      record
    - it inverts ``N_src`` with ``torch.linalg.inv`` (so ``cusolver`` on
      ``cuda``, and a ``float32`` upcast for ``float16``/``bfloat16``),
      where the 2-D function uses a closed-form adjugate, with the same
      ``float32`` upcast; the 2-D and 3-D routes therefore need not agree bitwise
    - the matrices are ``(B, 4, 4)`` and act on ``(x, y, z, 1)`` column
      vectors, while both ``dsize`` arguments are
      ``(depth, height, width)`` triples
    - :func:`~kornia.geometry.conversions.denormalize_homography3d`
      computes the reverse ``inv(N_dst) @ H @ N_src``
    - a caller's autocast region does not change the product or the returned dtype, outside TorchScript. Under
      ``torch.compile`` on MPS it still does (torch ignores the nested guard there)
    - the shape guard is the 2-D function's for 4x4 matrices: ``(4, 4)``
      (returned as ``(1, 4, 4)``) or ``(B, 4, 4)``, anything else raises
      ``ValueError``
    - ``float16`` and ``bfloat16`` are computed in ``float32`` and rounded once to the input dtype

Args:
    dst_pix_trans_src_pix: homography/ies from source to destination to be
      normalized. ``(B, 4, 4)``, or an unbatched ``(4, 4)``, which
      is promoted to ``(1, 4, 4)``
    dsize_src: size of the source image (depth, height, width).
    dsize_dst: size of the destination image (depth, height, width).

Returns:
    the normalized homography.

Shape:
    Output: ``(B, 4, 4)``

See Also:
    - :func:`denormalize_homography3d`: the reverse, a normalized voxel homography back to voxels.
    - :func:`normalize_homography`: the 2D form for ``(B, 3, 3)`` pixel homographies, with ``align_corners``.
    - :func:`normal_transform_pixel3d`: the ``(1, 4, 4)`` normalization matrix ``N`` composed here.

rJ   Nú8Input dst_pix_trans_src_pix must be a Bx4x4 tensor. Got rÃ  r  rš   r™   ©r    r    )rM   rN   rO   rP   rQ   rø  r{   r|   rf   rg   rh   rc   r‘   r’   r*   rˆ  rm   r   r  rî  )rñ  rò  ró  r—  Úsrc_drù  rú  Údst_drû  rü  rý  rþ  rÿ  r   r  s   &&&            rF   r,   r,   ö
  sy  € ôt Ð+¬U¯\©\×:Ò:ÜÐ@ÄÐF[ÓA\Ð@]Ð^Ó_Ð_à!×&Ñ&¨&Ô0Ð5J×5PÑ5PÐQSÐQTÐ5UÐY_Ô5_ÜÐSÐTi×ToÑToÐSpÐqÓrÐrð
 &×+Ñ+€IØ”U—]‘]¤E§N¡NÐ3Ô3Ø 5× ;Ñ ;Ó =Ðð $Ñ€E�%Ø#Ñ€E�%ð !×2Ñ2×4Ò4Ð8M×8XÑ8X×8ZÒ8Zð 	×#Ò#àð ô
 ,DØ�e×$@Ñ$@ÐH[ô,ç�bÐ	Óð ô 1ØÔ1HÐI_Ó1`Ô-`ôÐô ,DØ�e×$@Ñ$@ÐH[ô,ç�bÐ	Óð ô )Ð)?ÐXnÓo€JØ�=‰=˜Ó#Ð#rH   c               ó(   € V ^8„  d   QhRRRRRRRR/# r!  rD   )rE   s   "rF   rG   rG   W  s2   € ÷ d$ñ d$Ø'ðd$Ø4Hðd$ØUiðd$àñd$rH   c                ó  € \        V \        P                  4      '       g   \        R\	        V 4       24      hV P                  4       '       g&   \        RV P                   R2V P                  R7      hV P                  R	9   d   V P                  R
R R8X  g   \        RV P                   24      hV P                  pV\        P                  \        P                  39   d   V P                  4       p Vw  rEpVw  rxp	V P                  p
\        WEW`P                  V
R7      P!                  V 4      p\        WxW�P                  V
R7      P!                  V 4      p\#        V\%        V4      '       * R7      p\'        WÐV4      pVP!                  V4      # )uA  Express a ``[-1, 1]`` homography ``(B, 4, 4)`` as a sourceâ†’destination voxel homography.

``H = denormalize_homography3d(H_norm, dsize_src, dsize_dst)`` is the inverse of :func:`normalize_homography3d`: it
takes real floating homographies ``(B, 4, 4)``, or one ``(4, 4)``, from normalized :math:`[-1, 1]` source
coordinates to normalized destination coordinates, and the ``(depth, height, width)`` of both volumes, and returns
the sourceâ†’destination voxel homographies ``inv(N_dst) @ H_norm @ N_src`` ``(B, 4, 4)``, always corner-aligned
(`#4503 <https://github.com/kornia/kornia/issues/4503>`_). For ``(B, 3, 3)`` pixel homographies, use
:func:`denormalize_homography`.

Convention:
    - the mirror of
      :func:`~kornia.geometry.conversions.normalize_homography3d`. The ``(depth, height, width)``
      ``dsize`` roles, the ``(x, y, z, 1)`` column vectors, per-sample
      batching, the corner-aligned frames and the shape guard are as
      documented there
    - ``inv(N_dst)`` goes through ``torch.linalg.inv`` (so ``cusolver`` on
      ``cuda``, and a ``float32`` upcast for ``float16``/``bfloat16``), the
      same routine :func:`~kornia.geometry.conversions.normalize_homography3d`
      uses for ``inv(N_src)``
    - a caller's autocast region does not change the product or the returned dtype, outside TorchScript. Under
      ``torch.compile`` on MPS it still does (torch ignores the nested guard there)
    - the two functions invert each other to a small multiple of the
      working dtype's ``eps`` times the largest entry, not bitwise in
      general
    - only real floating point homographies are accepted (``float16``,
      ``bfloat16``, ``float32``, ``float64``): an integer, bool or complex
      ``dst_pix_trans_src_pix`` raises ``TypeCheckError`` (also a
      ``TypeError``) instead of being promoted, so cast it first. Integers
      would truncate the normalization matrices (the 2-D function still
      does), and
      complex dtypes would be inverted in ``float32``
      (``_torch_inverse_cast``), losing ``complex128`` precision
    - ``float16`` and ``bfloat16`` are computed in ``float32`` and rounded once to the input dtype

Args:
    dst_pix_trans_src_pix: homography/ies from source to destination to be
      denormalized. ``(B, 4, 4)``, or an unbatched ``(4, 4)``, which
      is promoted to ``(1, 4, 4)``
    dsize_src: size of the source image (depth, height, width).
    dsize_dst: size of the destination image (depth, height, width).

Returns:
    the denormalized homography.

Shape:
    Output: ``(B, 4, 4)``

See Also:
    - :func:`normalize_homography3d`: the forward conversion, voxels to normalized coordinates.
    - :func:`denormalize_homography`: the 2D form for ``(B, 3, 3)`` homographies, with ``align_corners``.
    - :func:`normal_transform_pixel3d`: the ``(1, 4, 4)`` normalization matrix ``N`` composed here.

rJ   zLInput dst_pix_trans_src_pix must be a real floating point tensor. Got dtype rŒ   ©Úactual_typeNr#  rÃ  r  rš   r™   r$  )rM   rN   rO   rP   rQ   r‘   r	   rf   rø  r{   r|   rg   rh   rc   r*   rˆ  rm   r   r  rî  )rñ  rò  ró  r—  r%  rù  rú  r&  rû  rü  rý  rþ  r   Údst_pix_trans_dst_normr  s   &&&            rF   r#   r#   W  s�  € ôp Ð+¬U¯\©\×:Ò:ÜÐ@ÄÐF[ÓA\Ð@]Ð^Ó_Ð_ð !×2Ñ2×4Ò4ÜðØ.×4Ñ4Ð5°Qð8à-×3Ñ3ô
ð 	
ð "×&Ñ&¨&Ô0Ð5J×5PÑ5PÐQSÐQTÐ5UÐY_Ô5_ÜÐSÐTi×ToÑToÐSpÐqÓrÐrð
 &×+Ñ+€IØ”U—]‘]¤E§N¡NÐ3Ô3Ø 5× ;Ñ ;Ó =Ðð $Ñ€E�%Ø#Ñ€E�%à/×5Ñ5ÐÜ+CØ�e×$@Ñ$@ÐH[ô,ç�bÐ	Óð ô ,DØ�e×$@Ñ$@ÐH[ô,ç�bÐ	Óð ô
 1ØÔ1HÐI_Ó1`Ô-`ôÐô )Ð)?ÐXnÓo€JØ�=‰=˜Ó#Ð#rH   c               ó$   € V ^8„  d   QhRRRRRR/# )r@   Úpoint_2drB   Úcamera_matrixrC   rD   )rE   s   "rF   rG   rG   ¾  s"   € ÷ =$ñ =$¨|ð =$ÈLð =$Ð]iñ =$rH   c                ó:  € \        V RR.4       \        V. RO4       VR,          pVR,          P                  RRR7      p\        VP                  4      \        V P                  4      8  d"   VP	                  R4      VP	                  R4      r2W,
          V,          # )	aK
  Convert pixel coordinates (u, v) to normalized camera coordinates (x, y) with the intrinsics K.

``xy = normalize_points_with_intrinsics(uv, K)`` takes pixel points ``(*, 2)`` and pinhole intrinsics
``(*, 3, 3)`` and returns the normalized camera coordinates ``((u - cx) / fx, (v - cy) / fy)``, ``(*, 2)``: the
point where the ray of each pixel meets the ``z = 1`` plane, the form an essential matrix relates. A
``(B, 3, 3)`` ``K`` pairs camera ``b`` with ``uv[b]`` for ``(B, 2)`` and ``(B, N, 2)`` points; for
``(B, H, W, 2)`` points pass ``K[:, None, None]``, since the cameras otherwise line up with the ``H`` axis
(`#6409 <https://github.com/kornia/kornia/issues/6409>`_). For the reverse, use
:func:`denormalize_points_with_intrinsics`; for 3D points at a depth,
:func:`~kornia.geometry.camera.perspective.unproject_points`.

Convention:
    See :doc:`camera and world conventions </get-started/camera-conventions>` for the camera intrinsics and
    pixel-centre conventions used by these coordinates.

    - ``point_2d`` is ``(*, 2)`` in pixel ``(u, v)`` order and
      ``camera_matrix`` is a row-major pinhole ``(*, 3, 3)`` with
      ``fx = K[0, 0]``, ``fy = K[1, 1]``, ``cx = K[0, 2]``, ``cy = K[1, 2]``
    - with ``K = [[100., 0., 320.], [0., 200., 240.], [0., 0., 1.]]`` the
      pixel ``(420., 440.)`` maps to ``(1., 1.)``
    - the skew entry ``K[0, 1]`` is **ignored**; only the two diagonal
      entries and the ``[:2, 2]`` column are read. This is a design choice:
      kornia's functional pinhole model is zero-skew, like OpenCV's, and
      :func:`~kornia.geometry.camera.perspective.project_points` reads
      ``K`` the same way. For a skewed ``K`` apply ``inv(K)`` directly

Args:
    point_2d: tensor containing the 2d points in the image pixel coordinates. The shape of the tensor can be
              ``(*, 2)``.
    camera_matrix: tensor containing the intrinsics camera matrix. The tensor shape must be ``(*, 3, 3)``.

Returns:
    tensor of normalized camera coordinates :math:`(x, y)` with shape ``(*, 2)``, the leading dimensions
    broadcast from both inputs.

See Also:
    - :func:`denormalize_points_with_intrinsics`: the reverse, normalized camera coordinates back to pixels.
    - :func:`~kornia.geometry.camera.perspective.unproject_points`: the 3D camera-frame points of pixels at a
      given depth.
    - :func:`normalize_pixel_coordinates`: a different normalization, to :math:`[-1, 1]` by the image size.

Example:
    >>> _ = torch.manual_seed(0)
    >>> X = torch.rand(1, 2)
    >>> K = torch.eye(3)[None]
    >>> normalize_points_with_intrinsics(X, K)
    tensor([[0.4963, 0.7682]])

Ú*Ú2©Údim1Údim2©r0  Ú3r6  ©.ºNr@   Nr@   ©.r8  r8  r™   ry   ©r   Údiagonalrz   r{   rª   )r-  r.  ÚcxcyÚfxfys   &&  rF   r/   r/   ¾  s‚   € ôd �x # s Ô,Ü�}¢oÔ6ð ˜Õ$€DØ˜Õ%×.Ñ.°B¸RÐ.Ó@€DÜ
ˆ4�:‰:ƒœ˜XŸ^™^Ó,Ô,Ø—^‘^ BÓ'¨¯©¸Ó);ˆdØ�O˜tÕ#Ð#rH   c               ó$   € V ^8„  d   QhRRRRRR/# )r@   Úpoint_2d_normrB   r.  rC   rD   )rE   s   "rF   rG   rG   þ  s#   € ÷ 1'ñ 1'°lð 1'ÐS_ð 1'Ðdpñ 1'rH   c                ó:  € \        V RR.4       \        V. RO4       VR,          P                  RRR7      pVR,          p\        VP                  4      \        V P                  4      8  d"   VP	                  R4      VP	                  R4      r2W,          V,           # )	a(  Convert normalized camera coordinates (x, y) to pixel coordinates (u, v) with the intrinsics K.

``uv = denormalize_points_with_intrinsics(xy, K)`` is the inverse of :func:`normalize_points_with_intrinsics`: it
takes normalized camera coordinates ``(*, 2)``, points on the ``z = 1`` plane, and pinhole intrinsics
``(*, 3, 3)``, and returns the pixels ``(x * fx + cx, y * fy + cy)``, ``(*, 2)``. ``K`` broadcasts against the
points as in that function: for ``(B, H, W, 2)`` points pass ``K[:, None, None]``
(`#6409 <https://github.com/kornia/kornia/issues/6409>`_). To project 3D camera-frame points instead, use
:func:`~kornia.geometry.camera.perspective.project_points`.

Convention:
    See :doc:`camera and world conventions </get-started/camera-conventions>` for the camera intrinsics and
    pixel-centre conventions used by these coordinates.

    - the ``K`` layout is documented on
      :func:`~kornia.geometry.conversions.normalize_points_with_intrinsics`,
      and the skew entry ``K[0, 1]`` is ignored here too

Args:
    point_2d_norm: tensor containing the 2d points in normalized camera coordinates. The shape of the tensor can
                   be ``(*, 2)``.
    camera_matrix: tensor containing the intrinsics camera matrix. The tensor shape must be ``(*, 3, 3)``.

Returns:
    tensor of :math:`(u, v)` pixel coordinates with shape ``(*, 2)``, the leading dimensions broadcast from both
    inputs.

See Also:
    - :func:`normalize_points_with_intrinsics`: the forward conversion, pixels to normalized camera coordinates.
    - :func:`~kornia.geometry.camera.perspective.project_points`: the pixels of 3D camera-frame points.

Example:
    >>> _ = torch.manual_seed(0)
    >>> X = torch.rand(1, 2)
    >>> K = torch.eye(3)[None]
    >>> denormalize_points_with_intrinsics(X, K)
    tensor([[0.4963, 0.7682]])

r0  r1  r2  r5  r9  r™   ry   r7  r:  )r?  r.  r=  r<  s   &&  rF   r&   r&   þ  s…   € ôN �} s¨C jÔ1Ü�}¢oÔ6ð
 ˜Õ%×.Ñ.°B¸RÐ.Ó@€DØ˜Õ$€DÜ
ˆ4�:‰:ƒœ˜]×0Ñ0Ó1Ô1Ø—^‘^ BÓ'¨¯©¸Ó);ˆdØÕ $Õ&Ð&rH   c               ó$   € V ^8„  d   QhRRRRRR/# )r@   ÚRrB   ÚtrC   rD   )rE   s   "rF   rG   rG   2  s&   € ÷ F4ñ F4�|ð F4¨ð F4¸ñ F4rH   c                ó$  € \        V . RO4       \        V. RO4       \        WR4       \        P                  ! W.^R7      pVP	                  4       '       g0   VP                  4       '       g   \        RVP                   R24      h\        V4      # )u°  Pack rotations ``(B, 3, 3)`` and translations ``(B, 3, 1)`` into ``(B, 4, 4)`` pose matrices.

``M = Rt_to_matrix4x4(R, t)`` places each rotation ``(B, 3, 3)`` in the top-left block and its translation
``(B, 3, 1)`` in the last column of a ``(B, 4, 4)`` matrix with the bottom row ``[0, 0, 0, 1]``, so that ``M``
maps ``x`` to ``R @ x + t``. It checks neither that ``R`` is a rotation nor which way the pose goes:
camera-to-world and world-to-camera poses pack the same way. For the reverse, use :func:`matrix4x4_to_Rt`; for the
``(*, 3, 4)`` matrix ``[R | t]`` without the bottom row,
:func:`~kornia.geometry.transform.projection_from_Rt`.

Convention:
    - ``t`` goes in the **last column** and the appended bottom row is
      ``[0, 0, 0, 1]``, so the result acts on homogeneous column vectors as
      ``x_out = R @ x_in + t``: with ``t = (1, 2, 3)``,
      ``M @ (0, 0, 0, 1)`` returns ``t`` itself and ``M @ (1, 0, 0, 1)``
      returns ``R[:, 0] + t``
    - the function is **frame-agnostic** â€” it packs whatever ``(R, t)`` it
      is handed and does not check that ``R`` is a rotation. Under the
      camera-to-world reading the rest of this family uses (see
      :func:`~kornia.geometry.conversions.camtoworld_to_worldtocam_Rt`),
      ``t`` is the **camera centre in world coordinates**, whereas the
      world-to-camera form's ``-R^T t`` is a translation and not a centre.
      Which of the two you are packing is your bookkeeping, not this
      function's
    - shapes are strict: exactly ``(B, 3, 3)`` and ``(B, 3, 1)``.
      An unbatched ``(3, 3)``, a ``(B, 3)`` translation, a ``(B, 1, 3)``
      translation and extra leading dimensions each raise ``ShapeError``;
      ``R`` and ``t`` must also carry the same batch size: a mismatched
      pair raises ``ShapeError`` too
    - :func:`~kornia.geometry.conversions.matrix4x4_to_Rt` is the inverse:
      ``Rt -> 4x4 -> Rt`` is bitwise, while ``4x4 -> Rt -> 4x4`` is bitwise
      only when the bottom row is already ``[0, 0, 0, 1]``, because
      :func:`~kornia.geometry.conversions.matrix4x4_to_Rt` drops it

Note:
    ``R`` and ``t`` must promote to a floating point or complex dtype;
    an integer or boolean pair raises ``ValueError`` naming its dtype.
    Mixed integer/floating inputs keep torch's promotion. The ``_4x4``
    frame functions and ``camtoworld_to_worldtocam_Rt`` only transpose,
    negate and multiply, so they accept integer input as well.

Args:
    R: Rotation matrix, ``(B, 3, 3)``.
    t: Translation matrix ``(B, 3, 1)``.

Returns:
    the extrinsics ``(B, 4, 4)``.

See Also:
    - :func:`matrix4x4_to_Rt`: the reverse, splitting a ``(B, 4, 4)`` matrix into ``R`` and ``t``.
    - :func:`camtoworld_to_worldtocam_Rt`: inverts a rigid ``(R, t)`` pose before or after packing.
    - :func:`~kornia.geometry.transform.projection_from_Rt`: the ``(*, 3, 4)`` matrix ``[R | t]``, without the
      bottom row.
    - :func:`convert_affinematrix_to_homography3d`: the same ``(B, 4, 4)`` from a ``(B, 3, 4)`` matrix.

Example:
    >>> R, t = torch.eye(3)[None], torch.ones(3).reshape(1, 3, 1)
    >>> Rt_to_matrix4x4(R, t)
    tensor([[[1., 0., 0., 1.],
             [0., 1., 0., 1.],
             [0., 0., 1., 1.],
             [0., 0., 0., 1.]]])

r   r„   z?R and t must promote to a floating point or complex dtype. Got rŒ   ©ÚBr6  r6  ©rF  r6  Ú1)	r   Ú_check_Rt_same_batchrN   r‡   r‘   r’   r|   rf   r   )rB  rC  ÚRts   && rF   r   r   2  sx   € ô@ �qš/Ô*Ü�qš/Ô*Ü˜Ð0Ô1Ü	�Š�A�6˜qÔ	!€BØ×Ñ×!Ò!¨"¯-©-¯/ª/ÜÐZÐ[]×[cÑ[cÐZdÐdeÐfÓgÐgÜ/°Ó3Ð3rH   c               ó    € V ^8„  d   QhRRRR/# )r@   Ú
extrinsicsrB   rC   rZ   rD   )rE   s   "rF   rG   rG   {  s   € ÷ .ñ . ð .Ð1Rñ .rH   c                óF   € \        V . RO4       V R,          V R,          r!W3# )a  Split ``(B, 4, 4)`` pose matrices into rotation ``(B, 3, 3)`` and translation ``(B, 3, 1)`` views.

``R, t = matrix4x4_to_Rt(M)`` returns the top-left ``(B, 3, 3)`` block and the first three rows ``(B, 3, 1)`` of
the last column of each ``(B, 4, 4)`` matrix, as views of ``M``; the bottom row is ignored. It is the inverse of
:func:`Rt_to_matrix4x4`.

Convention:
    - the inverse of
      :func:`~kornia.geometry.conversions.Rt_to_matrix4x4`, with the same
      layout and the same frame-agnosticism. Only the lines below differ
    - the input shape is strictly ``(B, 4, 4)``; an unbatched ``(4, 4)``,
      a ``(B, 3, 3)`` and extra leading dimensions each raise ``ShapeError``
    - the **bottom row is ignored**: a projective 4x4 is silently truncated
      to its rigid part, so replacing the bottom row with ``[9, 9, 9, 9]``
      leaves ``R`` and ``t`` bit-identical, and re-packing through
      :func:`~kornia.geometry.conversions.Rt_to_matrix4x4` restores the
      canonical ``[0, 0, 0, 1]`` rather than what was passed in
    - the returned ``R`` and ``t`` are **views** of ``extrinsics``, not
      copies: ``R.mul_(0.)`` zeroes the caller's rotation block in place.
      Clone before mutating either output

Args:
    extrinsics: pose matrix ``(B, 4, 4)``.

Returns:
    R: Rotation matrix, ``(B, 3, 3)``.
    t: Translation matrix ``(B, 3, 1)``.

See Also:
    - :func:`Rt_to_matrix4x4`: the reverse, packing ``R`` and ``t`` with the bottom row ``[0, 0, 0, 1]``.
    - :func:`~kornia.geometry.linalg.inverse_transformation`: the rigid inverse of the ``(B, 4, 4)`` matrix
      itself.

Example:
    >>> ext = torch.eye(4)[None]
    >>> matrix4x4_to_Rt(ext)
    (tensor([[[1., 0., 0.],
             [0., 1., 0.],
             [0., 0., 1.]]]), tensor([[[0.],
             [0.],
             [0.]]]))

©rF  Ú4rO  )ºNNNr\  r\  )rP  r\  :r›   NN)r   )rL  rB  rC  s   &  rF   r(   r(   {  s'   € ôX �z¢?Ô3Ø�iÕ  *¨YÕ"7€qØˆ4€KrH   c               ó$   € V ^8„  d   QhRRRRRR/# )r@   rÌ   rB   rÍ   rC   rD   )rE   s   "rF   rG   rG   ¬  s!   € ÷ ñ ˜Lð ¨\ð ¸lñ rH   c                ó*  € V P                   VP                   8X  dò   V P                   \        P                  \        P                  \        P                  \        P
                  \        P                  39   d–   V P                  4       ^8”  d�   VP                  4       ^8”  dl   V P                  R,          VP                  R,          8X  dC   V P                  R4      VP                  R4      ,          P                  RV P                   R7      # W,          # )r†   r  ry   r™   éýÿÿÿ)rf   rN   Úuint8Úint8Úint16Úint32Úint64r…   r{   rª   rÖ   )rÌ   rÍ   s   &&rF   Ú_integer_safe_matmulrY  ¬  s§   € ð 	
�‰�1—7‘7ÔØ�G‰GœŸ™¤U§Z¡Z´·±¼e¿k¹kÌ5Ï;É;ÐWÔWØ�E‰E‹G�aŒKØ�E‰E‹G�aŒKØ�G‰G�B�K˜1Ÿ7™7 2�;Ô&à—‘˜B“ !§+¡+¨b£/Õ1×6Ñ6°rÀÇÁÐ6ÓIÐIØ�5€LrH   c               ó    € V ^8„  d   QhRRRR/# )r@   Úextrinsics_graphicsrB   rC   rD   )rE   s   "rF   rG   rG   ¿  s"   € ÷ N@ñ N@¸<ð N@ÈLñ N@rH   c                ó¨   € \        V . RO4       \        P                  ! . RO. RO. RO. RO..V P                  V P                  R7      p\        W4      # )uÆ  Convert ``(B, 4, 4)`` camera-to-world poses from graphics (OpenGL) to vision (OpenCV) camera axes.

``M_vision = camtoworld_graphics_to_vision_4x4(M_graphics)`` takes camera-to-world poses ``(B, 4, 4)`` whose
camera axes follow the graphics convention, ``[+x, +y, +z] == [right, up, backwards]``, and returns them with the
vision camera axes, ``[right, down, forwards]``: it negates the camera ``y`` and ``z`` axes, the second and third
columns of the rotation block, and leaves the camera centre unchanged. A world-to-camera pose needs the flip on the
other side, which this function does not make: invert it to camera-to-world with
:func:`~kornia.geometry.linalg.inverse_transformation`, convert, and invert the result back. For a pose given as
``(R, t)``, use :func:`camtoworld_graphics_to_vision_Rt`.

Convention:
    See :doc:`camera and world conventions </get-started/camera-conventions>` for the graphics/vision camera
    frames and camera-to-world extrinsics convention.

    - the input is a **camera-to-world** pose ``(B, 4, 4)``: its 3x3
      block maps camera axes into the world and its last column is the
      camera centre in world coordinates
    - the operation is exactly ``extrinsics @ diag(1, -1, -1, 1)`` â€” a
      **right** multiplication, i.e. a change of the **camera-side** basis.
      The translation column is untouched. Left-multiplying by the same
      matrix would negate two of its components instead, and feeding a
      *world-to-camera* matrix in flips the wrong side and leaves the
      translation in the old frame: a silent error, not an exception
    - graphics (OpenGL) camera frame: ``+x`` right, ``+y`` up, ``+z``
      backwards â€” the camera looks down ``-z``. Vision (OpenCV) camera
      frame: ``+x`` right, ``+y`` down, ``+z`` forwards â€” the camera looks
      down ``+z``. On the identity camera-to-world pose, camera ``+y``
      maps to world ``+y`` before the conversion and to world ``-y`` after
      it, and likewise for ``+z``
    - the flip **preserves the determinant** of the 3x3 block, and with it
      the handedness: ``diag(1, -1, -1)`` has determinant ``+1``, so a
      proper rotation stays proper. Nothing here checks that the input is a
      rotation
    - the flip is an **involution**, and all four graphics/vision frame
      functions compute the identical map:
      :func:`~kornia.geometry.conversions.camtoworld_vision_to_graphics_4x4`
      returns the same matrix as this one on the same input, and applying
      either twice returns the input. The two names document the caller's
      intent, not different arithmetic
    - the shape is strictly ``(B, 4, 4)``; the ``_Rt`` variants take and
      return ``(B, 3, 3)`` and ``(B, 3, 1)`` and agree with this
      path bitwise

.. warning::
    Integer input is not guarded: this function returns ``int64`` for an
    ``int64`` matrix on every device, CUDA (which has no integer matmul)
    included, while
    :func:`~kornia.geometry.conversions.camtoworld_graphics_to_vision_Rt`
    raises ``ValueError`` naming the unsupported dtype; see
    :func:`~kornia.geometry.conversions.Rt_to_matrix4x4`.

Args:
    extrinsics_graphics: pose matrix ``(B, 4, 4)``.

Returns:
    extrinsics: pose matrix ``(B, 4, 4)``.

See Also:
    - :func:`camtoworld_vision_to_graphics_4x4`: the reverse direction, the same arithmetic.
    - :func:`camtoworld_graphics_to_vision_Rt`: the same conversion for a pose given as ``(R, t)``.
    - :func:`camtoworld_to_worldtocam_Rt`: inverts a camera-to-world pose to world-to-camera.

Example:
    >>> ext = torch.eye(4)[None]
    >>> camtoworld_graphics_to_vision_4x4(ext)
    tensor([[[ 1.,  0.,  0.,  0.],
             [ 0., -1.,  0.,  0.],
             [ 0.,  0., -1.,  0.],
             [ 0.,  0.,  0.,  1.]]])

©rf   rˆ  rN  ©r†   r�   r�   r�   ©r�   ry   r�   r�   ©r�   r�   ry   r�   ©r�   r�   r�   rx   ©r   rN   rA   rf   rˆ  rY  )r[  Ú	invert_yzs   & rF   r   r   ¿  sM   € ôP Ð*ªOÔ<Ü—’Ú
š¢}²nÐ	EÐFØ!×'Ñ'Ø"×)Ñ)ô€Iô
  Ð 3Ó?Ð?rH   c               ó$   € V ^8„  d   QhRRRRRR/# ©r@   rB  rB   rC  rC   rZ   rD   )rE   s   "rF   rG   rG     s"   € ÷ 2#ñ 2#¨ð 2#¸ð 2#ÐJkñ 2#rH   c                ó�   € \        V . RO4       \        V. RO4       \        WR4       \        \        W4      4      p\	        V4      # )a  Convert camera-to-world ``(R, t)`` poses from graphics (OpenGL) to vision (OpenCV) camera axes.

``R_vision, t = camtoworld_graphics_to_vision_Rt(R, t)`` is :func:`camtoworld_graphics_to_vision_4x4` for a
camera-to-world pose given as rotations ``(B, 3, 3)`` and camera centres ``(B, 3, 1)``: it negates the camera
``y`` and ``z`` axes, the second and third columns of ``R``, to turn graphics camera axes
``[right, up, backwards]`` into vision ones ``[right, down, forwards]``, and returns ``t`` unchanged.

Convention:
    See :doc:`camera and world conventions </get-started/camera-conventions>` for the graphics/vision camera
    frames and camera-to-world extrinsics convention.

    - the split-argument form of
      :func:`~kornia.geometry.conversions.camtoworld_graphics_to_vision_4x4`,
      which documents the flip, the two camera frames, the involution and
      the preserved handedness. It packs ``(R, t)`` with
      :func:`~kornia.geometry.conversions.Rt_to_matrix4x4`, applies that
      function and splits the result again, so the two paths agree bitwise.
      Only the lines below differ
    - the shapes are strictly ``(B, 3, 3)`` and ``(B, 3, 1)`` in and
      out, with the same-batch-size rule and the integer-input ``ValueError`` of
      :func:`~kornia.geometry.conversions.Rt_to_matrix4x4`

Args:
    R: Rotation matrix, ``(B, 3, 3)``.
    t: Translation matrix ``(B, 3, 1)``.

Returns:
    R: Rotation matrix, ``(B, 3, 3)``.
    t: Translation matrix ``(B, 3, 1)``.

See Also:
    - :func:`camtoworld_vision_to_graphics_Rt`: the reverse direction, the same arithmetic.
    - :func:`camtoworld_graphics_to_vision_4x4`: the same conversion for a ``(B, 4, 4)`` matrix.
    - :func:`camtoworld_to_worldtocam_Rt`: inverts a camera-to-world ``(R, t)`` to world-to-camera.

Example:
    >>> R, t = torch.eye(3)[None], torch.ones(3).reshape(1, 3, 1)
    >>> camtoworld_graphics_to_vision_Rt(R, t)
    (tensor([[[ 1.,  0.,  0.],
             [ 0., -1.,  0.],
             [ 0.,  0., -1.]]]), tensor([[[1.],
             [1.],
             [1.]]]))

r   rE  rG  )r   rI  r   r   r(   ©rB  rC  Úmat4x4s   && rF   r   r     s>   € ô\ �qš/Ô*Ü�qš/Ô*Ü˜ÐAÔBÜ.¬¸qÓ/DÓE€FÜ˜6Ó"Ð"rH   c               ó    € V ^8„  d   QhRRRR/# )r@   Úextrinsics_visionrB   rC   rD   )rE   s   "rF   rG   rG   E  s   € ÷ 1>ñ 1>¸ð 1>È,ñ 1>rH   c                ó¨   € \        V . RO4       \        P                  ! . RO. RO. RO. RO..V P                  V P                  R7      p\        W4      # )uÁ  Convert ``(B, 4, 4)`` camera-to-world poses from vision (OpenCV) to graphics (OpenGL) camera axes.

``M_graphics = camtoworld_vision_to_graphics_4x4(M_vision)`` takes camera-to-world poses ``(B, 4, 4)`` whose
camera axes follow the vision convention, ``[+x, +y, +z] == [right, down, forwards]``, and returns them with the
graphics camera axes, ``[right, up, backwards]``, by negating the camera ``y`` and ``z`` axes. The flip is its own
inverse, so this is the same arithmetic as :func:`camtoworld_graphics_to_vision_4x4`; the name records the
direction. For a pose given as ``(R, t)``, use :func:`camtoworld_vision_to_graphics_Rt`.

Convention:
    See :doc:`camera and world conventions </get-started/camera-conventions>` for the graphics/vision camera
    frames and camera-to-world extrinsics convention.

    - the same map as
      :func:`~kornia.geometry.conversions.camtoworld_graphics_to_vision_4x4`,
      which carries the canonical block: ``diag(1, -1, -1, 1)`` is its own
      inverse, so vision-to-graphics and graphics-to-vision are the identical
      function and return bitwise equal matrices on the same input. The name
      records which direction the caller means
    - everything else â€” the right multiplication, the untouched translation
      column, the two frame definitions, the preserved determinant, the
      strict ``(B, 4, 4)`` shape and the integer-dtype warning â€” is as
      documented there

Args:
    extrinsics_vision: pose matrix ``(B, 4, 4)``.

Returns:
    extrinsics: pose matrix ``(B, 4, 4)``.

See Also:
    - :func:`camtoworld_graphics_to_vision_4x4`: the forward direction, which documents the flip.
    - :func:`camtoworld_vision_to_graphics_Rt`: the same conversion for a pose given as ``(R, t)``.

Example:
    >>> ext = torch.eye(4)[None]
    >>> camtoworld_vision_to_graphics_4x4(ext)
    tensor([[[ 1.,  0.,  0.,  0.],
             [ 0., -1.,  0.,  0.],
             [ 0.,  0., -1.,  0.],
             [ 0.,  0.,  0.,  1.]]])

r]  rN  r^  r_  r`  ra  rb  )rj  rc  s   & rF   r   r   E  sM   € ôV Ð(ª/Ô:Ü—’Ú
š¢}²nÐ	EÐFØ×%Ñ%Ø ×'Ñ'ô€Iô
  Ð 1Ó=Ð=rH   c               ó$   € V ^8„  d   QhRRRRRR/# re  rD   )rE   s   "rF   rG   rG   y  s"   € ÷ 0#ñ 0#¨ð 0#¸ð 0#ÐJkñ 0#rH   c                ó�   € \        V . RO4       \        V. RO4       \        WR4       \        \        W4      4      p\	        V4      # )aé  Convert camera-to-world ``(R, t)`` poses from vision (OpenCV) to graphics (OpenGL) camera axes.

``R_graphics, t = camtoworld_vision_to_graphics_Rt(R, t)`` is :func:`camtoworld_vision_to_graphics_4x4` for a
camera-to-world pose given as rotations ``(B, 3, 3)`` and camera centres ``(B, 3, 1)``: it negates the second and
third columns of ``R`` and returns ``t`` unchanged, the same arithmetic as
:func:`camtoworld_graphics_to_vision_Rt`.

Convention:
    See :doc:`camera and world conventions </get-started/camera-conventions>` for the graphics/vision camera
    frames and camera-to-world extrinsics convention.

    - the split-argument form of
      :func:`~kornia.geometry.conversions.camtoworld_vision_to_graphics_4x4`
      and, because ``diag(1, -1, -1, 1)`` is its own inverse, bitwise the
      same function as
      :func:`~kornia.geometry.conversions.camtoworld_graphics_to_vision_Rt`.
      The canonical block lives on
      :func:`~kornia.geometry.conversions.camtoworld_graphics_to_vision_4x4`
    - the shapes, the unchanged ``t`` and the warnings are as in the
      graphics-to-vision ``_Rt`` form

Args:
    R: Rotation matrix, ``(B, 3, 3)``.
    t: Translation matrix ``(B, 3, 1)``.

Returns:
    R: Rotation matrix, ``(B, 3, 3)``.
    t: Translation matrix ``(B, 3, 1)``.

See Also:
    - :func:`camtoworld_graphics_to_vision_Rt`: the forward direction, the same arithmetic.
    - :func:`camtoworld_vision_to_graphics_4x4`: the same conversion for a ``(B, 4, 4)`` matrix.

Example:
    >>> R, t = torch.eye(3)[None], torch.ones(3).reshape(1, 3, 1)
    >>> camtoworld_vision_to_graphics_Rt(R, t)
    (tensor([[[ 1.,  0.,  0.],
             [ 0., -1.,  0.],
             [ 0.,  0., -1.]]]), tensor([[[1.],
             [1.],
             [1.]]]))

r   rE  rG  )r   rI  r   r   r(   rg  s   && rF   r   r   y  s>   € ôX �qš/Ô*Ü�qš/Ô*Ü˜ÐAÔBÜ.¬¸qÓ/DÓE€FÜ˜6Ó"Ð"rH   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r@   rB  rB   rC  Úfn_nameÚstrrC   ÚNonerD   )rE   s   "rF   rG   rG   ¬  s(   € ÷ 
ñ 
˜Lð 
¨\ð 
ÀCð 
ÈDñ 
rH   c           	     óž  € \         P                  P                  4       '       g   \        4       '       g   R # V P                  ^ ,          VP                  ^ ,          8w  dn   \        V R\        V P                  4       R\        VP                  4       R2\        VP                  4      \        V P                  ^ ,          4      RR.R7      hR # )Nz-: R and t must have the same batch size, got z and rŒ   r6  rH  )Úactual_shapeÚexpected_shape)rN   rÅ  rÇ  r   r{   r   rÇ   rp  )rB  rC  ro  s   &&&rF   rI  rI  ¬  s�   € ô
 �9‰9×!Ñ!×#Ò#Ü!×#Ò#Ùà‡w�wˆq…z�Q—W‘W˜Q•ZÔÜØˆiÐDÄTÈ!Ï'É'Ã]ÀOÐSXÔY]Ð^_×^eÑ^eÓYfÐXgÐghÐiÜ˜aŸg™g›Ü §¡¨¥
›O¨S°#Ð6ô
ð 	
ñ  rH   c               ó$   € V ^8„  d   QhRRRRRR/# )r@   rB  rB   ro  rp  rC   rq  rD   )rE   s   "rF   rG   rG   ½  s&   € ÷ _ñ _˜,ð _°ð _¸ñ _rH   c                ó\  € V P                   \        P                  8X  d   T MV P                  \        P                  4      pV P                   \        P                  8X  d   RpMFV P                   \        P
                  8X  d   R	pM$V P                   \        P                  8X  d   R
pMRp\        P                  ! ^V P                  VP                   R7      pW"P                  RR4      ,          V,
          P                  4       P                  RR7      p\        WS8*  P                  4       4      '       g,   \        V R\        VP!                  4       4       RV R24      h\        \        P"                  P%                  V4      ^ 8*  P'                  4       4      '       d   \        V R24      hR# )g      Y@rÃ  r„   z1: R is not a rotation matrix: max|R @ R^T - I| = z is not within the tolerance rŒ   z8: R is a reflection (det(R) < 0), not a rotation matrix.Ng      =g      À?g      �?g      é>r™   ry   )r™   ry   )rf   rN   r
  rm   rt  rh   rg   Úeyerˆ  Ú	transposer}   Úamaxrä   Úallr|   rc   r+  r9  ÚdetÚany)rB  ro  rw  Útolrw  Ú	ortho_errs   &&    rF   rè   rè   ½  sD  € ð —‘œ5Ÿ=™=Ô(‰1¨a¯d©d´5·=±=Ó.A€DØ‡w�w”%—-‘-ÔØ‰Ø	
�‰”E—N‘NÔ	"Ø‰Ø	
�‰”E—M‘MÔ	!Ø‰àˆÜ
�)Š)�A˜aŸh™h¨d¯j©jÔ
9€CØŸ™ r¨2Ó.Õ.°Õ4×9Ñ9Ó;×@Ñ@ÀXÐ@ÓN€Iä�Ñ!×&Ñ&Ó(×)Ò)ÜØˆiÐHÌÈyÏ}É}ËÓI_ÐH`ð a+Ø+.¨%¨qð2ó
ð 	
ô ŒU�\‰\×Ñ˜dÓ# qÑ(×-Ñ-Ó/×0Ò0Ü˜G˜9Ð$\Ð]Ó^Ð^ñ 1rH   c               ó(   € V ^8„  d   QhRRRRRRRR/# ©r@   rB  rB   rC  rã   rä   rC   rZ   rD   )rE   s   "rF   rG   rG   Ù  s2   € ÷ Qñ QØðQØ$ðQØ6:ðQà&ñQrH   c                ó¾   € \        V . RO4       \        V. RO4       \        WR4       V'       d   \        V R4       V P                  ^^4      p\	        V) V4      pW43# )uÿ  Invert camera-to-world poses (R, t) into the world-to-camera poses that Colmap stores.

``R_w2c, t_w2c = camtoworld_to_worldtocam_Rt(R, t)`` takes camera-to-world rotations ``(B, 3, 3)`` and camera
centres ``(B, 3, 1)`` and returns the rigid inverse ``(R^T, -R^T @ t)``: the world-to-camera pose of
`Colmap's images.txt <https://colmap.github.io/format.html#output-format>`_. It transposes rather than inverts, so
``R`` must be a rotation; pass ``check_rotation=True`` to verify it. The same formula undoes it, under the name
:func:`worldtocam_to_camtoworld_Rt`; for a ``(B, 4, 4)`` matrix, use
:func:`~kornia.geometry.linalg.inverse_transformation`.

Convention:
    See :doc:`camera and world conventions </get-started/camera-conventions>` for camera-to-world versus
    world-to-camera extrinsics and camera-centre semantics.

    - the returned pair is exactly ``(R^T, -R^T @ t)`` â€” the **rigid**
      inverse, computed by transposition and never by a matrix inverse, so
      for a proper rotation it inverts the pose to the working dtype's
      rounding
    - what ``t`` means on each side: the input is a camera-to-world pose, so
      its ``t`` is the **camera centre in world coordinates** (the 4x4 sends
      the origin to ``t``); the returned ``-R^T t`` is the **world-to-camera
      translation** of Colmap's ``images.txt`` (the returned 4x4 sends the
      camera centre to the origin)
    - :func:`~kornia.geometry.conversions.worldtocam_to_camtoworld_Rt` is
      the **same function** under the other name: applying either one twice
      returns ``R`` exactly and ``t`` to rounding
    - the shapes are ``(B, 3, 3)`` and ``(B, 3, 1)``, and ``R`` and ``t``
      must carry the same batch size: a mismatched pair raises ``ShapeError``
    - an ``R`` and ``t`` of one integer dtype (``uint8``, ``int8``, ``int16``,
      ``int32`` or ``int64``) are accepted on every device, CUDA (which has
      no integer matmul) included, and the result keeps that dtype, wrapping
      on overflow; ``check_rotation=True`` checks such an ``R`` in ``float32``

.. warning::
    ``R`` is **assumed** to be a rotation and by default this is not
    checked, so for a non-orthogonal ``R`` the result is a transpose and
    not an inverse, silently: ``R = [[1, 0.5, 0], [0, 1, 0], [0, 0, 2]]``
    gives ``max|M_inv @ M - I| = 3.0``. Pass ``check_rotation=True`` to
    raise a ``ValueError`` instead, which also rejects reflections
    (``det(R) < 0``).

Args:
    R: Rotation matrix, ``(B, 3, 3)``.
    t: Translation matrix ``(B, 3, 1)``.
    check_rotation: if ``True``, raise ``ValueError`` unless every ``R``
        is a rotation: ``max|R @ R^T - I|`` within 100 eps of the dtype of
        ``R`` (16 eps for float16 and bfloat16) and ``det(R) > 0``.
        Defaults to ``False`` (unchecked).

Returns:
    Rinv: Rotation matrix, ``(B, 3, 3)``.
    tinv: Translation matrix ``(B, 3, 1)``.

See Also:
    - :func:`worldtocam_to_camtoworld_Rt`: the reverse direction, the same formula.
    - :func:`~kornia.geometry.linalg.inverse_transformation`: the same rigid inverse of a ``(B, 4, 4)`` matrix.
    - :func:`camtoworld_graphics_to_vision_Rt`: changes the camera axes of a camera-to-world pose instead.
    - :func:`ARKitQTVecs_to_ColmapQTVecs`: an ARKit quaternion pose to Colmap's, through this inversion.

Example:
    >>> R, t = torch.eye(3)[None], torch.ones(3).reshape(1, 3, 1)
    >>> camtoworld_to_worldtocam_Rt(R, t)
    (tensor([[[1., 0., 0.],
             [0., 1., 0.],
             [0., 0., 1.]]]), tensor([[[-1.],
             [-1.],
             [-1.]]]))

r   rE  rG  ©r   rI  rè   rx  rY  ©rB  rC  rã   ÚR_invÚnew_ts   &&&  rF   r   r   Ù  sX   € ôN �qš/Ô*Ü�qš/Ô*Ü˜Ð<Ô=çÜ˜1Ð;Ô<à�K‰K˜˜1Ó€EÜ.°¨v°qÓ9€Eàˆ>ÐrH   c               ó(   € V ^8„  d   QhRRRRRRRR/# r€  rD   )rE   s   "rF   rG   rG   -  s,   € ÷ >ñ >Øð>Ø$ð>Ø6:ð>à&ñ>rH   c                ó¾   € \        V . RO4       \        V. RO4       \        WR4       V'       d   \        V R4       V P                  ^^4      p\	        V) V4      pW43# )aÜ  Invert world-to-camera poses (R, t), as Colmap stores them, into camera-to-world poses.

``R_c2w, t_c2w = worldtocam_to_camtoworld_Rt(R, t)`` takes world-to-camera rotations ``(B, 3, 3)`` and
translations ``(B, 3, 1)``, as in Colmap's ``images.txt``, and returns the rigid inverse ``(R^T, -R^T @ t)``: the
camera-to-world pose, whose translation is the camera centre in world coordinates. It is the same formula as
:func:`camtoworld_to_worldtocam_Rt`, which documents it; ``R`` must be a rotation, verified with
``check_rotation=True``.

Convention:
    See :doc:`camera and world conventions </get-started/camera-conventions>` for camera-to-world versus
    world-to-camera extrinsics and camera-centre semantics.

    - the **same function** as
      :func:`~kornia.geometry.conversions.camtoworld_to_worldtocam_Rt`,
      which carries the canonical block: for a proper rotation
      ``(R^T, -R^T @ t)`` is its own inverse, so one name serves both
      directions and the choice is documentation for the reader
    - read the other way round here: the input ``t`` is the world-to-camera
      translation and the returned ``-R^T t`` is the camera centre in world
      coordinates
    - the shapes and the rotation warning are as documented there

Args:
    R: Rotation matrix, ``(B, 3, 3)``.
    t: Translation matrix ``(B, 3, 1)``.
    check_rotation: if ``True``, raise ``ValueError`` unless every ``R``
        is a rotation: ``max|R @ R^T - I|`` within 100 eps of the dtype of
        ``R`` (16 eps for float16 and bfloat16) and ``det(R) > 0``.
        Defaults to ``False`` (unchecked).

Returns:
    Rinv: Rotation matrix, ``(B, 3, 3)``.
    tinv: Translation matrix ``(B, 3, 1)``.

See Also:
    - :func:`camtoworld_to_worldtocam_Rt`: the reverse direction, the same formula.
    - :func:`~kornia.geometry.linalg.inverse_transformation`: the same rigid inverse of a ``(B, 4, 4)`` matrix.
    - :func:`ColmapQTVecs_to_ARKitQTVecs`: a Colmap quaternion pose to ARKit's, through this inversion.

Example:
    >>> R, t = torch.eye(3)[None], torch.ones(3).reshape(1, 3, 1)
    >>> worldtocam_to_camtoworld_Rt(R, t)
    (tensor([[[1., 0., 0.],
             [0., 1., 0.],
             [0., 0., 1.]]]), tensor([[[-1.],
             [-1.],
             [-1.]]]))

r=   rE  rG  r‚  rƒ  s   &&&  rF   r=   r=   -  sX   € ôh �qš/Ô*Ü�qš/Ô*Ü˜Ð<Ô=çÜ˜1Ð;Ô<à�K‰K˜˜1Ó€EÜ.°¨v°qÓ9€Eàˆ>ÐrH   c               ó$   € V ^8„  d   QhRRRRRR/# ©r@   ÚqvecrB   ÚtvecrC   rZ   rD   )rE   s   "rF   rG   rG   n  s'   € ÷ Yñ Y lð Y¸,ð YÐKlñ YrH   c                ó  € \        V \        P                  4      '       d<   V P                  4       '       g&   \	        RV P
                   R2V P
                  R7      h\        V\        P                  4      '       d<   VP                  4       '       d&   \	        RVP
                   R2VP
                  R7      h\        V 4      p\        W!4      w  r4\        W44      w  rVVP                  R^^4      p\        VP                  4       4      pWv3# )u  Convert an Apple ARKit camera-to-world screen pose to the world-to-camera pose expected by Colmap.

``q_colmap, t_colmap = ARKitQTVecs_to_ColmapQTVecs(q, t)`` takes ARKit camera-to-world poses in the graphics camera
frame, as ``(w, x, y, z)`` quaternions ``(B, 4)`` and camera centres ``(B, 3, 1)``, and returns the Colmap
world-to-camera poses in the vision camera frame, the ``QW QX QY QZ TX TY TZ`` of ``images.txt``, as a
``(B, 4)`` quaternion and a ``(B, 3, 1)`` translation. ARKit stores quaternions as ``(x, y, z, w)``: reorder them
first. The sign of the returned quaternion is not canonical. For the reverse, use
:func:`ColmapQTVecs_to_ARKitQTVecs`.

Convention:
    See :doc:`camera and world conventions </get-started/camera-conventions>` for the camera frames and
    extrinsics conventions composed by this conversion.

    - **input**: ``qvec`` ``(B, 4)`` in ``(w, x, y, z)`` order â€”
      ``[1., 0., 0., 0.]`` is the identity â€” and ``tvec`` ``(B, 3, 1)``,
      read as a **camera-to-world** pose in the **graphics** frame (``+y``
      up, ``-z`` forward), so ``tvec`` is the camera centre in world
      coordinates
    - **output**: ``(q, t)`` in the same layouts, a **world-to-camera** pose
      in the **vision** frame (``+y`` down, ``+z`` forward) â€” Colmap's
      ``images.txt`` ``QW QX QY QZ TX TY TZ``. The pipeline is
      :func:`~kornia.geometry.conversions.quaternion_to_rotation_matrix`,
      :func:`~kornia.geometry.conversions.camtoworld_graphics_to_vision_Rt`,
      :func:`~kornia.geometry.conversions.camtoworld_to_worldtocam_Rt`, then
      :func:`~kornia.geometry.conversions.rotation_matrix_to_quaternion`
    - ARKit's ``simd_quatf`` exposes ``.vector`` as ``(ix, iy, iz, r)``, i.e.
      ``xyzw``: reorder it to ``wxyz`` first, since this function accepts
      either order silently
    - the input quaternion need not be unit and ``q`` and ``-q`` give the
      same output, as long as ``||q||`` stays above the ``eps = 1e-12``
      normalisation floor and its squared norm does not overflow (about
      ``1.8e19`` in ``float32``); outside that range the result is the
      zero-quaternion answer below or a wrong pose
    - the **sign of the output quaternion is not canonical**: it is the
      representative
      :func:`~kornia.geometry.conversions.rotation_matrix_to_quaternion`'s
      branch produces, so ``[0.5, 0.5, 0.5, 0.5]`` with ``t = (1, 2, 3)``
      returns ``q = [-0.5, -0.5, -0.5, 0.5]`` and ``t = (-2, 3, 1)``.
      Compare rotations, never raw components
    - worked literal: ``q = [0., 1., 0., 1.]``, ``t = (1, 1, 1)`` gives
      ``q = [0.7071, 0., 0.7071, 0.]`` and ``t = (-1, -1, 1)``, the example
      below
    - :func:`~kornia.geometry.conversions.ColmapQTVecs_to_ARKitQTVecs`
      computes the reverse conversion
    - the zero quaternion is not rejected: it rotates as the identity, so
      ``torch.zeros(1, 4)`` with ``t = (1, 1, 1)`` returns
      ``q = [0., 1., 0., 0.]``, ``t = (-1, 1, 1)``, the same answer as the
      identity input
    - ``qvec`` must be real floating point: an integer, bool or complex
      ``qvec`` raises ``TypeCheckError`` (also a ``TypeError``) naming it,
      so cast it first. An integer or bool ``tvec`` promotes to ``qvec``'s
      dtype; a complex ``tvec`` raises ``TypeCheckError``

Args:
    qvec: ARKit rotation quaternion ``(B, 4)``, [w, x, y, z] format.
    tvec: translation vector ``(B, 3, 1)``, [x, y, z]

Returns:
    qvec: Colmap rotation quaternion ``(B, 4)``, [w, x, y, z] format.
    tvec: translation vector ``(B, 3, 1)``, [x, y, z]

See Also:
    - :func:`ColmapQTVecs_to_ARKitQTVecs`: the reverse conversion, Colmap to ARKit.
    - :func:`camtoworld_graphics_to_vision_Rt`: the camera-axes step of this pipeline, for a matrix pose.
    - :func:`camtoworld_to_worldtocam_Rt`: the inversion step of this pipeline, for a matrix pose.

Example:
    >>> q, t = torch.tensor([0, 1, 0, 1.])[None], torch.ones(3).reshape(1, 3, 1)
    >>> ARKitQTVecs_to_ColmapQTVecs(q, t)
    (tensor([[0.7071, 0.0000, 0.7071, 0.0000]]), tensor([[[-1.0000],
             [-1.0000],
             [ 1.0000]]]))

z;Input qvec must be a real floating point tensor. Got dtype rŒ   r)  z,Input tvec must be a real tensor. Got dtype ry   )rM   rN   rO   r‘   r	   rf   r’   r7   r   r   rÆ   r;   Ú
contiguous)rŠ  r‹  ÚRcgÚRcvÚTcvÚR_colmapÚt_colmapÚq_colmaps   &&      rF   r   r   n  sà   € ôZ �$œŸ™×%Ò%¨d×.DÑ.D×.FÒ.FÜØIÈ$Ï*É*ÈÐUVÐWÐei×eoÑeoô
ð 	
ô �$œŸ™×%Ò%¨$¯/©/×*;Ò*;ÜÐKÈDÏJÉJÈ<ÐWXÐYÐgk×gqÑgqÔrÐrÜ
'¨Ó
-€CÜ/°Ó:�H€CÜ4°SÓ>Ñ€HØ×Ñ  A qÓ)€HÜ,¨X×-@Ñ-@Ó-BÓC€HØÐÐrH   c               ó$   € V ^8„  d   QhRRRRRR/# r‰  rD   )rE   s   "rF   rG   rG   Ê  s'   € ÷ Rñ R lð R¸,ð RÐKlñ RrH   c                óŒ  € RV 3RV33 Fe  w  r#\        V\        P                  4      '       g   K'  VP                  4       '       d   K?  \	        RV RVP
                   R2VP
                  R7      h	  \        V 4      p\        WA4      w  rV\        WV4      w  rxVP                  R^^4      p	\        VP                  4       4      p
W©3# )uf  Convert a Colmap world-to-camera pose to an Apple ARKit camera-to-world screen pose.

``q_arkit, t_arkit = ColmapQTVecs_to_ARKitQTVecs(q, t)`` takes Colmap world-to-camera poses in the vision camera
frame, as ``(w, x, y, z)`` quaternions ``(B, 4)`` and translations ``(B, 3, 1)``, and returns the ARKit
camera-to-world poses in the graphics camera frame, as a ``(w, x, y, z)`` quaternion ``(B, 4)`` and the camera
centre ``(B, 3, 1)``. Reorder the quaternion to ARKit's ``(x, y, z, w)`` before handing it over. The sign of the
returned quaternion is not canonical. For the reverse, use :func:`ARKitQTVecs_to_ColmapQTVecs`.

Convention:
    See :doc:`camera and world conventions </get-started/camera-conventions>` for the camera frames and
    extrinsics conventions composed by this conversion.

    - the reverse of
      :func:`~kornia.geometry.conversions.ARKitQTVecs_to_ColmapQTVecs`,
      with the same layouts and the frames exchanged
    - **input**: ``qvec`` ``(B, 4)`` in ``(w, x, y, z)`` order â€”
      ``[1., 0., 0., 0.]`` is the identity â€” and ``tvec`` ``(B, 3, 1)``,
      read as a **world-to-camera** pose in the **vision** frame (``+y``
      down, ``+z`` forward) â€” Colmap's ``images.txt``
      ``QW QX QY QZ TX TY TZ``
    - **output**: ``(q, t)`` in the same layouts, a **camera-to-world**
      pose in the **graphics** frame (``+y`` up, ``-z`` forward), so ``t``
      is the camera centre in world coordinates. The pipeline is
      :func:`~kornia.geometry.conversions.quaternion_to_rotation_matrix`,
      :func:`~kornia.geometry.conversions.worldtocam_to_camtoworld_Rt`,
      :func:`~kornia.geometry.conversions.camtoworld_vision_to_graphics_Rt`,
      then :func:`~kornia.geometry.conversions.rotation_matrix_to_quaternion`
    - the output is ``(w, x, y, z)``; ARKit's ``simd_quatf`` stores
      ``(ix, iy, iz, r)``, i.e. ``xyzw``, so reorder it before handing it
      to ARKit
    - the input quaternion need not be unit and ``q`` and ``-q`` give the
      same output, within the same normalisation range as
      :func:`~kornia.geometry.conversions.ARKitQTVecs_to_ColmapQTVecs`
    - only real floating point ``qvec`` and ``tvec`` are accepted: an
      integer, bool or complex one raises ``TypeCheckError`` (also a
      ``TypeError``) naming the argument, so cast it first
    - the **sign of the output quaternion is not canonical**: a round trip
      through both functions returns the input rotation, but not
      necessarily the input quaternion's sign. Compare rotations, never raw
      components
    - worked literal: the reverse of the
      :func:`~kornia.geometry.conversions.ARKitQTVecs_to_ColmapQTVecs`
      example, ``q = [0.7071, 0., 0.7071, 0.]``, ``t = (-1, -1, 1)``, gives
      ``q = [0., 0.7071, 0., 0.7071]`` and ``t = (1, 1, 1)``, the unit form
      of that example's input; see the example below
    - the zero quaternion is not rejected: it rotates as the identity, so
      ``torch.zeros(1, 4)`` with ``t = (1, 1, 1)`` returns
      ``q = [0., 1., 0., 0.]``, ``t = (-1, -1, -1)``, the same answer as the
      identity input

Args:
    qvec: Colmap rotation quaternion ``(B, 4)``, [w, x, y, z] format.
    tvec: translation vector ``(B, 3, 1)``, [x, y, z]

Returns:
    qvec: ARKit rotation quaternion ``(B, 4)``, [w, x, y, z] format.
    tvec: translation vector ``(B, 3, 1)``, [x, y, z]

See Also:
    - :func:`ARKitQTVecs_to_ColmapQTVecs`: the reverse conversion, ARKit to Colmap.
    - :func:`worldtocam_to_camtoworld_Rt`: the inversion step of this pipeline, for a matrix pose.
    - :func:`camtoworld_vision_to_graphics_Rt`: the camera-axes step of this pipeline, for a matrix pose.

Example:
    >>> q, t = torch.tensor([0, 1, 0, 1.])[None], torch.ones(3).reshape(1, 3, 1)
    >>> ColmapQTVecs_to_ARKitQTVecs(*ARKitQTVecs_to_ColmapQTVecs(q, t))
    (tensor([[0.0000, 0.7071, 0.0000, 0.7071]]), tensor([[[1.0000],
             [1.0000],
             [1.0000]]]))

rŠ  r‹  zInput z1 must be a real floating point tensor. Got dtype rŒ   r)  ry   )rM   rN   rO   r‘   r	   rf   r7   r=   r   rÆ   r;   r�  )rŠ  r‹  Únamer�   r‘  r�  r�  rŽ  ÚTcgÚt_arkitÚq_arkits   &&         rF   r   r   Ê  s¾   € ðP   ˜¨°¨Ó7‰ˆÜ�eœUŸ\™\×*Ô*°5×3JÑ3J×3LÔ3LÜ Ø˜˜ÐOÐPU×P[ÑP[È}Ð\]Ð^Ðlq×lwÑlwôð ñ 8ô
 -¨TÓ2€HÜ*¨8Ó:�H€CÜ/°Ó9�H€CØ�k‰k˜"˜a Ó#€GÜ+¨C¯N©NÓ,<Ó=€GØÐÐrH   c               ó    € V ^8„  d   QhRRRR/# )r@   ÚvecrB   rC   rD   )rE   s   "rF   rG   rG     s   € ÷ 5ñ 5¨ð 5¸,ñ 5rH   c           	     óÂ  € V P                   R,          ^8w  g   \        V P                   4      ^8”  d   \        RV P                    24      hV R,          V R,          V R,          r2p\        P                  ! V4      p\        P
                  ! \        P
                  ! WC) V.RR7      \        P
                  ! W4V) .RR7      \        P
                  ! V) W.RR7      .RR7      # )uä  Build the skew-symmetric cross-product matrix ``(3, 3)`` or ``(B, 3, 3)`` of a 3-vector.

``S = vector_to_skew_symmetric_matrix(v)`` takes a vector ``(3,)`` or a batch ``(B, 3)`` and returns the matrix
``(3, 3)`` or ``(B, 3, 3)`` with ``S @ x == cross(v, x)``. For any number of leading dimensions ``(*, 3)``, use
:func:`~kornia.geometry.epipolar.cross_product_matrix`, which builds the same matrix.

A vector :math:`(v1, v2, v3)` has a corresponding skew-symmetric matrix, which is of the form:

.. math::
    \begin{bmatrix} 0 & -v3 & v2 \\
    v3 & 0 & -v1 \\
    -v2 & v1 & 0\end{bmatrix}

Convention:
    - the matrix acts on the left as the first cross-product factor:
      ``vector_to_skew_symmetric_matrix(v) @ x`` equals ``cross(v, x)``, not
      its negation â€” for ``v = (1., 2., 3.)`` and ``x = (4., 5., 6.)`` both
      are ``(-3., 6., -3.)``
    - accepts ``(3,)`` or ``(B, 3)`` only; any higher rank raises
      ``ValueError``

Args:
    vec: tensor of shape ``(3,)`` or ``(B, 3)``.

Returns:
    tensor of shape ``(3, 3)`` or ``(B, 3, 3)`` respectively.

See Also:
    - :func:`~kornia.geometry.epipolar.cross_product_matrix`: the same matrix for ``(*, 3)`` vectors of any rank.
    - :meth:`~kornia.geometry.liegroup.So3.hat`: the same matrix, as the Lie-algebra element of a rotation
      vector.

Example:
    >>> vec = torch.tensor([1.0, 2.0, 3.0])
    >>> vector_to_skew_symmetric_matrix(vec)
    tensor([[ 0., -3.,  2.],
            [ 3.,  0., -1.],
            [-2.,  1.,  0.]])

z2Input vector must be of shape (B, 3) or (3,). Got r„   ry   rC  rD  rE  r™   )r{   rz   r|   rN   r;  r¬   )r›  Úv1Úv2Úv3r‰  s   &    rF   r<   r<     s¼   € ðT ‡y�y�…}˜ÔœS §¡›^¨aÔ/ÜÐMÈcÏiÉiÈ[ÐYÓZÐZØ�V•˜c &�k¨3¨v­;ˆB€BÜ×Ò˜RÓ €EÜ�;Š;ä�KŠK˜  RÐ(¨bÔ1Ü�KŠK˜ R CÐ(¨bÔ1Ü�KŠK˜"˜˜bÐ(¨bÔ1ð	
ð
 ôð rH   )rÀ  )F)rÀ  F)gê-�™—q=)T)r  NNT)r  NN)SÚ__doc__Ú
__future__r   rR   rÈ  Útypingr   rN   Útorch.nn.functionalÚnnÚ
functionalr“   Úkornia.core._compatr   Úkornia.core.checkr   r   r   r   Úkornia.core.exceptionsr	   Úkornia.core.opsr
   Úkornia.core.utilsr   r   r   r   Ú__all__r8   r!   r1   r   r   r    r–   r   r   r   r   r:   r9   r;   r0   r3  r7   r6   r5   r4   r2   r   r   r'   r3   r-   r$   r.   r%   r   rî  r+   r)   r*   r  r"   r,   r#   r/   r&   r   r(   rY  r   r   r   r   rI  rè   r   r=   r   r   r<   rD   rH   rF   Ú<module>r¬     sè  ðñ$2õh #ã Û Ý ã ß Ð å *ß ^Ó ^Ý 1Ý ,ß mÓ mð0Ø!ð0à!ð0ð ð0ð ð	0ð
 $ð0ð ð0ð ð0ð $ð0ð (ð0ð 'ð0ð "ð0ð (ð0ð 'ð0ð ð0ð )ð0ð  +ð!0ð" &ð#0ð$ $ð%0ð& ð'0ð( ð)0ð* ð+0ð, $ð-0ð. &ð/0ð0 )ð10ð2 ð30ð4 ð50ð6 ð70ð8 ð90ð: ð;0ð< ð=0ð> "ð?0ð@ $ðA0ðB 'ðC0ðD ðE0ðF ðG0ðH ðI0ðJ ðK0ðL ðM0ðN ðO0ðP ðQ0ðR $ðS0ðT ðU0ðV $ðW0ðX $ðY0ðZ $ð[0ð\ &ð]0ð^ "ð_0€õf&õ8&õ<$÷NM÷`7$õt!IõHõ*7õZ,7õ^U9ñp Ð8À'ÔJô5ó Kð5÷NHñb Ð8À'ÔJô:ó Kð:÷F=÷R20õjDõBq5õhH=ñV Ð3¸WÔEô0ó Fð0÷KT÷\Yõ@d=ñN Ð3¸WÔEô0ó Fð0õPõfD÷Vq/÷hO/÷d`/÷FT/õn2-õj	÷F$÷RD÷N_õD3÷
^$õB^$õBd$õN=$õ@1'õhF4õR.õbõ&N@õb2#õj1>õh0#õf
õ"_÷8Q÷h>õBYõxR÷j5rH   