
    Mi{               	           S SK Jr  S SKrSSKJr  SSKJr  SSKJr	  SSKJ
r  SSKJrJrJrJrJr  S	r\ " S
 S5      5       r SS\S\S\S\4S jjrSS jrSS jrg)    )	dataclassN   )util)log)res_path)tol_path)	ArrayLikeNDArrayNumberOptionalfloat64g-q=c                   ~    \ rS rSr% \\S'   \\   \S'   Sr\	\\      \S'   Sr
\	\\      \S'   Sr\	\   \S'   S rS	rg)
ArcInfo   radiuscenterNnormalanglesspanc                     [        X5      $ N)getattr)selfitems     j/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/trimesh/path/arc.py__getitem__ArcInfo.__getitem__!   s    t""     )__name__
__module____qualname____firstlineno__float__annotations__r
   r   r   r   r   r   r   r   __static_attributes__r   r   r   r   r      sX     M G *.FHWW%&- *.FHWW%&- "D(6
!#r   r   pointsreturn_normalreturn_anglereturnc           	         [         R                  " U [         R                  S9n U / SQ   U / SQ   -
  n[         R                  " US-  S/U R                  S   -  5      n[         R
                  " U5      nUR                  5       nXV-  nUR                  5       S-  nU[         R                  " X-
  5      -  n	U	[        R                  :  a  [        S5      eU[         R                  " U5      S-  [         R
                  " U	5      -  -  n
U/ S	Q   / S
Q-  R                  S5      R                  SS9U-  nU R                  R                  U5      UR                  5       -  n[        R                  (       a<  [        R                   " [         R"                  R%                  X-
  SS9U
5      (       d   eXS.nU(       a  U R                  S:X  a`  [        R&                  " [         R(                  " [         R*                  " US   * S5      [         R*                  " US   S5      5      5      US'   O5[        R&                  " [         R(                  " US   * US   5      5      US'   U(       Gah  [        R&                  " X-
  5      n[         R,                  " U SS9n[         R                  " USS/   6 nU[.        S-
  :  a  [         R0                  nO&US[.        -
  :  a  SnO[         R2                  " U5      n[5        U5      [.        :  a-  [         R                  " U6 S:  a  [         R0                  S-  U-
  n[         R6                  " USS2SS24   R                  SSS2   6 [         R0                  S-  -   n[         R8                  " USS/   5      nUS   US   s=:  =(       a    US   :  Os  nUSSS[;        U(       + 5      S-  -
  2   nUUS'   UUS'   [=        S0 UD6$ )a  
Given three points on a 2D or 3D arc find the center,
radius, normal, and angular span.

Parameters
---------
points : (3, dimension) float
  Points in space, where dimension is either 2 or 3
return_normal : bool
  If True calculate the 3D normal unit vector
return_angle : bool
  If True calculate the start and stop angle and span

Returns
---------
info
  Arc center, radius, and other information.
dtype)r   r      )r.   r   r   r   r.   g       @zarc is colinear!g      @)	r.   r   r   r   r   r.   r   r.   r   )	r.   r.   r.   r.   r/   r.   r.   r/   )   r0   )axis)r   r   )r0   r   r   r           Nr/   r   r   r   )np
asanyarrayr   dotshapesqrtminsumprodtolmerge
ValueErrorreshapeTstrictr   allcloselinalgnormunitizecrossappenddiff	_TOL_ZEROpiarccosabsarctan2sortintr   )r'   r(   r)   vectorsabc2abcscaleedgeshalfdenomr   ba2r   resultvectoredge_directionr5   angler   angles_sortedreverses                        r   
arc_centerr]   &   s$   * ]]64F Y&"33G66'1*qcFLLO34D
''$-C GGIEKE99;D2774<((Esyy+,,rwwu~+rwwu~=>F +,/MM
V
V	cqckDC XX\\#*F
zz}}RYY^^FO!^DfMMMM 1F<<6!  $||GAJ;2BIIgaj!4LM F8
  $||BHHgaj['!*,MNF8fo.a0fffaVn%)a- EEE1y= EIIcNE u:	!bffn&=&CUUQY%'EVArrE]__TrT23beeai?1v/"VAYAAq1AA%&C!cg+.>.B*B&CD(xvVr   c                 x   [         R                  " U SS9u  p [        U 5      nUR                  UR
                  UR                  UR                  4u  pVpxU(       a  [        R                  S-  nU[        R                  -  n	Xh-  [        R                  U-  -  n
[        R                  " X/5      n[        R                  " US[        R                  5      n[!        [        R"                  " U5      5      n[         R$                  " U S   U-
  5      n[         R$                  " [        R&                  " U* U5      5      n[        R(                  " SX5      n[        R*                  " X[S45      nX[        R,                  " U5      R/                  S5      -  U-  -  nX[        R0                  " U5      R/                  S5      -  U-  -  nU(       d  [2        R4                  (       a  [         R6                  " U SS	/   USS	/   -
  5      nU[2        R8                  :  R;                  5       nU(       dL  [<        R>                  " S
[A        U5      U5        [<        R>                  " S[A        U 5      5        [C        S5      eU SS	/   USS	/'   USS2SSU-
  24   nU$ ! [         a    U(       a  U SS2SS24   s $ U s $ f = f)a  
Returns a version of a three point arc consisting of
line segments.

Parameters
---------
points : (3, d) float
  Points on the arc where d in [2,3]
close :  boolean
  If True close the arc into a circle
scale : float
  What is the approximate overall drawing scale
  Used to establish order of magnitude for precision

Returns
---------
discrete : (m, d) float
  Connected points in space
T)	return_2DNr      r   r.   )r/   r.   r/   z4failed to discretize arc (endpoint_distance=%s R=%s)zFailed arc points: %szArc endpoints diverging!r0   )"r   stack_3Dr]   BaseExceptionr   r   r   r   r3   rI   res	seg_angleseg_fracmaxclipinfrN   ceilrD   rE   linspacetilecosr>   sinr;   r@   row_normr<   allr   warningstrr=   )r'   closerR   is_2Dcenter_infor   RNrZ   count_acount_lcountV1V2tdiscretearc_distarc_oks                     r   discretize_arcr      sO   * MM&D9MF ( 		Fq 	 cmm#GyS\\E12G FFG%&E GGE1bff%EE	fQi&(	)B	bhhr2&	'B
Au$Awwvqz*HBFF1I%%g..33HBFF1I%%g..33H ::}}VQG_xB7H%HIH*//1FJM
 3S[A !;<<"Ar7O!R =a%i=()HOs   !RaR%= s   J J94J98J9c                 |   Uc  S[         R                  /n[         R                  " U[         R                  S9nUR                  S:w  a  [        S5      eUS   US   :  a  US==   [         R                  S-  -  ss'   [         R                  " U [         R                  S9n U R                  S:w  a  [        S5      e[         R                  " US   UR                  5       US   /[         R                  S9n[         R                  " [         R                  " U5      [         R                  " U5      45      U-  U -   nU$ )	ad  
For 2D arcs, given a center and radius convert them to three
points on the arc.

Parameters
-----------
center : (2,) float
  Center point on the plane
radius : float
  Radius of arc
angles : (2,) float
  Angles in radians for start and end angle
  if not specified, will default to (0.0, pi)

Returns
----------
three : (3, 2) float
  Arc control points
r2   r,   )r   zangles must be (2,)!r.   r   r   zonly valid on 2D arcs!)r3   rI   r4   r   r6   r=   arraymeancolumn_stackrl   rm   )r   r   r   threes       r   to_threepointr      s    * ~ruu]]64F||t/00ay6!9q	RUUQY	]]64F||t122 XXvay&++-;2::NF__bffVnbffVn=>G6QELr   )TT)Fg      ?r   )dataclassesr   numpyr3    r   	constantsr   r   rc   r   r;   typedr	   r
   r   r   r   rH   r   boolr]   r   r   r   r   r   <module>r      s{    !    ' ' A A 	 # # #. IM[[&*[AE[[|Sl)r   