+
    åûjUi  ã                  óè   € ^ RI Ht ^ RIHtHtHt ^ RIt^ RIHt ^ RIH	t	H
t
 ^ RIHt ^ RIHtHt ^ RIHt ^ R	IHt RR
 R lltR R ltR R ltR R ltR R lt ! R R]P2                  4      tR# )é    )Úannotations)ÚOptionalÚUnionÚoverloadN)Únn)ÚKORNIA_CHECK_SHAPEÚKORNIA_CHECK_TYPE)Ú_unwrap)Úquaternion_to_axis_angleÚvector_to_skew_symmetric_matrix)Ú
Quaternion)ÚVector3c               ó$   € V ^8„  d   QhRRRRRR/# )é   Úthetaútorch.TensorÚtheta_sqzOptional[torch.Tensor]Úreturnú/tuple[torch.Tensor, torch.Tensor, torch.Tensor]© )Úformats   "ÚXC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\geometry\liegroup\so3.pyÚ__annotate__r   "   s$   € ÷ ,ñ ,Øð,Ø#9ð,à4ñ,ó    c                ó
  € V P                   \        P                  8X  d   RMRpW8  p\        P                  ! V\        P                  ! V 4      V 4      pVf5   \        P                  ! W0\        P
                  ! V 4      4      pWU,          pM+\        P                  ! W1\        P
                  ! V4      4      pRVRVRVRVRVR,          ,
          ,          ,           ,          ,           ,          ,           ,          ,           pR	VR
VRVRVRVR,          ,
          ,          ,           ,          ,           ,          ,           ,          ,           pRVRVRVRVRVR,          ,           ,          ,           ,          ,           ,          ,           ,          ,           p	RV,          p
\        P                  ! W7^\        P                  ! V4      ,
          V,          V,          4      p\        P                  ! W8^\        P                  ! V4      V,          ,
          V,          V,          4      p\        P                  ! W9^V
\        P                  ! V
4      ,          \        P                  ! V
4      ,          ,
          V,          V,          4      pW¼V3# )aA  Evaluate the three angle coefficients of the SO(3) and SE(3) closed forms without cancellation.

Returns :math:`(1 - \cos\theta) / \theta^2`, :math:`(\theta - \sin\theta) / \theta^3` and
:math:`(1 - \tfrac{\theta}{2}\cot\tfrac{\theta}{2}) / \theta^2`, the coefficients of :math:`[\omega]_\times`
and :math:`[\omega]_\times^2` in the SO(3) Jacobians, in the SE(3) :math:`V` matrix and in its inverse.

Each closed form is a 0/0 at :math:`\theta = 0` and keeps only about :math:`\epsilon / \theta^2` of its
relative accuracy near it: all three evaluate to exactly 0 in float32 for :math:`\theta \le 10^{-4}` and in
float64 for :math:`\theta \le 10^{-8}`. Below ``theta_small`` the Taylor series through :math:`\theta^{10}`
is used instead. At the switch point the series is accurate to a fraction of an ulp and the closed forms to a
few hundred ulps, so the two branches agree there. The closed forms divide by :math:`\theta` one factor at a
time: :math:`\theta^3` overflows float16 above 40.3 rad and :math:`\theta^2` above 256 rad.

Args:
    theta: rotation angles of any shape, non-negative.
    theta_sq: optional squared angles computed directly from the rotation vector, with the shape of ``theta``.
        Avoids differentiating a norm at zero in the Taylor series.

Returns:
    the three coefficients, each with the shape of ``theta``.
