+
    úäûjˆ  ã                   ó”   € ^ RI HtHtHtHtHt ^ RIt^ RIt^ RIH	t
 ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHtHt  ! R	 R
]4      tR# )é    )ÚAnyÚDictÚOptionalÚTupleÚUnionN)Úrandom_generator)ÚGeometricAugmentationBase3D)ÚResample)Ú_to_device_nonblocking)Úaffine3d)Ú_compute_rotation_matrix3dÚ_compute_tensor_center3dc                   ó    a a€ ] tR t^t oRt]P                  P                  RRRR3V3R lV 3R llltV3R lR lt	RV3R lR	 llt
R
tVtV ;t# )ÚRandomRotation3Daî  Rotate 3D volumes by a random axis-angle rotation, applied per sample with probability ``p`` (default 0.5).

``output = RandomRotation3D(degrees, ...)(input)`` rotates volumes of shape ``(B, C, D, H, W)``.

Args:
    degrees: Range of degrees to select from.
        If degrees is a number, then yaw, pitch, roll will be generated from the range of (-degrees, +degrees).
        If degrees is a tuple of (min, max), then yaw, pitch, roll will be generated from the range of (min, max).
        If degrees is a list of floats [a, b, c], then yaw, pitch, roll will be generated from (-a, a), (-b, b)
        and (-c, c).
        If degrees is a list of tuple ((a, b), (m, n), (x, y)), then yaw, pitch, roll will be generated from
        (a, b), (m, n) and (x, y).
        Set to 0 to deactivate rotations.
    resample: resample mode from "nearest" (0) or "bilinear" (1).
    same_on_batch: apply the same transformation across the batch.
    align_corners: interpolation flag.
    p: probability of applying the transformation to each sample.
    keepdim: whether to keep the output shape the same as input (True) or broadcast it
      to the batch form (False).

Shape:
    - Input: ``(C, D, H, W)`` or ``(B, C, D, H, W)``
    - Output: ``(B, C, D, H, W)``

Note:
    Input torch.Tensor must be float and normalized into [0, 1] for the best differentiability support.

Convention:
    See :class:`~kornia.augmentation.GeometricAugmentationBase3D` for the shared 3D geometry contract.

    - each sampled ``degrees`` triple ``(yaw, pitch, roll) = (rx, ry, rz)`` is **one axis-angle vector**
      in degrees and is converted into a single Rodrigues rotation, not composed as per-axis Euler
      rotations, exactly as :func:`kornia.geometry.transform.rotate3d` does. The rotation axis
      is ``(rx, ry, rz) / ||(rx, ry, rz)||`` and the angle is ``||(rx, ry, rz)||`` degrees, so a
      sampled ``(90, 90, 0)`` turns through ``90 * sqrt(2)`` degrees about ``(1, 1, 0) / sqrt(2)``
      while a sampled ``(30, 0, 0)`` is a 30-degree turn about ``x``. One non-zero component is
      therefore the per-axis rotation it names; two or more are not, and neither Euler order
      reproduces the axis-angle result. To rotate about the axes in turn, compose the rotation
      matrix yourself and convert it with
      :func:`~kornia.geometry.conversions.rotation_matrix_to_axis_angle`, which returns radians.
    - A positive roll turns a displayed ``H x W`` slice clockwise, as
      :func:`kornia.geometry.transform.rotate3d` does; :class:`RandomAffine3D`, the 2D
      :class:`~kornia.augmentation.RandomRotation` and
      :func:`kornia.geometry.transform.rotate` turn it counter-clockwise
      (`#4408 <https://github.com/kornia/kornia/issues/4408>`_).
    - the default interpolation is bilinear with ``align_corners=False``.

See Also:
    - :class:`RandomAffine3D`: samples a combined 3D affine transformation.
    - :class:`RandomRotation`: rotates 2D images by a sampled angle.

Examples:
    >>> import torch
    >>> rng = torch.manual_seed(0)
    >>> input = torch.rand(1, 1, 3, 3, 3)
    >>> aug = RandomRotation3D((15., 20., 20.), p=1.0)
    >>> aug(input), aug.transform_matrix
    (tensor([[[[[0.3819, 0.4886, 0.2111],
               [0.1196, 0.3833, 0.4722],
               [0.3432, 0.5951, 0.4223]],
    <BLANKLINE>
              [[0.5553, 0.4374, 0.2780],
               [0.2423, 0.1689, 0.4009],
               [0.4516, 0.6376, 0.7327]],
    <BLANKLINE>
              [[0.1605, 0.3112, 0.3673],
               [0.4931, 0.4620, 0.5700],
               [0.3505, 0.4685, 0.8092]]]]]), tensor([[[ 0.9722,  0.1131, -0.2049,  0.1196],
             [-0.0603,  0.9669,  0.2478, -0.1545],
             [ 0.2262, -0.2286,  0.9469,  0.0556],
             [ 0.0000,  0.0000,  0.0000,  1.0000]]]))

To apply the exact augmenation again, you may take the advantage of the previous parameter state:
    >>> input = torch.rand(1, 3, 32, 32, 32)
    >>> aug = RandomRotation3D((15., 20., 20.), p=1.)
    >>> (aug(input) == aug(input, params=aug._params)).all()
    tensor(True)

