+
    åûjßB  ã                   ó´   € R t ^ RIHt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Ot ! R
 R]
4      t ! R R	]
4      t ! R R]
4      t]t]tR# )a  2D and 3D vector and scalar wrappers that planes, Lie groups and cameras take.

:class:`Vector3`, :class:`Vector2` and :class:`Scalar` wrap a tensor without copying it, of shape ``(*, 3)``,
``(*, 2)`` and any shape. They are not ``torch.Tensor`` subclasses: ``v.data`` is the wrapped tensor. Torch
functions, tensor methods and operators accept a wrapper and wrap their result by the rule of
:class:`~kornia.core.TensorWrapper`, while kornia functions that check for a tensor raise on one.

Which class to use:

- 3D points, directions and normals: :class:`Vector3`. :class:`~kornia.geometry.plane.Hyperplane` takes its normal
  as one, and :class:`~kornia.geometry.liegroup.So3` and :class:`~kornia.geometry.liegroup.Se3` map a ``Vector3`` to
  a ``Vector3``.
- 2D points and directions: :class:`Vector2`. :class:`~kornia.geometry.liegroup.So2` and
  :class:`~kornia.geometry.liegroup.Se2` map a ``Vector2`` to a ``Vector2``, and the camera models of
  ``kornia.sensors.camera`` (:class:`~kornia.sensors.camera.CameraModelBase`) project a ``Vector3`` to one.
- One value per vector, such as a dot product or the offset of a plane: :class:`Scalar`.
- Points for kornia's tensor functions, such as :func:`~kornia.geometry.linalg.transform_points`: plain ``(*, 3)``
  or ``(*, 2)`` tensors, or ``v.data``.
)ÚOptionalÚTupleÚUnionÚcastN)ÚKORNIA_CHECK)ÚTensorWrapperÚ_wrap)Ú_normalize_last_dim)Úbatched_dot_productÚbatched_squared_normÚScalarÚVector2ÚVector3c                   óB   a a€ ] tR t^3t oRtV3R lV 3R lltRtVtV ;t# )r   a  Wrap a tensor of scalars of any shape, such as dot products and plane offsets.

``s = Scalar(values)`` wraps a tensor of any shape without copying it; it adds no methods, and ``s.data`` is the
tensor. :meth:`Vector3.dot` and :meth:`Vector3.squared_norm` return one, and
:class:`~kornia.geometry.plane.Hyperplane` takes its offset as one and returns its distances as one. An operation
between a ``Scalar`` and a :class:`Vector3` follows the rule of :class:`~kornia.core.TensorWrapper`, so ``s * v``
is a ``Vector3`` like ``v * s``. Broadcasting follows the wrapped tensors and adds no coordinate axis: the
``(B,)`` result of :meth:`Vector3.dot` meets the last axis of ``(B, 3)`` vectors, so ``s * v`` scales
coordinates for ``B == 3``, scales the one vector for ``B == 1`` and raises for any other ``B``. Scale vector by
vector with ``s.data[..., None] * v``.

See Also:
    - :class:`Vector3`: 3D vectors ``(*, 3)``, whose dot products and squared norms come back as a ``Scalar``.
    - :class:`Vector2`: 2D vectors ``(*, 2)``, likewise.
c                ó8   <€ V ^8„  d   QhRS[ P                  RR/# )é   ÚdataÚreturnN©ÚtorchÚTensor)ÚformatÚ__classdict__s   "€ÚRC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\geometry\vector.pyÚ__annotate__ÚScalar.__annotate__D   s   ø€ ÷ ñ ™UŸ\™\ð ¨dñ ó    c                ó&   <€ \         SV `  V4       R # )N)ÚsuperÚ__init__)Úselfr   Ú	__class__s   &&€r   r   ÚScalar.__init__D   s   ø€ Ü‰Ñ˜Ör   © )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©r!   r   s   @@r   r   r   3   s   ù‡ € ñ÷ ÷ ó r   c                   ó"  a a€ ] tR t^Ht oRt^tV3R lV 3R lltV3R lR lt]V3R lR l4       t	]V3R lR	 l4       t
]V3R
 lR l4       tV3R lR ltV3R lR ltV3R lR lt]RV3R lR ll4       t]RV3R lR ll4       tRtVtV ;t# )r   af  Wrap a ``(*, 3)`` tensor of 3D vectors, with coordinates, dot products and normalisation.