gš™™™™™É?ç      à?i üŒl    LQf gUUUUUU¥¿glÁlÁV?g  ú¾g\Ÿx·O~’>gUUUUUUÅ?g�¿g  *?g4ÇV¥ãÇ¾gäDõgEæZ>gUUUUUUµ?gg¼jV?gï4“w½«>g¾÷+�jV>g&DÖ(>)ÚdtypeÚtorchÚfloat64ÚwhereÚ	ones_likeÚ
zeros_likeÚcosÚsin)r   r   Útheta_smallÚsmallÚ
safe_thetaÚseries_thetaÚt2Úa_seriesÚb_seriesÚc_seriesÚhalfÚaÚbÚcs   &&            r   Ú_so3_small_angle_coefficientsr1   "   sÛ  € ð0 Ÿ™¬¯©Ô5‘#¸3€KØÑ€Eô —’˜U¤E§O¢O°EÓ$:¸EÓB€JØÒÜ—{’{ 5´×1AÒ1AÀ%Ó1HÓIˆØÕ(‰ä�[Š[˜¬%×*:Ò*:¸8Ó*DÓEˆØ�R˜7 R¨7°R¸:ÈÈkÐ\^ÐajÕ\jÕNjÕHkÕ;kÕ5lÕ+lÕ%mÕmÕnÕn€HØ�r˜X¨¨h¸¸{ÈRÐS_ÐbdÐgqÕbqÕSqÕMrÕ?rÕ9sÕ.sÕ(tÕtÕuÕu€HØ˜Ø�"˜	 B¨+¸¸lÈRÐSfÕMgÕ>gÕ8hÕ*hÕ$iÕiÕjÕjõõ €Hð �Õ€DÜ�Š�E a¬%¯)ª)°JÓ*?Õ&?À:Õ%MÐPZÕ%ZÓ[€AÜ�Š�E a¬%¯)ª)°JÓ*?À*Õ*LÕ&LÐPZÕ%ZÐ]gÕ%gÓh€AÜ�Š�E a¨$´·²¸4³Õ*@Ä5Ç9Â9ÈTÃ?Õ*RÕ&RÐV`Õ%`ÐcmÕ%mÓn€AØ�ˆ7€Nr   c               ó    € V ^8„  d   QhRRRR/# )r   Úvecr   r   r   r   )r   s   "r   r   r   Q   s   € ÷ 	Pñ 	P Lð 	PÐ5dñ 	Pr   c                ó@  € W ,          P                  RRR7      pV^ 8„  p\        P                  ! W \        P                  ! V 4      4      p\        P                  ! W#P	                  RRR7      \        P
                  ! V4      4      p\        VR,          VR,          4      # )zPEvaluate Jacobian coefficients without a singular norm backward at the identity.T©Úkeepdim©Údimr6   éÿÿÿÿ©.N)Úsumr   r    r!   Únormr"   r1   )r3   r   ÚnonzeroÚsafe_vecr   s   &    r   Ú_so3_jacobian_coefficientsr?   Q   sz   € à•	�‰˜r¨4ˆÓ0€HØ˜‰l€Gô �{Š{˜7¬¯ª¸Ó)=Ó>€HÜ�KŠK˜§¡°2¸t Ó!DÄe×FVÒFVÐW_ÓF`Óa€EÜ(¨¨yÕ)9¸8ÀIÕ;NÓOÐOr   c               ó    € V ^8„  d   QhRRRR/# )r   r   ztorch.dtyper   Úboolr   )r   s   "r   r   r   ]   s   € ÷ 4ñ 4 ð 4°ñ 4r   c                óH   € V \         P                  \         P                  39   # )z\Whether So3 and Se3 evaluate an operation of this result dtype in float32 and round it once.)r   Úfloat16Úbfloat16)r   s   &r   Ú_computes_in_float32rE   ]   s   € à”U—]‘]¤E§N¡NÐ3Ñ3Ð3r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úqr   Úpointsr   r   r   )r   s   "r   r   r   b   s!   € ÷ %ñ %�:ð % |ð %¸ñ %r   c                ó  € \        VRR.4       \        \        P                  ! V P                  P
                  VP
                  4      4      '       d/   V P                  \        P                  4      VP                  4       rV P                  P                  4       ^8X  dL   VP                  4       ^8X  d7   \        V P                  P                  VP                  ^ ,          ^4      4      p \        P                  ! . VP                  RR O^N5RVP                  RVP
                  / p\        \        P                  ! W!3R4      4      pV P!                  4       p W,          V P#                  4       ,          P$                  # )a  Rotate points of shape ``(*, 3)`` by the unit direction of ``q`` as :math:`q p q^*`.

A float16/bfloat16 result is computed in float32 and returned in float32, for the caller to add to it or round it
once; any other dtype combination is evaluated as given.
Ú*Ú3NÚdevicer   r9   )r   rE   r   Úpromote_typesÚdatar   ÚtoÚfloat32Úfloatr8   r   ÚexpandÚshapeÚzerosrL   ÚcatÚ	normalizeÚconjr3   )rG   rH   ÚwÚquats   &&  r   Ú_so3_rotaterZ   b   sþ   € ô �v  S˜zÔ*ÜœE×/Ò/°·±·±¸f¿l¹lÓK×LÒLØ—D‘DœŸ™Ó'¨¯©«ˆ6Ø‡v�v‡z�zƒ|�qÔ˜VŸZ™Z›\¨QÔ.ä�q—v‘v—}‘} V§\¡\°!¥_°aÓ8Ó9ˆÜ�ŠÐT�V—\‘\ # 2Ð&ÐT¨ÒT°&·-±-ÐTÀvÇ|Á|ÑT€AÜ”e—i’i  ¨RÓ0Ó1€Dà	�‰‹€AØ�H�q—v‘v“xÕ×$Ñ$Ð$r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rG   r   rH   r   r   ÚNoner   )r   s   "r   r   r   u   s!   € ÷ 
ñ 
˜Jð 
°ð 
Àñ 
r   c                ó  € V P                   P                  RR p\        V4      ^ 8X  d   VP                  4       R	9   pM�VP                  4       \        V4      ^,           8H  ;'       dc    \        ;QJ d3    R \        VP                  RR V4       4       F  '       d   K   RM(	  RM$! R \        VP                  RR V4       4       4      pV'       g/   \        R\        VP                  4       R\        V4       R24      hR# )
züRaise unless So3 and Se3 map ``points``: ``(3,)`` or ``(N, 3)`` unbatched, one point per pose for a batch.

For a batch of ``B`` poses the points are ``(B, 3)``; a batch of one pose also maps ``(N, 3)``, and one point
``(1, 3)`` maps under every pose.
Nc              3  óL   "  € T F  w  rW^39   ;'       g    V^8H  x € K  	  R# 5i)é   Nr   )Ú.0Úpr/   s   &  r   Ú	<genexpr>Ú'_check_points_layout.<locals>.<genexpr>   s+   é € ð :
Ù.K¡d aˆA�Q�‰K×!Ð!˜1 ™6Ô!Ó.Kùs   ‚$–$FTzÝExpected points of shape (3,) or (N, 3) for an unbatched pose, or (B, 3), one point per pose, for a batch of B poses (a batch of one pose also maps (N, 3), and one point (1, 3) maps under every pose). Got points of shape z for a pose of batch shape Ú.r9   )r_   r   )rN   rS   Úlenr8   ÚallÚzipÚ
ValueErrorÚtuple)rG   rH   ÚbatchÚaccepteds   &&  r   Ú_check_points_layoutrl   u   sá   € ð �F‰F�L‰L˜˜"Ð€EÜ
ˆ5ƒz�Q„Ø—:‘:“< 6Ñ)‰à—:‘:“<¤3 u£:°¥>Ñ1÷ 
ð 
·c³cñ :
Ü.1°&·,±,¸sÀÐ2CÀUÔ.Kó:
·c·c²cñ :
Ü.1°&·,±,¸sÀÐ2CÀUÔ.Kó:
ó 7
ˆ÷ Üðä˜fŸl™lÓ+Ð,Ð,GÌÈeËÀ~ÐUVðXó
ð 	
ñ r   c                  ó  a € ] tR t^ŠtRtR V 3R lltR R ltR R lt]R R	 l4       t	]R
 R l4       t	]R R l4       t	R R lt	]
