+
    åûj™^  ã                   óð   € R t ^ RIHtHt ^ RIt^ RIHt ^ RIHtHtH	t	H
t
 ^ RIHtHt ^ RIHtHt ^ RIHtHtHtHtHtHtHt ^ RIHt ^ R	IHtHt R
R.t ! R R
]P>                  4      t R R lt!R R lt"R# )ag  Planes in 3D as n . x + d = 0: signed distances, projection and fitting.

A plane is :math:`n \cdot x + d = 0`, with a normal ``n`` of shape ``(3,)``, or ``(B, 3)`` for ``B`` planes, held in a
:class:`~kornia.geometry.vector.Vector3`, and an offset ``d`` of shape ``()`` or ``(B,)`` in a
:class:`~kornia.geometry.vector.Scalar`. The signed distance :math:`n \cdot x + d` is positive on the side the normal
points to, and a Euclidean distance only for a unit normal, which :meth:`~kornia.geometry.plane.Hyperplane.through`
and :func:`fit_plane` return. :func:`~kornia.geometry.depth.depth_from_plane_equation` writes the plane as
:math:`n \cdot X = d` instead.

Which function to use:

- A plane from a normal and an offset, a normal and a point, or three points, with the signed and absolute distances
  and the projection of points: :class:`Hyperplane`.
- The plane that best fits 3D points by total least squares: :func:`fit_plane`.
- Where a line meets a plane: :meth:`~kornia.geometry.line.ParametrizedLine.intersect`.
- The depth of given pixels on a known plane: :func:`~kornia.geometry.depth.depth_from_plane_equation`.
)ÚAnyÚOptionalN)Únn)ÚKORNIA_CHECKÚKORNIA_CHECK_SHAPEÚKORNIA_CHECK_TYPEÚare_checks_enabled)Ú	BaseErrorÚValueCheckError)Ú_unwrapÚ_wrap)Ú_deepcopy_module_stateÚ_right_singular_vectorÚ_svd_work_dtypeÚ_torch_linalg_svdvalsÚ_torch_svd_castÚis_compilingÚregister_module_state)Úbatched_dot_product)ÚScalarÚVector3Ú
HyperplaneÚ	fit_planec                   ó,  a a€ ] tR t^>t oRt]tV3R lV 3R lltV3R lV 3R lltV3R lR 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]V3R lR l4       t]RV3R lR ll4       tRtVtV ;t# )r   aÓ  Represent 3D planes n . x + d = 0 by a normal and an offset, with signed distances.

``plane = Hyperplane(Vector3(n), Scalar(d))`` stores the plane :math:`n \cdot x + d = 0` from a normal ``(3,)``
or ``(B, 3)`` in a :class:`~kornia.geometry.vector.Vector3` and an offset ``()`` or ``(B,)`` in a
:class:`~kornia.geometry.vector.Scalar`; plain tensors raise ``TypeCheckError``. :meth:`from_vector` builds it
from a normal and a point on it, and :meth:`through` from three points with a unit normal.
``plane.signed_distance(p)`` returns :math:`n \cdot p + d` for points ``(..., 3)`` as a ``Scalar``,
:meth:`abs_distance` its absolute value, and :meth:`projection` the closest points as a ``Vector3`` for a unit
normal. To fit a plane to many points, use :func:`fit_plane`; to intersect it with a line,
:meth:`~kornia.geometry.line.ParametrizedLine.intersect`.