Fg      à?c                ó  <€ V ^8„  d   QhRS[ S[P                  S[S[S[S[S[3,          S[S[S[S[3,          S[S[S[3,          S[S[S[3,          3,          3,          RS[ S[S[S[3,          RS[RS[RS[RS[RR/# )	é   ÚdegreesÚresampleÚsame_on_batchÚalign_cornersÚpÚkeepdimÚreturnN)	r   ÚtorchÚTensorÚfloatr   ÚstrÚintr
   Úbool)ÚformatÚ__classdict__s   "€ÚfC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_3d\geometric\rotation.pyÚ__annotate__ÚRandomRotation3D.__annotate__p   s´   ø€ ÷ @ñ @áÙ�L‰LÙÙ‘%™¡Ð%Õ&Ù‘%™™u˜Õ%¡u©U±E¨\Õ':¹EÁ%ÉÀ,Õ<OÐOÕPðRõ
ð@ñ ™™S¡(Ð*Õ+ð@ñ ð@ñ ð@ñ ð@ñ ð@ð 
ñ@ó    c                óž   <€ \         SV `  WSVR 7       R\        P                  ! V4      RV/V n        \
        P                  ! V4      V n        R# ))r   r   r   r   r   N)ÚsuperÚ__init__r
   ÚgetÚflagsÚrgÚRotationGenerator3DÚ_param_generator)Úselfr   r   r   r   r   r   Ú	__class__s   &&&&&&&€r"   r(   ÚRandomRotation3D.__init__p   sC   ø€ ô 	‰Ñ˜1À7ÐÔKØ ¤(§,¢,¨xÓ"8¸/È=ÐYˆŒ
Ü "× 6Ò 6°wÓ ?ˆÖr%   c                óš   <€ V ^8„  d   QhRS[ P                  RS[S[S[ P                  3,          RS[S[S[3,          RS[ P                  /# )r   ÚinputÚparamsr*   r   )r   r   r   r   r   )r    r!   s   "€r"   r#   r$   ‚   sN   ø€ ÷ ñ Ù—\‘\ðÙ+/±±U·\±\Ð0AÕ+BðÙKOÑPSÑUXÐPXÍ>ðá	�‰ñr%   c           	     ó  € \        VR ,          VP                  VP                  4      p\        VR,          VP                  VP                  4      p\        VR,          VP                  VP                  4      p\        V4      p\	        WEWgP                  VP                  ^ ,          R4      4      p\        P                  P                  P                  ^V4      p	VR,          V	R&   VR,          V	R&   VR,          V	R&   V	# )ÚyawÚpitchÚrolléÿÿÿÿ)ºNNNr   )r9   é   )r9   r   )r   ÚdeviceÚdtyper   r   ÚexpandÚshapeÚkorniaÚcoreÚopsÚeye_like)
r.   r2   r3   r*   r5   r6   r7   ÚcenterÚrotation_matÚ	trans_mats
   &&&&      r"   Úcompute_transformationÚ'RandomRotation3D.compute_transformation‚   sØ   € ô 3°6¸%µ=À%Ç,Á,ÐPU×P[ÑP[Ó\ˆÜ4°V¸Gµ_ÀeÇlÁlÐTY×T_ÑT_Ó`ˆÜ3°F¸6µNÀEÇLÁLÐRW×R]ÑR]Ó^ˆä7¸Ó>ˆÜ%?ÀÈD×R_ÑR_Ð`c×`iÑ`iÐjkÕ`lÐnpÓRqÓ%rˆô #)§+¡+§/¡/×":Ñ":¸1¸eÓ"Dˆ	Ø& tÕ,ˆ	�$‰Ø& tÕ,ˆ	�$‰Ø& tÕ,ˆ	�$‰àÐr%   c          
      óÄ   <€ V ^8„  d   QhRS[ P                  RS[S[S[ P                  3,          RS[S[S[3,          RS[S[ P                  ,          RS[ P                  /# )r   r2   r3   r*   Ú	transformr   )r   r   r   r   r   r   )r    r!   s   "€r"   r#   r$   ”   sk   ø€ ÷ 
xñ 
xá�|‰|ð
xñ ‘S™%Ÿ,™,Ð&Õ'ð
xñ ‘C™�H�~ð	
xñ
 ™EŸL™LÕ)ð
xñ 
�‰ñ
xr%   c                óæ   € \        V\        P                  4      '       g   \        R \	        V4       24      h\        WR,          VR,          P                  P                  4       RVR,          4      # )z1Expected the transform to be a torch.Tensor. Got r   Úzerosr   ).:Né   N:Né   N)Ú
isinstancer   r   Ú	TypeErrorÚtyper   ÚnameÚlower)r.   r2   r3   r*   rI   s   &&&&&r"   Úapply_transformÚ RandomRotation3D.apply_transform”   sb   € ô ˜)¤U§\¡\×2Ò2ÜÐOÔPTÐU^ÓP_ÐO`ÐaÓbÐbä˜¨Õ5°u¸ZÕ7H×7MÑ7M×7SÑ7SÓ7UÐW^Ð`eÐfuÕ`vÓwÐwr%   )r-   r*   )N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r
   ÚBILINEARrQ   r(   rF   rS   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r/   r!   s   @@r"   r   r      sQ   ù‡ € ñNðp /7×.?Ñ.?×.DÑ.DØ#Ø#ØØ÷@õ @÷$ð ÷$
x÷ 
xò 
xr%   r   )Útypingr   r   r   r   r   r   r?   Úkornia.augmentationr   r+   Ú&kornia.augmentation._3d.geometric.baser	   Úkornia.constantsr
   Úkornia.core.utilsr   Úkornia.geometryr   Ú!kornia.geometry.transform.affwarpr   r   r   © r%   r"   Ú<module>rf      s6   ð÷$ 5Õ 4ã ã Ý 6Ý NÝ %Ý 4Ý $ß bôxÐ2ö xr%   