R R l4       t]R R l4       tR R lt]R R l4       t]R R l4       tR R lt]R7R R ll4       t]R R l4       t]R8R  R! ll4       tR" R# lt]R8R$ R% ll4       t]R& R' l4       t]R( R) l4       t]R* R+ l4       tR, R- lt]R. R/ l4       t]R0 R1 l4       t]R2 R3 l4       t]R4 R5 l4       tR6t V ;t!# )9ÚSo3aú  Represent a 3D rotation as an SO(3) Lie group element stored as a quaternion.

``r = So3.exp(omega)`` builds rotations from rotation vectors ``omega`` of shape ``(B, 3)``, the axis times the
angle in radians; ``So3(q)`` wraps a ``(B, 4)`` :class:`~kornia.geometry.quaternion.Quaternion`,
:meth:`from_matrix` reads ``(B, 3, 3)`` matrices, and ``So3.identity(B)`` and ``So3.random(B)`` build ``B``
rotations, or an unbatched one with ``batch_size=None``. ``r1 * r2`` composes a batch with a batch of the same size,
a batch of one or an unbatched rotation; ``r.inverse()`` inverts, ``r.log()`` returns the ``(B, 3)`` rotation
vectors and ``r.matrix()`` the ``(B, 3, 3)`` matrices; an unbatched rotation drops the ``B``. ``r * p`` rotates
points as :math:`R p`: ``(3,)`` or ``(N, 3)`` points for an unbatched rotation, and ``(B, 3)``, one point per
rotation, or a single ``(1, 3)`` point, not ``(3,)``, for a batch of ``B``; a batch of one also maps ``(N, 3)``.
For a rotation and a translation, use :class:`Se3`; for
quaternion arithmetic, interpolation and Euler angles, :class:`~kornia.geometry.quaternion.Quaternion`.

SO(3) is the group of rotations of :math:`R^3` about the origin under composition; see
https://en.wikipedia.org/wiki/3D_rotation_group.

Convention:
    - The tangent vector is the rotation vector, the axis times the angle in radians, and ``hat(v)`` is its
      cross-product matrix: ``hat(v) @ p`` equals ``torch.linalg.cross(v, p)``. ``log()`` is
      ``q.to_axis_angle()``: it reads only the direction of ``q``, within the range limits stated on
      :class:`~kornia.geometry.quaternion.Quaternion`, and returns the principal vector, of norm at most
      :math:`\pi`, the same for ``q`` and ``-q`` below a half turn.
    - ``a * b`` composes like ``a.matrix() @ b.matrix()``, so ``b`` acts first; ``s * p`` rotates points ``p``, a
      tensor or a ``Vector3``, as :math:`R p`: ``(3,)`` or ``(N, 3)`` for an unbatched ``So3``, and ``(B, 3)``,
      one point per rotation, or ``(1, 3)``, not ``(3,)``, for a batch of ``B`` (a batch of one also maps
      ``(N, 3)``); other layouts raise ``ValueError``. ``adjoint()`` is :math:`R` itself.
      :ref:`Rotations and rigid motions <rotation-conventions>` compares these with scipy, Sophus and Eigen.
    - A non-unit quaternion stands for the rotation of its direction :math:`q / |q|`, as for
      :meth:`~kornia.geometry.quaternion.Quaternion.matrix`: ``matrix()`` and ``s * p`` normalise it where they
      use it, so ``matrix()`` is a rotation and ``s * p`` keeps the norm of ``p`` within the range limits stated
      on :class:`~kornia.geometry.quaternion.Quaternion`. ``q`` returns the quaternion as stored, which keeps an
      ``nn.Parameter`` registered and following optimiser steps.
    - For a small :math:`\delta`,
      :math:`\exp(\omega + \delta) \approx \exp(\omega) \exp(J_r \delta) = \exp(J_l \delta) \exp(\omega)`,
      with :math:`J_r` = ``right_jacobian(omega)`` and :math:`J_l` = ``left_jacobian(omega)`` =
      ``right_jacobian(-omega)``.
    - ``from_matrix`` does not check its input by default: a reflection (det :math:`-1`) is accepted without
      error and returns an ``So3`` whose ``matrix()`` is not the input. ``check_rotation=True`` raises
      ``ValueError`` instead.
    - The quaternion is registered as module state following
      :class:`~kornia.geometry.quaternion.Quaternion`'s buffer/parameter convention, including rotations
      produced by ``exp``, ``identity``, ``random``, ``from_matrix`` and group operations.
    - ``matrix()``, ``adjoint()``, ``a * b`` and ``s * p`` compute in float32 for float16/bfloat16 inputs and
      return the input dtype, rounding once; float32 and float64 are evaluated in their own dtype.