Convention:
    - The plane is :math:`n \cdot x + d = 0`, and :meth:`signed_distance` is :math:`n \cdot x + d`: positive on
      the side the normal points to, and ``d`` at the origin. :meth:`from_vector` sets :math:`d = -n \cdot e`.
      :func:`~kornia.geometry.depth.depth_from_plane_equation` takes :math:`n \cdot X = d` instead: pass it
      ``-offset``.
    - The normal must be unit for :meth:`signed_distance`, :meth:`abs_distance` and :meth:`projection` to give
      Euclidean distances and the closest point. :meth:`through` and :func:`fit_plane` return a unit normal; the
      constructor and :meth:`from_vector` do not normalise it.
    - :meth:`through` points the normal along :math:`(p_2 - p_0) \times (p_1 - p_0)`, as Eigen's
      ``Hyperplane::Through`` does: the opposite of the right-hand normal of the loop
      :math:`p_0 \to p_1 \to p_2`. Swapping two points flips it.
    - The normal and offset are registered module state under the keys ``_n`` and ``_d``, so ``state_dict()``,
      ``load_state_dict()`` and ``.to()`` include both tensors. As in
      :class:`~kornia.geometry.line.ParametrizedLine`, outside graph capture a floating-point tensor that takes
      no part in autograd (no ``grad_fn`` and ``requires_grad=False``) becomes an ``nn.Parameter``: a plane built
      from plain tensors, including the result of :meth:`through` and :func:`fit_plane` on points without
      autograd history, has trainable parameters, and the distances and projections it returns require grad. A
      caller's ``nn.Parameter`` is kept; any other floating-point tensor, such as a leaf that requires grad or a
      tensor with autograd history, is stored as a buffer and keeps its autograd link; and an integer tensor is
      stored as a buffer (ParametrizedLine rejects one).
      ``copy.deepcopy`` holds a tensor with autograd history as a new leaf that keeps ``requires_grad``, as for
      :class:`~kornia.geometry.quaternion.Quaternion`.
    - Points broadcast against the planes as torch broadcasts ``(..., 3)`` against ``(B, 3)``: the axis before
      the coordinates pairs with the plane batch. One plane, or a batch of one, takes points of any leading
      shape; a batch of ``B > 1`` takes ``(B, 3)``, one point per plane, a single ``(3,)`` point, or
      ``(N, B, 3)`` for ``N`` points per plane. ``(B, N, 3)`` is not ``N`` points per plane: it raises unless
      ``N`` is ``B`` or 1. With ``N = B``, plane ``j`` meets ``p[:, j]``; with ``N = 1``, every plane meets every
      point and the result is ``(B, B)``.

Args:
    n: The normal vector :math:`n`, a :class:`~kornia.geometry.vector.Vector3`.
    d: The offset :math:`d`, a :class:`~kornia.geometry.vector.Scalar`.

See Also:
    - :func:`fit_plane`: fits the plane to a set of 3D points by total least squares, instead of taking a normal
      and an offset.
    - :class:`~kornia.geometry.line.ParametrizedLine`: a line in any dimension; its
      :meth:`~kornia.geometry.line.ParametrizedLine.intersect` returns where a 3D line meets this plane.
    - :func:`~kornia.geometry.depth.depth_from_plane_equation`: the depth of pixels on a plane given as plain
      tensors, with the offset of the opposite sign.

Example:
    >>> plane = Hyperplane(Vector3(torch.tensor([0.0, 0.0, 1.0])), Scalar(torch.tensor(-2.0)))
    >>> plane.signed_distance(torch.tensor([[1.0, 1.0, 5.0], [0.0, 0.0, 0.0]])).data
    tensor([ 3., -2.], grad_fn=<AddBackward0>)
c                ó*   <€ V ^8„  d   QhRS[ RS[RR/# )é   ÚnÚdÚreturnN)r   r   )ÚformatÚ__classdict__s   "€ÚQC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\geometry\plane.pyÚ__annotate__ÚHyperplane.__annotate__|   s"   ø€ ÷ 2ñ 2™'ð 2¡fð 2°ñ 2ó    c                óD  <€ \         SV `  4        \        V\        4       \        V\        4       R VP
                  3RVP
                  33 FP  w  r4VP                  4       '       g   VP                  4       '       d   \        WV4       K?  V P                  W44       KR  	  R# )Ú_nÚ_dN)
ÚsuperÚ__init__r   r   r   ÚdataÚis_floating_pointÚ
is_complexr   Úregister_buffer)Úselfr   r   ÚnameÚvalueÚ	__class__s   &&&  €r!   r)   ÚHyperplane.__init__|   s|   ø€ Ü‰ÑÔÜ˜!œWÔ%Ü˜!œVÔ$ð " 1§6¡6˜N¨T°1·6±6¨NÓ;‰KˆDØ×&Ñ&×(Ò(¨E×,<Ñ,<×,>Ò,>Ü% d°%Ö8ð ×$Ñ$ TÖ1ó <r$   c                ó:   <€ V ^8„  d   QhRS[ S[S[3,          RR/# )r   Ústater   N)ÚdictÚstrr   )r   r    s   "€r!   r"   r#   Š   s#   ø€ ÷ 7ñ 7¡$¡s©C x¥.ð 7°Tñ 7r$   c                ón  <€ \         SV `  V4       R Fž  pV P                  P                  V4      p\	        V\
        \        34      '       g   K<  \        W4       VP                  pVP                  4       '       g   VP                  4       '       d   \        WV4       K�  V P                  W$4       K   	  R# )r&   N)r&   r'   )r(   Ú__setstate__Ú__dict__ÚgetÚ
