ó
    ÀMóiç  ã                   ó°   • S r SSKrSSKJr  SSKJr   SSKJr  S rS	 rS
 rS rS rS rg! \ a"  r	SSKJ
r
  \
R                  " \	5      r Sr	C	N6Sr	C	ff = f)z5
curvature.py
---------------

Query mesh curvature.
é    Né   )Úutil)Údiagonal_dot)Ú
coo_matrix)Ú
exceptionsc                 óÎ   • [        U R                  R                  5       U R                  R                  U R                  R
                  44U R                  R                  5      nU$ )zž
A sparse matrix representation of the face angles.

Returns
----------
sparse : scipy.sparse.coo_matrix
  matrix is float shaped (len(vertices), len(faces))
)r   Úface_anglesÚflattenÚfaces_sparseÚrowÚcolÚshape)ÚmeshÚmatrixs     Úk/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/trimesh/curvature.pyÚface_angles_sparser      sX   € ô Ø	×	Ñ	×	!Ñ	!Ó	# d×&7Ñ&7×&;Ñ&;¸T×=NÑ=N×=RÑ=RÐ%SÐTØ×Ñ×Ñó€Fð €Mó    c                 ó¨   • [         R                  " U R                  R                  SS95      R	                  5       nS[         R
                  -  U-
  nU$ )a`  
Return the vertex defects, or (2*pi) minus the sum of the
angles of every face that includes that vertex.

If a vertex is only included by coplanar triangles, this
will be zero. For convex regions this is positive, and
concave negative.

Returns
--------
vertex_defect : (len(self.vertices), ) float
                 Vertex defect at the every vertex
r   )Úaxisé   )ÚnpÚarrayr   Úsumr
   Úpi)r   Ú	angle_sumÚdefects      r   Úvertex_defectsr   %   sF   € ô —’˜×0Ñ0×4Ñ4¸!Ð4Ð<Ó=×EÑEÓG€IØ”"—%‘%‰i˜9Ñ$€FØ€Mr   c                 óZ  • [         R                  " U[         R                  S9n[        R                  " US5      (       d  [        S5      eU R                  R                  X5      nU Vs/ s H  o@R                  U   R                  5       PM!     nn[         R                  " U5      $ s  snf )aú  
Return the discrete gaussian curvature measure of a sphere
centered at a point as detailed in 'Restricted Delaunay
triangulations and normal cycle'- Cohen-Steiner and Morvan.

This is the sum of the vertex defects at all vertices
within the radius for each point.

Parameters
----------
points : (n, 3) float
  Points in space
radius : float ,
  The sphere radius, which can be zero if vertices
  passed are points.

Returns
--------
gaussian_curvature:  (n,) float
  Discrete gaussian curvature measure.
©Údtype©éÿÿÿÿé   úpoints must be (n,3)!)r   Ú
asanyarrayÚfloat64r   Úis_shapeÚ
ValueErrorÚkdtreeÚquery_ball_pointr   r   Úasarray)r   ÚpointsÚradiusÚnearestÚverticesÚ
gauss_curvs         r   Ú#discrete_gaussian_curvature_measurer1   8   s„   € ô. ]Š]˜6¬¯©Ñ4€FÜ=Š=˜ ×)Ñ)ÜÐ0Ó1Ð1àk‰k×*Ñ*¨6Ó:€GÙFMÓNÂg¸(×%Ñ% hÑ/×3Ñ3Ö5Ág€JÐNä:Š:jÓ!Ð!ùò Os   Á*&B(c                 óÈ  • [         R                  " U[         R                  S9n[        R                  " US5      (       d  [        S5      e[         R                  " X-
  X-   45      nU Vs/ s H'  n[        U R                  R                  U5      5      PM)     nn[         R                  " [        U5      5      n[        [        X5      5       H‹  u  nu  p‰U R                  U R                  U	      n
[!        U
SS2S4   U
SS2S4   X‚S9nU R"                  U	   n[         R$                  " U R&                  U	   SS5      nX¼-  U-  R)                  5       S	-  Xg'   M     U$ s  snf )
aÚ  
Return the discrete mean curvature measure of a sphere
centered at a point as detailed in 'Restricted Delaunay
triangulations and normal cycle'- Cohen-Steiner and Morvan.

This is the sum of the angle at all edges contained in the
sphere for each point.

Parameters
----------
points : (n, 3) float
  Points in space
radius : float
  Sphere radius which should typically be greater than zero

Returns
--------
mean_curvature : (n,) float
  Discrete mean curvature measure.
r   r!   r$   Nr   r   )Úcenterr-   r"   r   )r   r%   r&   r   r'   r(   Úcolumn_stackÚlistÚface_adjacency_treeÚintersectionÚzerosÚlenÚ	enumerateÚzipr/   Úface_adjacency_edgesÚline_ball_intersectionÚface_adjacency_anglesÚwhereÚface_adjacency_convexr   )r   r,   r-   ÚboundsÚbÚ
candidatesÚ	mean_curvÚiÚxÚx_candidatesÚ	endpointsÚlengthsÚanglesÚsignss                 r   Údiscrete_mean_curvature_measurerL   Y   s?  € ô, ]Š]˜6¬¯©Ñ4€FÜ=Š=˜ ×)Ñ)ÜÐ0Ó1Ð1ô _Š_˜f™o¨v©Ð?Ó@€Fñ KQÓQÊ&ÀQ”$t×/Ñ/×<Ñ<¸QÓ?Ö@É&€JÐQä—’œ˜V›Ó%€IÜ )¬#¨fÓ*AÖ BÑˆÑˆAØ—M‘M $×";Ñ";¸LÑ"IÑJˆ	Ü(Ø’a˜d‰O˜Y¢q¨! t™_°Qñ
ˆð ×+Ñ+¨LÑ9ˆÜ—’˜×3Ñ3°LÑAÀ1ÀbÓIˆØÑ(¨5Ñ0×5Ñ5Ó7¸!Ñ;ˆ	‹ñ !Cð Ðùò Rs   Á+.Ec                 óî  • X-
  nX-
  nUn[        XD5      n[        XE5      n[        XU5      n	US-  XyUS-  -
  -  -
  n
[        R                  " [        U 5      5      nU
S:„  nXŒ   * [        R                  " X¬   5      -
  X|   -  nXŒ   * [        R                  " X¬   5      -   X|   -  n[        R
                  " USS5      n[        R
                  " USS5      nXí-
  [        R                  " X|   5      -  X¼'   U$ )aP  
Compute the length of the intersection of a line segment with a ball.

Parameters
----------
start_points : (n,3) float, list of points in space
end_points   : (n,3) float, list of points in space
center       : (3,) float, the sphere center
radius       : float, the sphere radius

Returns
--------
lengths: (n,) float, the lengths.

r   r   r   )r   r   r8   r9   ÚsqrtÚclip)Ústart_pointsÚ
end_pointsr3   r-   ÚLÚocÚrÚldotlÚldotocÚocdotocÚdiscrimsrI   ÚmÚd1Úd2s                  r   r=   r=   †   sô   € ð( 	Ñ!€AØ	Ñ	€BØ€AÜ˜Ó€EÜ˜!Ó €FÜ˜2Ó"€GØq‰y˜5¨a°©d¡NÑ3Ñ3€Hô hŠh”s˜<Ó(Ó)€Gà1‰€AØ‰9ˆ*”r—w’w˜x™{Ó+Ñ
+¨u©xÑ	7€BØ‰9ˆ*”r—w’w˜x™{Ó+Ñ
+¨u©xÑ	7€Bô 
ŠQ˜Ó	€BÜ	ŠQ˜Ó	€Bð ‘'œRŸWšW U¡XÓ.Ñ.€GJà€Nr   c                 ó¬   • SU S-  -  US-  -
  SU -  -  nX * :¼  a  S[         R                  -  U -  X-
  -  $ X * :  a  S[         R                  -  U S-  -  $ g)a   
Compute the surface area of the intersection of sphere of radius R centered
at (0, 0, 0) with a ball of radius r centered at (R, 0, 0).

Parameters
----------
R : float, sphere radius
r : float, ball radius

Returns
--------
area: float, the surface are.
r   é   N)r   r   )ÚRrT   rF   s      r   Úsphere_ball_intersectionr_   ³   se   € ð 
ˆQ‰T‰Aq‘D‰˜Q ™UÑ#€AØˆBƒwØ”2—5‘5‰y˜1‰} ¡Ñ&Ð&Øˆ2ƒvØ”2—5‘5‰y˜1˜a™4ÑÐð r   )Ú__doc__Únumpyr   Ú r   r   Úscipy.sparser   ÚImportErrorÚEr   ÚExceptionWrapperr   r   r1   rL   r=   r_   © r   r   Ú<module>rh      sd   ðñó å Ý ð0Ý'òò ò&"òB*òZ*óZ øðI ó 0Ýà×,Ò,¨QÓ/…Jûð0ús   ”- ­A³AÁA