See Also:
    - :class:`So2`: the 2D rotation group, stored as a complex number.
    - :class:`Se3`: a 3D rotation followed by a translation, mapping points as :math:`R p + t`.
    - :class:`~kornia.geometry.quaternion.Quaternion`: the stored quaternion, with the Hamilton product,
      ``slerp`` and Euler angles but no action on points.
    - :func:`~kornia.geometry.conversions.axis_angle_to_rotation_matrix`: the matrix of ``So3.exp(v)`` in one
      call on a plain ``(*, 3)`` tensor.

Example:
    >>> q = Quaternion.identity()
    >>> s = So3(q)
    >>> s.q
    tensor([1., 0., 0., 0.])

c               ó    € V ^8„  d   QhRRRR/# )r   rG   r   r   r\   r   )r   s   "r   r   ÚSo3.__annotate__È   s   € ÷ ñ ˜*ð ¨ñ r   c                óP   <€ \         SV `  4        \        V\        4       Wn        R# )a5  Construct an So3 that stores the quaternion ``q`` as given.

Args:
    q: Quaternion with the shape of ``(B, 4)`` or ``(4,)``.

Example:
    >>> data = torch.tensor([[1., 0., 0., 0.], [0., 1., 0., 0.]])
    >>> q = Quaternion(data)
    >>> So3(q)
    tensor([[1., 0., 0., 0.],
            [0., 1., 0., 0.]])