isinstancer   r   Údelattrr*   r+   r,   r   r-   )r.   r4   r/   r0   Útensorr1   s   &&   €r!   r8   ÚHyperplane.__setstate__Š   sˆ   ø€ Ü‰Ñ˜UÔ#ó !ˆDØ—M‘M×%Ñ% dÓ+ˆEÜ˜%¤'¬6Ð!2×3Ô3Ü˜Ô#ØŸ™�Ø×+Ñ+×-Ò-°×1BÑ1B×1DÒ1DÜ)¨$°fÖ=à×(Ñ(¨Ö6ó !r$   c                ó    <€ V ^8„  d   QhRS[ /# ©r   r   ©r6   )r   r    s   "€r!   r"   r#   ˜   s   ø€ ÷ ?ñ ?™ñ ?r$   c                ó:   € R V P                    RV P                   2# )zNormal: z	
Offset: )ÚnormalÚoffset©r.   s   &r!   Ú__str__ÚHyperplane.__str__˜   s   € Ø˜$Ÿ+™+˜ j°·±°Ð>Ð>r$   c                ó    <€ V ^8„  d   QhRS[ /# r@   rA   )r   r    s   "€r!   r"   r#   ›   s   ø€ ÷ ñ ™#ñ r$   c                ó   € \        V 4      # ©NrA   rE   s   &r!   Ú__repr__ÚHyperplane.__repr__›   s   € Ü�4‹yÐr$   c                ó    <€ V ^8„  d   QhRS[ /# r@   ©r   )r   r    s   "€r!   r"   r#   Ÿ   s   ø€ ÷  ñ  ™ñ  r$   c                ó,   € \        V P                  4      # )zÖReturn the vector perpendicular to the hyperplane.

Returns:
    :class:`~kornia.geometry.vector.Vector3` storing the normal
    direction. For a 3D plane this is the vector :math:`n` in
    :math:`n^T x + d = 0`.
)r   r&   rE   s   &r!   rC   ÚHyperplane.normalž   s   € ô �t—w‘wÓÐr$   c                ó    <€ V ^8„  d   QhRS[ /# r@   )r   )r   r    s   "€r!   r"   r#   ª   s   ø€ ÷ ñ ™ñ r$   c                ó,   € \        V P                  4      # )a  Return the scalar offset in the implicit plane equation.

Returns:
    :class:`~kornia.geometry.vector.Scalar` containing the ``d`` term
    in :math:`n^T x + d = 0`. The value controls where the plane sits
    relative to the origin for the stored normal direction.
)r   r'   rE   s   &r!   rD   ÚHyperplane.offset©   s   € ô �d—g‘g‹Ðr$   c                óJ   <€ V ^8„  d   QhRS[ S[P                  ,          RS[/# ©r   Úpr   ©r   ÚtorchÚTensorr   )r   r    s   "€r!   r"   r#   ´   s$   ø€ ÷ 5ñ 5™g©¯©Õ4ð 5¹ñ 5r$   c                óR   € \        V P                  V4      P                  4       4      # )a’  Compute unsigned distances from points to the hyperplane.

Args:
    p: Point or batch of points as a :class:`~kornia.geometry.vector.Vector3`
        or :class:`torch.Tensor`. The last coordinate dimension represents ``(x, y, z)``.

Returns:
    :class:`~kornia.geometry.vector.Scalar` with non-negative distance
    values. Leading batch dimensions follow the broadcasted point and
    plane inputs.
)r   Úsigned_distanceÚabs©r.   rV   s   &&r!   Úabs_distanceÚHyperplane.abs_distance´   s#   € ô �d×*Ñ*¨1Ó-×1Ñ1Ó3Ó4Ð4r$   c                óJ   <€ V ^8„  d   QhRS[ S[P                  ,          RS[/# rU   rW   )r   r    s   "€r!   r"   r#   Ã   s(   ø€ ÷ \ñ \¡©5¯<©<Õ!7ð \¹Fñ \r$   c                óî   € \        \        V\        \        P                  34      4       \        \        V P                  P                  \        V4      4      V P                  P                  ,           4      # )aq  Compute signed distances from points to the hyperplane.