``v = Vector3(points)`` wraps a ``(*, 3)`` tensor without copying it, and ``Vector3.from_coords(x, y, z)`` and
``Vector3.random(shape)`` build one; ``v.x``, ``v.y`` and ``v.z`` are plain ``(*)`` tensors, ``v.dot(w)`` and
``v.squared_norm()`` return a :class:`Scalar` ``(*)``, and ``v.normalized()`` the unit vectors, with the norm
floored at ``1e-12``. A ``Vector3`` is not a ``torch.Tensor``: torch functions, tensor methods and operators
accept it (``torch.linalg.cross(v, w)`` is a ``Vector3``), but a kornia function that checks for a tensor, such
as :func:`~kornia.geometry.linalg.transform_points`, raises, so pass it ``v.data``. For 2D vectors, use
:class:`Vector2` instead.

Convention:
    - The tensor is wrapped without a copy; any leading shape and dtype are accepted, and a last axis other than
      3 raises ``BaseError``. :attr:`x`, :attr:`y` and :attr:`z` are plain tensors of the leading shape ``(*)``,
      and :meth:`dot` and :meth:`squared_norm` return a :class:`Scalar` of that shape (for :meth:`dot`, the two
      operands' broadcast leading shape).
    - :meth:`random` draws vectors uniformly in the unit cube from torch's global generator, so every vector
      lies in the first octant: it is not a random direction.
    - ``copy.deepcopy``, ``copy.copy`` and pickle return a ``Vector3``. An in-place operator such as ``v += 1``
      updates the wrapped tensor, so an alias and the tensor the vector was built from see the change; the
      operator rules are those of :class:`~kornia.core.TensorWrapper`.
    - A result is a ``Vector3`` when it still holds 3D vectors, whether a torch function, a tensor method or an
      operator produced it, and whichever side a :class:`Scalar` is on: ``torch.clone(v)``, ``v.clone()``,
      ``s * v`` and ``v * s`` are ``Vector3``. A result that does not end in 3, or that lost an axis, is a
      plain tensor: ``torch.linalg.norm(v, dim=-1)`` and ``v.norm(dim=-1)``, also for three vectors. The full
      rule is in :class:`~kornia.core.TensorWrapper`.
    - Indexing the leading axes returns a ``Vector3`` (``v[0]``, ``v[1:]``, ``v[mask]``). An index into the
      coordinate axis returns a plain tensor, like the same index into the wrapped tensor: ``v[..., 0]`` and
      ``v[:, 0]`` have the leading shape, and an unbatched ``v[0]`` is 0-d.

See Also:
    - :class:`Vector2`: the 2D vector ``(*, 2)``, with ``x`` and ``y`` only.
    - :class:`Scalar`: the wrapper for one value per vector, which :meth:`dot` and :meth:`squared_norm` return.
    - :class:`~kornia.core.TensorWrapper`: the base class, whose rule decides which results stay a ``Vector3``.

Example:
    >>> v = Vector3.from_coords(3.0, 0.0, 4.0)
    >>> v.normalized().data
    tensor([0.6000, 0.0000, 0.8000])
    >>> v.dot(Vector3(torch.tensor([1.0, 1.0, 1.0]))).data
    tensor(7.)
c                ó8   <€ V ^8„  d   QhRS[ P                  RR/# ©r   Úvectorr   Nr   )r   r   s   "€r   r   ÚVector3.__annotate__u   ó   ø€ ÷ ,ñ ,™uŸ|™|ð ,°ñ ,r   c                ód   <€ \         SV `  V4       \        VP                  R,          ^8H  4       R# ©é   Néÿÿÿÿ©r   r   r   Úshape©r    r0   r!   s   &&€r   r   ÚVector3.__init__u   ó&   ø€ Ü‰Ñ˜Ô Ü�V—\‘\ "Õ%¨Ñ*Ö+r   c                ó    <€ V ^8„  d   QhRS[ /# ©r   r   ©Ústr)r   r   s   "€r   r   r1   y   s   ø€ ÷ 8ñ 8™#ñ 8r   c                óT   € R V P                    RV P                   RV P                   2# )úx: ú
y: z
z: )ÚxÚyÚz©r    s   &r   Ú__repr__ÚVector3.__repr__y   s'   € Ø�T—V‘V�H˜E $§&¡& ¨¨t¯v©v¨hÐ7Ð7r   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r=   r   )r   r   s   "€r   r   r1   }   ó   ø€ ÷ !ñ !‘5—<‘<ñ !r   c                ó(   € V P                   R,          # ©z<Return the x-coordinate stored in the last tensor dimension.).é    ©r   rF   s   &r   rC   Ú	Vector3.x|   ó   € ð �y‰y˜Õ Ð r   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r=   r   )r   r   s   "€r   r   r1   ‚   rJ   r   c                ó(   € V P                   R,          # ©z<Return the y-coordinate stored in the last tensor dimension.).r5   rN   rF   s   &r   rD   Ú	Vector3.y�   rP   r   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r=   r   )r   r   s   "€r   r   r1   ‡   rJ   r   c                ó(   € V P                   R,          # )z<Return the z-coordinate stored in the last tensor dimension.).r   rN   rF   s   &r   rE   Ú	Vector3.z†   rP   r   c                ó   <€ V ^8„  d   QhRR/# )r   r   r   r#   )r   r   s   "€r   r   r1   ‹   s   ø€ ÷ >ñ >˜Iñ >r   c                ó@   € \        \        V P                  R4      4      # )aI  Return a copy with each vector divided by its Euclidean norm.

Returns:
    New :class:`Vector3` of the same shape. The norm is floored at ``1e-12``, so a shorter vector is scaled
    by ``1e12`` instead of normalized, as in :func:`~kornia.geometry.conversions.normalize_quaternion`. A
    zero vector stays zero in every dtype.
çê-�™—q=)r   r	   r   rF   s   &r   Ú
normalizedÚVector3.normalized‹   s   € ô Ô*¨4¯9©9°eÓ<Ó=Ð=r   c                ó$   <€ V ^8„  d   QhRRRS[ /# )r   Úrightr   r   ©r   )r   r   s   "€r   r   r1   •   ó   ø€ ÷ Bñ B˜ð B¡vñ Br   c                óT   € \        \        V P                  VP                  4      4      # )a  Compute dot products with another 3D vector wrapper.

Args:
    right: Right-hand :class:`Vector3` operand with compatible leading
        dimensions.

Returns:
    :class:`Scalar` containing :math:`x_1 x_2 + y_1 y_2 + z_1 z_2` for
    each leading element.
©r   r
   r   ©r    r^   s   &&r   ÚdotÚVector3.dot•   ó   € ô Ô)¨$¯)©)°U·Z±ZÓ@ÓAÐAr   c                ó    <€ V ^8„  d   QhRS[ /# r=   r_   )r   r   s   "€r   r   r1   ¢   s   ø€ ÷ 7ñ 7™fñ 7r   c                ó>   € \        \        V P                  4      4      # )z�Compute squared Euclidean lengths of the wrapped vectors.

Returns:
    :class:`Scalar` containing :math:`x^2 + y^2 + z^2` for each
    vector.
©r   r   r   rF   s   &r   Úsquared_normÚVector3.squared_norm¢   s   € ô Ô*¨4¯9©9Ó5Ó6Ð6r   c                ó²   <€ V ^8„  d   QhRS[ S[S[R3,          ,          RS[ S[S[S[P                  3,          ,          RS[ S[P                  ,          RR/# )r   r8   .ÚdeviceÚdtyper   r   ©r   r   Úintr   r?   r   rm   rn   )r   r   s   "€r   r   r1   ¬   ób   ø€ ÷ Hñ Há™™c 3˜h�Õ(ðHñ ™™s¡E§L¡LÐ0Õ1Õ2ðHñ ™Ÿ™Õ$ð	Hð
 
ñHr   c                óT   € Vf   RpV ! \         P                  ! . VO^N5W#R7      4      # )aÊ  Create random 3D vectors with optional leading dimensions.

See the Convention block on :class:`Vector3`.

Args:
    shape: Optional leading dimensions before the final coordinate
        dimension. For example, ``shape=(B, N)`` creates
        ``(B, N, 3)`` vectors.
    device: Target device for the generated tensor.
    dtype: Target dtype for the generated tensor.

Returns:
    :class:`Vector3` wrapping a random tensor with shape
    ``(*shape, 3)``.
©rm   rn   r#   ©r   Úrand©Úclsr8   rm   rn   s   &&&&r   ÚrandomÚVector3.random«   ó,   € ð, Š=ØˆEÙ”5—:’:˜k ˜k q™k°&ÔFÓGÐGr   c                ó  <€ V ^8„  d   QhRS[ S[S[P                  3,          RS[ S[S[P                  3,          RS[ S[S[P                  3,          RS[S[ S[S[P                  3,          ,          RS[S[P                  ,          RR/# )r   rC   rD   rE   rm   rn   r   r   ©r   Úfloatr   r   r   r?   rm   rn   )r   r   s   "€r   r   r1   Ú   s�   ø€ ÷ 8ñ 8á‘™Ÿ™Ð$Õ%ð8ñ ‘™Ÿ™Ð$Õ%ð8ñ ‘™Ÿ™Ð$Õ%ð	8ñ
 ™™s¡E§L¡LÐ0Õ1Õ2ð8ñ ™Ÿ™Õ$ð8ð 
ñ8r   c                óô  € \        \        V4      \        V4      u;J ;'       d    \        V4      J Mu 4       \        \        V\        P                  \
        34      4       \        V\
        4      '       d)   \        \        P                  ! WV3WER7      \        4      # V\        \        P                  V4      \        \        P                  V4      3p\        \        P                  ! VR4      \        4      # )a„  Construct a 3D vector wrapper from x, y, and z coordinates.

All coordinate inputs must share the same Python type (all floats or
all tensors); Python ints raise, so write ``1.0``. For tensor inputs, coordinates are
stacked along the last dimension to produce ``(..., 3)`` output.

Args:
    x: X-coordinate value or tensor.
    y: Y-coordinate value or tensor.
    z: Z-coordinate value or tensor.
    device: Device used when scalar inputs are converted to tensor; ignored for tensors.
    dtype: Dtype used when scalar inputs are converted to tensor; ignored for tensors.

Returns:
    :class:`Vector3` containing the assembled coordinates.
rs   r6   )r   ÚtypeÚ
isinstancer   r   r}   r   Ú	as_tensorr   r   Ústack)rw   rC   rD   rE   rm   rn   Útensorss   &&&&&& r   Úfrom_coordsÚVector3.from_coordsÙ   s¢   € ô2 	”T˜!“W¤ Q£×2Ó2¬4°«7Ó2Ô3Ü”Z ¤E§L¡L´%Ð#8Ó9Ô:Ü�aœ×ÒÜœŸš¨!°¨¸6ÔOÔQXÓYÐYà-.´´U·\±\À1Ó0EÄtÌEÏLÉLÐZ[ÓG\Ð,]ˆÜ”U—[’[ ¨"Ó-¬wÓ7Ð7r   r#   ©NNN©NN)r$   r%   r&   r'   r(   Ú_WIDTHr   rG   ÚpropertyrC   rD   rE   r[   rd   rj   Úclassmethodrx   r„   r)   r*   r+   r,   s   @@r   r   r   H   s½   ù‡ € ñ(ðT €F÷,ó ,÷8ð 8ð ÷!ó ð!ð ÷!ó ð!ð ÷!ó ð!÷>ð >÷Bð B÷7ð 7ð ÷Hñ Hó ðHðZ ÷8ñ 8ó ÷8ð 8r   c                   ó  a a€ ] tR t^ût oRt^tV3R lV 3R lltV3R lR lt]V3R lR l4       t	]V3R lR	 l4       t
V3R
 lR ltV3R lR ltV3R lR lt]RV3R lR ll4       t]RV3R lR ll4       tRtVtV ;t# )r   a#  Wrap a ``(*, 2)`` tensor of 2D vectors, with coordinates, dot products and normalisation.

``v = Vector2(points)`` wraps a ``(*, 2)`` tensor without copying it, and ``Vector2.from_coords(x, y)`` and
``Vector2.random(shape)`` build one; ``v.x`` and ``v.y`` are plain ``(*)`` tensors, ``v.dot(w)`` and
``v.squared_norm()`` return a :class:`Scalar` ``(*)``, and ``v.normalized()`` the unit vectors, with the norm
floored at ``1e-12``. For 3D vectors, use :class:`Vector3` instead.

See the Convention block on :class:`Vector3`, which applies to ``(x, y)`` vectors; :meth:`random` fills the
unit square.

See Also:
    - :class:`Vector3`: the 3D vector ``(*, 3)``, whose conventions apply here.
    - :class:`Scalar`: the wrapper for one value per vector, which :meth:`dot` and :meth:`squared_norm` return.
c                ó8   <€ V ^8„  d   QhRS[ P                  RR/# r/   r   )r   r   s   "€r   r   ÚVector2.__annotate__  r2   r   c                ód   <€ \         SV `  V4       \        VP                  R,          ^8H  4       R# r4   r7   r9   s   &&€r   r   ÚVector2.__init__  r;   r   c                ó    <€ V ^8„  d   QhRS[ /# r=   r>   )r   r   s   "€r   r   r�     s   ø€ ÷ +ñ +™#ñ +r   c                ó:   € R V P                    RV P                   2# )rA   rB   )rC   rD   rF   s   &r   rG   ÚVector2.__repr__  s   € Ø�T—V‘V�H˜E $§&¡& Ð*Ð*r   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r=   r   )r   r   s   "€r   r   r�     rJ   r   c                ó(   € V P                   R,          # rL   rN   rF   s   &r   rC   Ú	Vector2.x  rP   r   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r=   r   )r   r   s   "€r   r   r�     rJ   r   c                ó(   € V P                   R,          # rS   rN   rF   s   &r   rD   Ú	Vector2.y  rP   r   c                ó   <€ V ^8„  d   QhRR/# )r   r   r   r#   )r   r   s   "€r   r   r�     s   ø€ ÷ >ñ >˜Iñ >r   c                ó@   € \        \        V P                  R4      4      # )z¬Return a copy with each vector divided by its Euclidean norm.

Returns:
    New :class:`Vector2` of the same shape, with the norm floored as in :meth:`Vector3.normalized`.
rZ   )r   r	   r   rF   s   &r   r[   ÚVector2.normalized  s   € ô Ô*¨4¯9©9°eÓ<Ó=Ð=r   c                ó$   <€ V ^8„  d   QhRRRS[ /# )r   r^   r   r   r_   )r   r   s   "€r   r   r�   &  r`   r   c                óT   € \        \        V P                  VP                  4      4      # )zøCompute dot products with another 2D vector wrapper.

Args:
    right: Right-hand :class:`Vector2` operand with compatible leading
        dimensions.

Returns:
    :class:`Scalar` containing :math:`x_1 x_2 + y_1 y_2` for each
    leading element.
rb   rc   s   &&r   rd   ÚVector2.dot&  rf   r   c                ó    <€ V ^8„  d   QhRS[ /# r=   r_   )r   r   s   "€r   r   r�   3  s   ø€ ÷ 7ñ 7™fñ 7r   c                ó>   € \        \        V P                  4      4      # )z†Compute squared Euclidean lengths of the wrapped vectors.

Returns:
    :class:`Scalar` containing :math:`x^2 + y^2` for each vector.
ri   rF   s   &r   rj   ÚVector2.squared_norm3  s   € ô Ô*¨4¯9©9Ó5Ó6Ð6r   c                ó²   <€ V ^8„  d   QhRS[ S[S[R3,          ,          RS[ S[S[S[P                  3,          ,          RS[ S[P                  ,          RR/# )r   r8   .rm   rn   r   r   ro   )r   r   s   "€r   r   r�   <  rq   r   c                óT   € Vf   RpV ! \         P                  ! . VO^N5W#R7      4      # )aÊ  Create random 2D vectors with optional leading dimensions.

See the Convention block on :class:`Vector3`.

Args:
    shape: Optional leading dimensions before the final coordinate
        dimension. For example, ``shape=(B, N)`` creates
        ``(B, N, 2)`` vectors.
    device: Target device for the generated tensor.
    dtype: Target dtype for the generated tensor.

Returns:
    :class:`Vector2` wrapping a random tensor with shape
    ``(*shape, 2)``.
rs   r#   rt   rv   s   &&&&r   rx   ÚVector2.random;  rz   r   c          
      óè   <€ V ^8„  d   QhRS[ S[S[P                  3,          RS[ S[S[P                  3,          RS[S[ S[S[P                  3,          ,          RS[S[P                  ,          RR/# )r   rC   rD   rm   rn   r   r   r|   )r   r   s   "€r   r   r�   V  su   ø€ ÷ 8ñ 8á‘™Ÿ™Ð$Õ%ð8ñ ‘™Ÿ™Ð$Õ%ð8ñ ™™s¡E§L¡LÐ0Õ1Õ2ð	8ñ
 ™Ÿ™Õ$ð8ð 
ñ8r   c                óŽ  € \        \        V4      \        V4      J 4       \        \        V\        P                  \
        34      4       \        V\
        4      '       d(   \        \        P                  ! W3W4R7      \        4      # V\        \        P                  V4      3p\        \        P                  ! VR4      \        4      # )aX  Construct a 2D vector wrapper from x and y coordinates.

Both coordinates must share the same Python type (both floats or both
tensors); Python ints raise, so write ``1.0``. For tensor inputs, coordinates are
stacked along the last dimension to produce ``(..., 2)`` output.

Args:
    x: X-coordinate value or tensor.
    y: Y-coordinate value or tensor.
    device: Device used when scalar inputs are converted to tensor; ignored for tensors.
    dtype: Dtype used when scalar inputs are converted to tensor; ignored for tensors.

Returns:
    :class:`Vector2` containing the assembled coordinates.
rs   r6   )r   r   r€   r   r   r}   r   r�   r   r   r‚   )rw   rC   rD   rm   rn   rƒ   s   &&&&& r   r„   ÚVector2.from_coordsU  s…   € ô. 	”T˜!“W¤ Q£Ð'Ô(Ü”Z ¤E§L¡L´%Ð#8Ó9Ô:Ü�aœ×ÒÜœŸš¨!¨¸ÔLÌgÓVÐVà-.´´U·\±\À1Ó0EÐ,FˆÜ”U—[’[ ¨"Ó-¬wÓ7Ð7r   r#   r†   r‡   )r$   r%   r&   r'   r(   rˆ   r   rG   r‰   rC   rD   r[   rd   rj   rŠ   rx   r„   r)   r*   r+   r,   s   @@r   r   r   û   s§   ù‡ € ñð €F÷,ó ,÷+ð +ð ÷!ó ð!ð ÷!ó ð!÷>ð >÷Bð B÷7ð 7ð ÷Hñ Hó ðHð2 ÷8ñ 8ó ÷8ð 8r   )r   r   r   )r(   Útypingr   r   r   r   r   Úkornia.core.checkr   Úkornia.core.tensor_wrapperr   r   Úkornia.geometry.conversionsr	   Úkornia.geometry.linalgr
   r   Ú__all__r   r   r   ÚVec3ÚVec2r#   r   r   Ú<module>r°      s\   ðñ$÷( 0Ó /ã å *ß ;Ý ;ß Lâ
*€ôˆ]ô ô*p8ˆmô p8ôfw8ˆmô w8ðt €Ø‚r   