N)ÚsuperÚ__init__r	   r   Ú_q)ÚselfrG   Ú	__class__s   &&€r   rs   ÚSo3.__init__È   s   ø€ ô 	‰ÑÔÜ˜!œZÔ(ØŽr   c               ó   € V ^8„  d   QhRR/# )r   r   Ústrr   )r   s   "r   r   rp   Ú   s   € ÷ ñ ˜#ñ r   c                	ó   € V P                    # ©N)rG   ©ru   s   &r   Ú__repr__ÚSo3.__repr__Ú   s   € Ø—&‘&�Ðr   c               ó    € V ^8„  d   QhRRRR/# )r   Úidxzint | slicer   rn   r   )r   s   "r   r   rp   Ý   s   € ÷ !ñ !˜{ð !¨sñ !r   c                	ó:   € \        V P                  V,          4      # r{   )rn   rt   )ru   r€   s   &&r   Ú__getitem__ÚSo3.__getitem__Ý   s   € Ü�4—7‘7˜3•<Ó Ð r   c               ó    € V ^8„  d   QhRRRR/# )r   Úrightrn   r   r   )r   s   "r   r   rp   á   s   € ×-Ñ-˜SÐ- SÑ-r   c                	ó   € R # r{   r   ©ru   r…   s   &&r   Ú__mul__ÚSo3.__mul__à   s   € Ù*-r   c               ó    € V ^8„  d   QhRRRR/# )r   r…   r   r   r   )r   s   "r   r   rp   ä   s   € ×5Ñ5˜WÐ5¨Ñ5r   c                	ó   € R # r{   r   r‡   s   &&r   rˆ   r‰   ã   s   € Ù25r   c               ó    € V ^8„  d   QhRRRR/# )r   r…   r   r   r   )r   s   "r   r   rp   ç   s   € ×?Ñ?˜\Ð?¨lÑ?r   c                	ó   € R # r{   r   r‡   s   &&r   rˆ   r‰   æ   s   € Ù<?r   c               ó    € V ^8„  d   QhRRRR/# )r   r…   zSo3 | Vector3 | torch.Tensorr   r   )r   s   "r   r   rp   é   s    € ÷ Mñ MÐ9ð MÐ>Zñ Mr   c                ó  € \        V\        4      '       Ed   \        P                  ! V P                  P
                  P                  VP                  P
                  P                  4      p\        V4      '       d…   V P                  P                  \        P                  4      VP                  P                  \        P                  4      ,          p\        \        VP
                  P                  V4      4      4      # \        V P                  VP                  ,          4      # \        V\        P                  \        34      '       d§   \        V4      p\        V P                  V4       \        V P                  V4      P                  \        P                  ! V P                  P
                  P                  VP                  4      4      p\        V\        4      '       d   \        V4      # T# \!        R\#        V4       24      h)a>  Compose two So3 transformations, or rotate points.

Both compute in float32 for float16/bfloat16 inputs and return the input dtype.

Args:
    right: the other So3 transformation, unbatched, a batch of the same size or a batch of one, or points
        as a tensor or a ``Vector3``: ``(3,)`` or ``(N, 3)`` for an unbatched rotation, and ``(B, 3)``, one
        point per rotation, or ``(1, 3)``, not ``(3,)``, for a batch of ``B`` (a batch of one also maps
        ``(N, 3)``).

Return:
    The resulting So3 transformation, or the rotated points of the type of ``right``.

z#Not So3 or torch.Tensor type. Got: )Ú
isinstancern   r   rM   rG   rN   r   rE   rO   rP   r   ÚTensorr   r
   rl   rZ   Ú	TypeErrorÚtype)ru   r…   r   ÚproductÚ_right_dataÚouts   &&    r   rˆ   r‰   é   sG  € ô  �eœS×!Ó!Ü×'Ò'¨¯©¯©×(9Ñ(9¸5¿7¹7¿<¹<×;MÑ;MÓNˆEÜ# E×*Ò*ØŸ&™&Ÿ)™)¤E§M¡MÓ2°U·W±W·Z±ZÄÇÁÓ5NÕN�Üœ: g§l¡l§o¡o°eÓ&<Ó=Ó>Ð>Ü�t—v‘v §¡Õ'Ó(Ð(Ü�eœeŸl™l¬GÐ4×5Ò5Ü! %›.ˆKÜ  §¡¨Ô5Ü˜dŸf™f kÓ2×5Ñ5´e×6IÒ6IÈ$Ï&É&Ï+É+×J[ÑJ[Ð]h×]nÑ]nÓ6oÓpˆCÜ#-¨e´W×#=Ò#=”7˜3“<ÐFÀ3ÐFÜÐ=¼dÀ5»k¸]ÐKÓLÐLr   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   rp     s   € ÷ ñ �:ñ r   c                ó   € V P                   # )zeReturn the stored :class:`~kornia.geometry.quaternion.Quaternion`: ``(B, 4)``, or ``(4,)`` unbatched.©rt   r|   s   &r   rG   ÚSo3.q  s   € ð �w‰wˆr   c               ó    € V ^8„  d   QhRRRR/# )r   Úvr   r   rn   r   )r   s   "r   r   rp     s   € ÷ &>ñ &>ˆ|ð &> ñ &>r   c                ó  € \        V RR.4       W ,          P                  RRR7      pVR8  p\        P                  ! W!\        P                  ! V4      4      p^VRVRVRVRVRVR,          ,           ,          ,           ,          ,           ,          ,           ,          ,           ,          ,           pRVRVRVRVRVR,          ,
          ,          ,           ,          ,           ,          ,           ,          ,           p\        P
                  ! \        P                  ! V4      \        P                  ! V R,          4      3RR	7      p\        P                  ! W&V 4      P                  RRR
7      p\        P                  ! W$\        P                  ! RV,          4      4      p\        P                  ! W%\        P                  ! RV,          4      V,          4      p	\        \        \        P
                  ! W‰V ,          3RR	7      4      4      # )a>  Convert elements of lie algebra to elements of lie group.

See more: https://vision.in.tum.de/_media/members/demmeln/nurlanov2021so3log.pdf

Args:
    v: vector of shape ``(B,3)``.

Example:
    >>> v = torch.zeros((2, 3))
    >>> s = So3.exp(v)
    >>> s
    tensor([[1., 0., 0., 0.],
            [1., 0., 0., 0.]])

rJ   rK   Tr5   g      Ð?l     €#r   l     PL )r8   r7   r9   g      À¿gUUUUUUe?glÁlÁö¾g  z>g\Ÿx·O~ò½gUUUUUU•¿g1?g  º¾g4ÇV¥ã7>).:r_   NN)r   r;   r   r    r"   rU   r!   r<   r#   r$   rn   r   )
rœ   r   r&   r)   Úw_seriesr+   Úunit_xr'   rX   r/   s
   &         r   ÚexpÚSo3.exp  s„  € ô" 	˜1˜s C˜jÔ)ð •E—;‘;˜r¨4�;Ó0ˆØ˜4‘ˆÜ�[Š[˜¬%×*:Ò*:¸8Ó*DÓEˆØ�rØØ�G˜b J°°|ÀbÈOÐ^`ÐcpÕ^pÕLpÕFqÕ7qÕ1rÕ$rÕsÕsÕtõuõ
õ 
ˆð ˜˜w¨¨x¸"ÀÈbÐTaÐdfÐitÕdtÕTtÕNuÕ@uÕ:vÕ/vÕ)wÕwÕxÕxˆÜ—’œEŸOšO¨HÓ5´u×7GÒ7GÈÈ'Í
Ó7SÐTÐZ\Ô]ˆÜ—[’[ °Ó2×7Ñ7¸BÈÐ7ÓMˆ
Ü�KŠK˜¬¯ª°3¸Õ3CÓ)DÓEˆÜ�KŠK˜¬¯ª°3¸Õ3CÓ)DÀzÕ)QÓRˆÜ”:œeŸiši¨°­E¨
¸Ô;Ó<Ó=Ð=r   c               ó   € V ^8„  d   QhRR/# ©r   r   r   r   )r   s   "r   r   rp   4  s   € ÷ >ñ >�\ñ >r   c                óR   € \        \        V P                  P                  4      4      # )z¤Convert elements of lie group  to elements of lie algebra.

Example:
    >>> So3.identity(batch_size=2).log()
    tensor([[0., 0., 0.],
            [0., 0., 0.]])

)r   r
   rG   rN   r|   s   &r   ÚlogÚSo3.log4  s   € ô (¬°·±·±Ó(<Ó=Ð=r   c               ó    € V ^8„  d   QhRRRR/# )r   rœ   zVector3 | torch.Tensorr   r   r   )r   s   "r   r   rp   F  s   € ÷ 3ñ 3Ð%ð 3¨,ñ 3r   c                óÔ  € \        V RR.4       \        V \        P                  4      '       d   V R,          V R,          V R,          r2pM#V P                  V P
                  V P                  r2p\        P                  ! V4      p\        P                  ! WC) V3R4      p\        P                  ! W4V) 3R4      p\        P                  ! V) W3R4      p\        P                  ! WVV3R4      # )a8  Convert elements from vector space to lie algebra. Returns matrix of shape ``(B,3,3)``.

Args:
    v: Vector3 or torch.Tensor of shape ``(B,3)``.

Example:
    >>> v = torch.ones((1,3))
    >>> m = So3.hat(v)
    >>> m
    tensor([[[ 0., -1.,  1.],
             [ 1.,  0., -1.],
             [-1.,  1.,  0.]]])