The sign is determined by the stored normal vector. Points in the
normal direction have positive values; points on the opposite side have
negative values; points on the plane evaluate to zero. The value is
:math:`n \cdot p + d`, a Euclidean distance only for a unit normal.

Args:
    p: Point or batch of points as a :class:`~kornia.geometry.vector.Vector3`
        or :class:`torch.Tensor`. Gradients with respect to the points are preserved for both.

Returns:
    :class:`~kornia.geometry.vector.Scalar` containing signed distance
    values for each input point.
)r   r;   r   rX   rY   r   r   rC   r*   r   rD   r]   s   &&r!   r[   ÚHyperplane.signed_distanceÃ   sL   € ô  	”Z ¤G¬U¯\©\Ð#:Ó;Ô<ÜÔ)¨$¯+©+×*:Ñ*:¼GÀA»JÓGÈ$Ï+É+×JZÑJZÕZÓ[Ð[r$   c                óJ   <€ V ^8„  d   QhRS[ S[P                  ,          RS[ /# rU   )r   rX   rY   )r   r    s   "€r!   r"   r#   ×   s$   ø€ ÷ 6ñ 6™G¡e§l¡lÕ2ð 6±wñ 6r$   c                óx   € V P                  V4      pWP                  R,          V P                  ,          ,
          # )aª  Project points onto the hyperplane along the normal direction.

Args:
    p: Point or batch of points as a :class:`~kornia.geometry.vector.Vector3`
        or :class:`torch.Tensor`.

Returns:
    :class:`~kornia.geometry.vector.Vector3`, also for a tensor input, containing
    :math:`p - (n \cdot p + d) n` for each input point, preserving leading
    batch dimensions: the closest point on the hyperplane for a unit normal.
©.N)r[   r*   rC   )r.   rV   Údists   && r!   Ú
projectionÚHyperplane.projection×   s/   € ð ×#Ñ# AÓ&ˆØ—9‘9˜YÕ'¨$¯+©+Õ5Õ5Ð5r$   c                ó*   <€ V ^8„  d   QhRS[ RS[ RR/# )r   r   Úer   r   rN   )r   r    s   "€r!   r"   r#   é   s"   ø€ ÷ 2ñ 2™Wð 2©ð 2°\ñ 2r$   c                óT   € TpVP                  V4      ) p\        V\        V4      4      # )aj  Create a hyperplane from a normal and one point on the plane.

Args:
    n: Normal vector :math:`n` defining the plane orientation, a
        :class:`~kornia.geometry.vector.Vector3` stored as given, not normalised.
    e: Point :math:`e` that lies on the target plane.

Returns:
    :class:`Hyperplane` whose offset is chosen so that
    :math:`n^T e + d = 0`.
)Údotr   r   )r.   r   rj   rC   rD   s   &&&  r!   Úfrom_vectorÚHyperplane.from_vectorè   s)   € ð ˆØ—*‘*˜Q“-�ˆÜ˜&¤&¨£.Ó1Ð1r$   c                ó|   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[S[ P                  ,          RR/# )r   Úp0Úp1Úp2r   r   )rX   rY   r   )r   r    s   "€r!   r"   r#   ú   sG   ø€ ÷ XIñ XI™Ÿ™ð XI©5¯<©<ð XI¹XÁeÇlÁlÕ=Sð XIÐ_kñ XIr$   c                ó¦  € Vf   \        R4      h\        V4      p\        V4      p\        V4      p\        VRR.4       \        VP                  VP                  8H  4       \        VP                  VP                  8H  4       VP
                  \        P                  \        P                  39   d   \        P                  MVP
                  pVP                  V4      pVP                  V4      V,
          VP                  V4      V,
          r©\        P                  P                  WšRR7      p\        P                  P                  VRRR7      p\        P                  P                  V	RRR7      p\        P                  P                  V
RRR7      pR R lp\        P                  P                  4       '       gª   \!        4       '       gš   \#        4       '       dŠ   \%        \        P&                  ! \        V	4      \        V
4      3R4      4      p\)        VR,          VR,          \+        VP
                  4      ,          8*  P-                  4       4      '       d   \/        R	4      hV	P1                  4       '       d!   \        P2                  ! V4      P4                  MR
pWÍV,          V,          8*  p\        P6                  ! V\        P8                  ! V4      V4      p\        P6                  ! VV! WšV4      VV,          4      pVP                  VP
                  4      p\;        WK4      ) p\=        \?        V\@        4      \?        V\B        4      4      # )aó  Construct the 3D plane through three points.

Only the three-point form is supported: :class:`Hyperplane` stores its normal as a
:class:`~kornia.geometry.vector.Vector3`, so it cannot represent a 2D line, and calling
``through`` with two points raises.

Args:
    p0: First point tensor, shaped ``(..., 3)``.
    p1: Second point tensor with the same shape as ``p0``.
    p2: Third point tensor with the same shape as ``p0``. It is required; the default of
        ``None`` only exists so that a two-point call fails with a clear error.

Returns:
    :class:`Hyperplane` passing through the three points, with a unit normal along
    :math:`(p_2 - p_0) \times (p_1 - p_0)`.

Raises:
    BaseError: if ``p2`` is omitted, or if the points are not ``(..., 3)`` tensors of the
        same shape.
    ValueCheckError: if the three points are collinear (or coincide), so they do not
        determine a plane. Like every kornia value check, it is skipped under ``torch.compile``
        and by ``disable_checks()``.
zxHyperplane.through requires three points p0, p1 and p2 of shape (..., 3); the two-point (2D line) form is not supported.Ú*Ú3)ÚdimT)rv   Úkeepdimc                ó˜   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  R\         P                  /# )r   Úv0Úv1Úuse_svdr   )rX   rY   )r   s   "r!   r"   Ú(Hyperplane.through.<locals>.__annotate__0  s;   € ÷ 		!ñ 		!¤5§<¡<ð 		!´U·\±\ð 		!ÌEÏLÉLð 		!Ô]b×]iÑ]iñ 		!r$   c                 ó  € \         P                  ! W3R4      p\         P                  ! . RO. RO.VP                  VP                  R7      p\         P
                  ! VR,          W44      p\        V4      w   rVVR,          # )r   )ÚdeviceÚdtypeéþÿÿÿ)g      ð?ç        r�   )r�   g       @r�   re   ).ºNNNéÿÿÿÿ)rX   Ústackr=   r~   r   Úwherer   )ry   rz   r{   ÚmÚsafeÚ_ÚVs   &&&    r!   Úcompute_normal_svdÚ.Hyperplane.through.<locals>.compute_normal_svd0  se   € Ü—’˜R˜H bÓ)ˆAô
 —<’<¢²/Ð BÈ1Ï8É8Ð[\×[bÑ[bÔcˆDÜ—’˜G IÕ.°Ó8ˆAÜ% aÓ(‰GˆAˆqØ�Z•=Ð r$   zkHyperplane.through requires three points that are not collinear; the given points do not determine a plane.g�íµ ÷Æ°>rƒ   r€   ©.é   ©.é    )"r	   r   r   r   Úshaper   rX   Úfloat16Úbfloat16Úfloat32ÚtoÚlinalgÚcrossÚvector_normÚjitÚis_scriptingr   r   r   r„   ÚboolÚ_rank_toleranceÚanyr
   r+   ÚfinfoÚepsr…   Ú	ones_liker   r   r   r   r   )Úclsrp   rq   rr   Úp0_dataÚp1_dataÚp2_dataÚ
work_dtypeÚp0_workry   rz   rC   ÚnormÚv0_normÚv1_normrŠ   Úsvrž   Únormal_maskÚ	norm_saferD   s   &&&&                 r!   ÚthroughÚHyperplane.throughù   ss  € ð2 Š:äðAóð ô
 ˜"“+ˆÜ˜"“+ˆÜ˜"“+ˆä˜7 S¨# JÔ/Ü�W—]‘] g§m¡mÑ3Ô4Ü�W—]‘] g§m¡mÑ3Ô4ð '.§m¡m¼¿¹ÄuÇ~Á~Ð7VÔ&V”U—]’]Ð\c×\iÑ\iˆ
Ø—*‘*˜ZÓ(ˆØ—*‘*˜ZÓ(¨7Õ2°g·j±jÀÓ6LÈwÕ6VˆBÜ—‘×#Ñ# B°Ð#Ó3ˆä�|‰|×'Ñ'¨°BÀÐ'ÓEˆÜ—,‘,×*Ñ*¨2°2¸tÐ*ÓDˆÜ—,‘,×*Ñ*¨2°2¸tÐ*ÓDˆõ		!ô& �y‰y×%Ñ%×'Ò'´·²ÔCU×CWÒCWÜ&¤u§{¢{´G¸B³KÄÈÃÐ3MÈrÓ'RÓSˆBÜ�R˜•Z 2 f¥:´ÀÇÁÓ0NÕ#NÑN×SÑSÓU×VÒVÜ%ðAóð ð
 .0×-AÑ-A×-CÒ-CŒe�kŠk˜*Ó%×)Ò)ÈˆØ¨Õ/°#Õ5Ñ5ˆÜ—K’K ¬U¯_ª_¸TÓ-BÀDÓIˆ	Ü—’˜[Ñ*<¸RÀ[Ó*QÐSYÐ\eÕSeÓfˆØ—‘˜7Ÿ=™=Ó)ˆÜ% gÓ6Ð6ˆäœ% ¬Ó0´%¸ÄÓ2GÓHÐHr$   © rJ   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__deepcopy__r)   r8   rF   rK   ÚpropertyrC   rD   r^   r[   rg   Úclassmethodrm   r¬   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r1   r    s   @@r!   r   r   >   s¼   ù‡ € ñ8ðv *€L÷2ó 2÷7ó 7÷?ð ?÷ð ð ÷ ó ð ð ÷ó ð÷5ð 5÷\ð \÷(6ð 6ð" ÷2ó ð2ð  ÷XIñ XIó ÷XIð XIr$   c                óD   € V ^8„  d   QhR\         P                  R\        /# )r   r   r   )rX   r   Úfloat)r   s   "r!   r"   r"   U  s   € ÷ (ñ (œ5Ÿ;™;ð (¬5ñ (r$   c                 óP   € R \         P                  ! V 4      P                  ,          # )g       @)rX   r�   rž   )r   s   &r!   r›   r›   U  s   € ð ”—’˜UÓ#×'Ñ'Õ'Ð'r$   c                ó0   € V ^8„  d   QhR\         R\        /# )r   Úpointsr   )r   r   )r   s   "r!   r"   r"   ]  s"   € ÷ ^Gñ ^G”gð ^G¤*ñ ^Gr$   c                ó¨  € V P                   R	,          ^8w  d   \        R4      h\        P                  P	                  4       '       * ;'       d"    \        4       '       * ;'       d    \        4       pV'       d†   V P                   R
,          pV^8  d   \        RV R24      h\        V 4      p\        W3R,          8g  P                  R
4      P                  R	4      P                  4       4      '       g   \        R4      h\        V 4      pVP                  \        P                  \        P                  39   pV'       d   VP!                  4       MTpVP#                  R
R4      pWg,
          pVP%                  4       P'                  \)        V4      4      p	\+        V	RR7      w  r«pVP'                  VP                  4      pV'       dV   \        VR,          VR,          \-        VP                  4      ,          8„  P                  4       4      '       g   \        R4      h\/        W‹VR	4      P'                  VP                  4      pVR,          pV'       d]   \1        Wï4      ) p\3        \5        VP'                  VP                  4      4      \7        VP'                  VP                  4      4      4      # \2        P9                  \5        V4      \5        V4      4      # )aY	  Fit a 3D plane to a set of points by total least squares, through their centroid.