rJ   rK   ).r   ).r_   ).r   r9   éþÿÿÿ)	r   r�   r   r‘   ÚxÚyÚzr"   Ústack)rœ   r.   r/   r0   r¬   Úrow0Úrow1Úrow2s   &       r   ÚhatÚSo3.hatE  s»   € ô  	˜1˜s C˜jÔ)Ü�aœŸ™×&Ò&à˜•i  6¥¨A¨f­I�!ˆA�!à—c‘c˜1Ÿ3™3 §¡�!ˆAÜ×Ò˜QÓˆÜ�{Š{˜A˜r 1˜: rÓ*ˆÜ�{Š{˜A 1 "˜: rÓ*ˆÜ�{Š{˜Q˜B ˜: rÓ*ˆÜ�{Š{˜D¨Ð-¨rÓ2Ð2r   c               ó    € V ^8„  d   QhRRRR/# )r   Úomegar   r   r   )r   s   "r   r   rp   b  s   € ÷ *ñ *�<ð * Lñ *r   c                ó„   € \        V . RO4       V R,          V R,          V R,          r2p\        P                  ! WV3R4      # )af  Convert elements from lie algebra to vector space. Returns vector of shape ``(B,3)``.

.. math::
    omega = \begin{bmatrix} 0 & -c & b \\
    c & 0 & -a \\
    -b & a & 0\end{bmatrix}

Args:
    omega: 3x3-matrix representing lie algebra.

Example:
    >>> v = torch.ones((1,3))
    >>> omega = So3.hat(v)
    >>> So3.vee(omega)
    tensor([[1., 1., 1.]])

)rJ   rK   rK   ).r   r_   ).r   r   ).r_   r   r9   )r   r   r­   )r´   r.   r/   r0   s   &   r   ÚveeÚSo3.veea  s=   € ô& 	˜5¢/Ô2Ø˜	Õ" E¨)Õ$4°e¸IÕ6FˆaˆÜ�{Š{˜A !˜9 bÓ)Ð)r   c               ó   € V ^8„  d   QhRR/# r£   r   )r   s   "r   r   rp   x  s   € ÷ (=ñ (=˜ñ (=r   c                ó.  € V P                   P                  P                  p\        V4      '       d*   V P                   P	                  \
        P                  4      MV P                   pVP                  4       pVP                  R,          pVP                  R,          VP                  R,          VP                  R,          rep^^V^,          ,          ,
          ^V^,          ,          ,
          p^V,          V,          ^V,          V,          ,
          p^V,          V,          ^V,          V,          ,           p	\
        P                  ! WxV	3R4      p
^V,          V,          ^V,          V,          ,           p^^V^,          ,          ,
          ^V^,          ,          ,
          p^V,          V,          ^V,          V,          ,
          p	\
        P                  ! WxV	3R4      p^V,          V,          ^V,          V,          ,
          p^V,          V,          ^V,          V,          ,           p^^V^,          ,          ,
          ^V^,          ,          ,
          p	\
        P                  ! WxV	3R4      p\
        P                  ! W«V3R4      P	                  V4      # )a  Convert the quaternion to a rotation matrix of shape ``(B,3,3)``.

The matrix is of the form, with :math:`(w, x, y, z)` the unit quaternion :math:`q / |q|`:

.. math::
    \begin{bmatrix} 1-2y^2-2z^2 & 2xy-2zw & 2xz+2yw \\
    2xy+2zw & 1-2x^2-2z^2 & 2yz-2xw \\
    2xz-2yw & 2yz+2xw & 1-2x^2-2y^2\end{bmatrix}

It computes in float32 for float16/bfloat16 inputs and returns the input dtype.

Example:
    >>> s = So3.identity()
    >>> m = s.matrix()
    >>> m
    tensor([[1., 0., 0.],
            [0., 1., 0.],
            [0., 0., 1.]])

r:   r9   r©   )rG   rN   r   rE   rO   r   rP   rV   rX   rª   r«   r¬   rU   r­   )ru   r   rG   rX   rª   r«   r¬   Úq0Úq1Úq2r®   r¯   r°   s   &            r   ÚmatrixÚ
So3.matrixx  sË  € ð. —‘—‘×!Ñ!ˆÜ(<¸U×(CÒ(CˆD�F‰F�I‰I”e—m‘mÔ$ÈÏÉˆØ�K‰K‹MˆØ�C‰C�	�NˆØ—#‘#�i•. !§#¡# i¥.°!·#±#°iµ.ˆaˆØ��Q˜•T•�\˜A  1¥�HÕ$ˆØ��U�Q�Y˜˜Q� �Õ"ˆØ��U�Q�Y˜˜Q� �Õ"ˆÜ�yŠy˜" "˜ rÓ*ˆØ��U�Q�Y˜˜Q� �Õ"ˆØ��Q˜•T•�\˜A  1¥�HÕ$ˆØ��U�Q�Y˜˜Q� �Õ"ˆÜ�yŠy˜" "˜ rÓ*ˆØ��U�Q�Y˜˜Q� �Õ"ˆØ��U�Q�Y˜˜Q� �Õ"ˆØ��Q˜•T•�\˜A  1¥�HÕ$ˆÜ�yŠy˜" "˜ rÓ*ˆÜ�{Š{˜D¨Ð-¨rÓ2×5Ñ5°eÓ<Ð<r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r½   r   Úcheck_rotationrA   r   rn   r   )r   s   "r   r   rp   £  s'   € ÷ Rñ R ð R¸tð RÐPSñ Rr   c                ó<   € V ! \         P                  ! WR7      4      # )a?  Create So3 from a rotation matrix.

Args:
    matrix: the rotation matrix to convert of shape ``(B,3,3)``.
    check_rotation: if ``True``, raise ``ValueError`` unless every input
        is a rotation matrix. The default ``False`` keeps the unchecked
        behaviour, under which a reflection such as ``diag(-1, 1, 1)``
        is silently turned into the identity. Note that
        ``So2.from_matrix`` rejects the 2D reflection ``diag(1, -1)``
        regardless.

Example:
    >>> m = torch.eye(3)
    >>> s = So3.from_matrix(m)
    >>> s
    tensor([1., 0., 0., 0.])

)rÀ   )r   Úfrom_matrix)Úclsr½   rÀ   s   &&&r   rÂ   ÚSo3.from_matrix¢  s   € ñ( ”:×)Ò)¨&ÔPÓQÐQr   c               ó    € V ^8„  d   QhRRRR/# )r   Úwxyzr   r   rn   r   )r   s   "r   r   rp   ¹  s   € ÷ %ñ %˜\ð %¨cñ %r   c                ó@   € \        VRR.4       V ! \        V4      4      # )zóCreate So3 from a torch.Tensor representing a quaternion.