``plane = fit_plane(points)`` takes ``N >= 3`` points ``(N, 3)``, or ``B`` sets of them ``(B, N, 3)``, as a
tensor or a :class:`~kornia.geometry.vector.Vector3`, and returns a :class:`Hyperplane` with a unit normal ``(3,)``
or ``(B, 3)`` and an offset ``()`` or ``(B,)``: the plane through the centroid that minimises the sum of squared
perpendicular distances to the points. Every point counts equally; there are no weights. For the plane through
exactly three points with an oriented normal, use :meth:`Hyperplane.through` instead; for a line,
:func:`~kornia.geometry.line.fit_line`.

Convention:
    - Returns a :class:`Hyperplane` (see its conventions) through the centroid of the points, with a unit normal
      of unspecified sign. Each batch row is fitted on its own.
    - The points are collinear, and rejected, when the second singular value of the centred points is at most
      ``8 * eps`` of the input dtype times the first, a test that does not depend on their scale.
    - float16 and bfloat16 points are fitted in float32 and the plane is cast back to the input dtype.

Args:
    points: a tensor or a :class:`~kornia.geometry.vector.Vector3` of 3D points, of shape ``(N, 3)`` or
        ``(B, N, 3)``. Another number of coordinates raises ``TypeError``.

Return:
    The computed hyperplane object.