Args:
    wxyz: the quaternion to convert of shape ``(B,4)``.

Example:
    >>> q = torch.tensor([1., 0., 0., 0.])
    >>> s = So3.from_wxyz(q)
    >>> s
    tensor([1., 0., 0., 0.])

rJ   Ú4)r   r   )rÃ   rÆ   s   &&r   Ú	from_wxyzÚSo3.from_wxyz¸  s"   € ô 	˜4 # s Ô,Ù”:˜dÓ#Ó$Ð$r   c               ó(   € V ^8„  d   QhRRRRRRRR/# ©	r   Ú
batch_sizezOptional[int]rL   zUnion[str, torch.device, None]r   zUnion[torch.dtype, None]r   rn   r   )r   s   "r   r   rp   Ê  s8   € ÷ Cñ Cà!ðCð /ðCð (ð	Cð
 
ñCr   c                ó<   € V ! \         P                  ! WV4      4      # )a{  Create a So3 group representing an identity rotation.

Args:
    batch_size: the batch size of the underlying data.
    device: device to place the result on.
    dtype: dtype of the result.

Example:
    >>> s = So3.identity()
    >>> s
    tensor([1., 0., 0., 0.])

    >>> s = So3.identity(batch_size=2)
    >>> s
    tensor([[1., 0., 0., 0.],
            [1., 0., 0., 0.]])

)r   Úidentity©rÃ   rÍ   rL   r   s   &&&&r   rÏ   ÚSo3.identityÉ  s   € ñ2 ”:×&Ò& z¸5ÓAÓBÐBr   c               ó   € V ^8„  d   QhRR/# )r   r   rn   r   )r   s   "r   r   rp   ä  s   € ÷ 	"ñ 	"˜ñ 	"r   c                óH   € \        V P                  P                  4       4      # )z}Return the inverse transformation.

Example:
    >>> s = So3.identity()
    >>> s.inverse()
    tensor([1., -0., -0., -0.])

)rn   rG   rW   r|   s   &r   ÚinverseÚSo3.inverseä  s   € ô �4—6‘6—;‘;“=Ó!Ð!r   c               ó(   € V ^8„  d   QhRRRRRRRR/# rÌ   r   )r   s   "r   r   rp   ð  s8   € ÷ Añ Aà!ðAð /ðAð (ð	Að
 
ñAr   c                ó<   € V ! \         P                  ! WV4      4      # )a  Create a So3 group representing a random rotation.

Args:
    batch_size: the batch size of the underlying data.
    device: device to place the result on.
    dtype: dtype of the result.

Example:
    >>> s = So3.random()
    >>> s = So3.random(batch_size=3)

)r   ÚrandomrÐ   s   &&&&r   rØ   Ú
So3.randomï  s   € ñ& ”:×$Ò$ Z¸Ó?Ó@Ð@r   c               ó    € V ^8„  d   QhRRRR/# )r   rª   r   r   rn   r   )r   s   "r   r   rp     ó   € ÷ 5ñ 5�lð 5 sñ 5r   c                ó~   € \         P                  ! V4      pV P                  \         P                  ! WV3R4      4      # )zGConstruct a x-axis rotation.

Args:
    x: the x-axis rotation angle.

r9   ©r   r"   r    r­   )rÃ   rª   Úzss   && r   Úrot_xÚ	So3.rot_x  s2   € ô ×Ò˜aÓ ˆØ�w‰w”u—{’{ A¨2 ;°Ó3Ó4Ð4r   c               ó    € V ^8„  d   QhRRRR/# )r   r«   r   r   rn   r   )r   s   "r   r   rp     rÛ   r   c                ó~   € \         P                  ! V4      pV P                  \         P                  ! W!V3R4      4      # )zGConstruct a y-axis rotation.

Args:
    y: the y-axis rotation angle.