Raises:
    TypeError: if ``points`` does not end in 3 coordinates.
    ValueCheckError: if fewer than three points are given, the points are all identical, or they are
        collinear, so they do not determine a plane. Like every kornia value check, these are skipped under
        ``torch.compile`` and by ``disable_checks()``.

See Also:
    - :class:`Hyperplane`: the returned plane; its :meth:`Hyperplane.through` takes exactly three points and
      orients the normal by their order.
    - :func:`~kornia.geometry.line.fit_line`: the same total least squares for a line, in any dimension and with
      optional weights, for a batch ``(B, N, D)`` only.

Example:
    >>> points = torch.tensor([[0.0, 0.0, 1.0], [1.0, 0.0, 1.0], [0.0, 1.0, 1.0], [1.0, 1.0, 1.0]])
    >>> plane = fit_plane(points)
    >>> plane.normal.data.abs(), plane.signed_distance(torch.tensor([0.0, 0.0, 3.0])).data.abs()
    (tensor([0., 0., 1.], grad_fn=<AbsBackward0>), tensor(2., grad_fn=<AbsBackward0>))

zvector must be (*, 3)zCfit_plane requires at least three points to determine a plane; got z
 point(s).zdfit_plane requires at least three points that are not identical; the given points are all identical.TF)Úfull_matricesz\fit_plane requires points that are not collinear; the given points do not determine a plane.rƒ   r€   ).:Nr�   Nr‚   rŒ   rŽ   ).r�   r‚   )r�   Ú	TypeErrorrX   r˜   r™   r   r   r
   r   rš   Úflattenrœ   Úallr   r‘   r’   r»   ÚmeanÚdetachr”   r   r   r›   r   r   r   r   r   rm   )r¾   Úchecksr   ÚptsÚpoints_dataÚhalfÚpoints_workrÄ   Úpoints_centeredÚworkrˆ   ÚSr‰   ÚS_workÚ	directionÚoriginrD   s   &                r!   r   r   ]  s9  € ðZ ‡|�|�BÕ˜1ÔÜÐ/Ó0Ð0ô —‘×'Ñ'Ó)Ô)×YÐY´,³.Ô.@×YÐYÔEWÓEY€FßØ�L‰L˜ÕˆØˆqŒ5Ü!Ð$gÐhiÐgjÐjtÐ"uÓvÐvô �f‹oˆÜ�S 
�OÑ+×4Ñ4°RÓ8×<Ñ<¸RÓ@×DÑDÓF×GÒGÜ!Øvóð ô ˜&“/€Kð ×Ñ¤§¡´·±Ð ?Ñ?€Dß)-�+×#Ñ#Ô%°;€KØ×Ñ˜B Ó%€DØ!Õ(€Oð
 ×!Ñ!Ó#×&Ñ&¤°Ó'GÓH€DÜ˜d°%Ô8�G€Aˆ!ð
 �T‰T�+×#Ñ#Ó$€Fß”d˜F 6�N¨V°F­^¼oÈk×N_ÑN_Ó>`Õ-`Ñ`×eÑeÓg×hÒhÜØjó
ð 	
ô
 ' ¸1¸bÓA×DÑDÀ[×EVÑEVÓW€IØ�)�_€FßÜ% iÓ8Ð8ˆÜœ' )§,¡,¨{×/@Ñ/@Ó"AÓBÄFÈ6Ï9É9ÐU`×UfÑUfÓKgÓDhÓiÐiä×!Ñ!¤'¨)Ó"4´g¸f³oÓFÐFr$   )#r³   Útypingr   r   rX   r   Úkornia.core.checkr   r   r   r   Úkornia.core.exceptionsr	   r
   Úkornia.core.tensor_wrapperr   r   Úkornia.core.utilsr   r   r   r   r   r   r   Úkornia.geometry.linalgr   Úkornia.geometry.vectorr   r   Ú__all__ÚModuler   r›   r   r®   r$   r!   Ú<module>rÚ      sc   ðñ$÷* !ã Ý ç eÓ eß =ß 5÷÷ ñ õ 7ß 2à˜Ð
%€ôTI�—‘ô TIõn(÷^Gr$   