r9   rÝ   )rÃ   r«   rÞ   s   && r   Úrot_yÚ	So3.rot_y  s2   € ô ×Ò˜aÓ ˆØ�w‰w”u—{’{ B¨2 ;°Ó3Ó4Ð4r   c               ó    € V ^8„  d   QhRRRR/# )r   r¬   r   r   rn   r   )r   s   "r   r   rp     rÛ   r   c                ó~   € \         P                  ! V4      pV P                  \         P                  ! W"V3R4      4      # )zGConstruct a z-axis rotation.

Args:
    z: the z-axis rotation angle.

r9   rÝ   )rÃ   r¬   rÞ   s   && r   Úrot_zÚ	So3.rot_z  s2   € ô ×Ò˜aÓ ˆØ�w‰w”u—{’{ B¨A ;°Ó3Ó4Ð4r   c               ó   € V ^8„  d   QhRR/# r£   r   )r   s   "r   r   rp   %  s   € ÷ ñ ˜ñ r   c                ó"   € V P                  4       # )z»Return the adjoint matrix of shape ``(B, 3, 3)``.

Example:
    >>> s = So3.identity()
    >>> s.adjoint()
    tensor([[1., 0., 0.],
            [0., 1., 0.],
            [0., 0., 1.]])

)r½   r|   s   &r   ÚadjointÚSo3.adjoint%  s   € ð �{‰{‹}Ðr   c               ó    € V ^8„  d   QhRRRR/# ©r   r3   r   r   r   )r   s   "r   r   rp   3  s   € ÷ 6ñ 6˜Lð 6¨\ñ 6r   c                óð   € \        V RR.4       \        V 4      p\        V 4      w  r#p\        P                  ! ^V P
                  V P                  R7      pWRV,          ,
          W1V,          ,          ,           # )a+  Compute the right Jacobian of So3.

Args:
    vec: the tangent vector of shape ``(B, 3)``.

Example:
    >>> vec = torch.tensor([1., 2., 3.])
    >>> So3.right_jacobian(vec)
    tensor([[-0.0687,  0.5556, -0.0141],
            [-0.2267,  0.1779,  0.6236],
            [ 0.5074,  0.3629,  0.5890]])

rJ   rK   ©rL   r   ©r   r   r?   r   ÚeyerL   r   ©r3   ÚR_skewr.   r/   Ú_ÚIs   &     r   Úright_jacobianÚSo3.right_jacobian2  ó\   € ô 	˜3  c 
Ô+Ü0°Ó5ˆÜ,¨SÓ1‰ˆˆaÜ�IŠI�a §
¡
°#·)±)Ô<ˆØ�v•:�~ ¨f¥_Õ 5Õ5Ð5r   c               ó    € V ^8„  d   QhRRRR/# rî   r   )r   s   "r   r   rp   H  s   € ÷ 'ñ '�ð ' ñ 'r   c                ó,   € \         P                  V 4      # )zSAlias for right jacobian.

Args:
    vec: the tangent vector of shape ``(B, 3)``.

)rn   r÷   ©r3   s   &r   ÚJrÚSo3.JrG  s   € ô ×!Ñ! #Ó&Ð&r   c               ó    € V ^8„  d   QhRRRR/# rî   r   )r   s   "r   r   rp   R  s   € ÷ 6ñ 6˜<ð 6¨Lñ 6r   c                óð   € \        V RR.4       \        V 4      p\        V 4      w  r#p\        P                  ! ^V P
                  V P                  R7      pWRV,          ,           W1V,          ,          ,           # )a)  Compute the left Jacobian of So3.

Args:
    vec: the tangent vector of shape ``(B, 3)``.

Example:
    >>> vec = torch.tensor([1., 2., 3.])
    >>> So3.left_jacobian(vec)
    tensor([[-0.0687, -0.2267,  0.5074],
            [ 0.5556,  0.1779,  0.3629],
            [-0.0141,  0.6236,  0.5890]])

rJ   rK   rð   rñ   ró   s   &     r   Úleft_jacobianÚSo3.left_jacobianQ  rù   r   c               ó    € V ^8„  d   QhRRRR/# rî   r   )r   s   "r   r   rp   g  s   € ÷ &ñ &�ð & ñ &r   c                ó,   € \         P                  V 4      # )zRAlias for left jacobian.

Args:
    vec: the tangent vector of shape ``(B, 3)``.

)rn   r  rü   s   &r   ÚJlÚSo3.Jlf  s   € ô × Ñ  Ó%Ð%r   r™   )F)NNN)"Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rs   r}   r‚   r   rˆ   ÚpropertyrG   Ústaticmethodr    r¥   r±   r¶   r½   ÚclassmethodrÂ   rÉ   rÏ   rÔ   rØ   rß   rã   rç   rë   r÷   rý   r  r  Ú__static_attributes__Ú__classcell__)rv   s   @r   rn   rn   Š   s—  ø† ñ;÷zð õ$õ!ð Ü-ó Ø-àÜ5ó Ø5àÜ?ó Ø?õMð: ôó ðð ô&>ó ð&>õP>ð" ô3ó ð3ð6 ô*ó ð*õ,(=ðT öRó ðRð* ô%ó ð%ð  öCó ðCõ4	"ð öAó ðAð( ô5ó ð5ð ô5ó ð5ð ô5ó ð5õð ô6ó ð6ð( ô'ó ð'ð ô6ó ð6ð( ô&ó ö&r   rn   r{   )Ú
__future__r   Útypingr   r   r   r   r   Úkornia.core.checkr   r	   Úkornia.core.tensor_wrapperr
   Úkornia.geometry.conversionsr   r   Úkornia.geometry.quaternionr   Úkornia.geometry.vectorr   r1   r?   rE   rZ   rl   ÚModulern   r   r   r   Ú<module>r     sR   ðõ( #ç ,Ñ ,ã Ý ç CÝ .ß aÝ 1Ý *÷,õ^	Põ4õ
%õ&
ô*d&ˆ"�)‰)ö d&r   