
    Mi&                     j   S r SSKrSSKrSSKrSSKJrJrJrJ	r	  SSKJ
r  SSKJr  SSKJrJr  SSKJrJrJr  SS	KJr  SS
KJrJrJrJrJrJrJr   SSKJ r   SSK!J"r#  \" S5      r'S\	RP                  " S5      4S\	RP                  " S5      4S\	RP                  " S5      4/r)    SRS\S\\   S\*S\\   S\\   S\4S jjr+  SSSSS\S\\   S\*S\4
S jjr,    STSSS\S \\   S\*S!\*S"\\   S\4S# jjr-S$\S%\S\4S& jr. SUS'\S(\S\S\\   S\4
S) jjr/   SVS*\\0   S+\\0   S,\*S\\\Rb                     \\Rd                     4   4S- jjr3S\4S. jr4   SWS/\\   S\\   S0\\   4S1 jjr5S\4S2 jr6SXS3\S4\4S5 jjr7   SYS4\S6\\   S\\   S\4S7 jjr8    SZS\S4\S6\\   S\\   S\4
S8 jjr9  S[S4\S\S\\   S\\   S\4
S9 jjr:    S\S4\S\\   S\\   S:\\   S\\   4
S; jjr;    S\S<\S=\S\\   S\\   S\\   S:\\   4S> jjr<S:\4S? jr=S]S@\4SA jjr>     S^SB\S\\   SC\\   SD\\   SE\\   4
SF jjr? S_SG\SB\\   4SH jjr@  S[SI\SJ\\   SK\\   4SL jjrA   S`SM\SN\SO\SP\S\\   4
SQ jjrBg! \$ a/  r%\RL                  " \%5      r \RL                  " \%5      r# Sr%C%GNOSr%C%ff = f)azP
creation.py
--------------

Create meshes from primitives, or with operations.
    N   )
exceptionsgrouping	trianglesutil)transformations)Trimesh)logtol)align_vectorsfaces_to_edgesplane_transform)get_json)	ArrayLikeDictIntegerNDArrayNumberOptionalTuple)Polygon)loadszcreation.jsonearcutmapbox_earcutmanifold
manifold3dtriangle
linestringanglecapsections	transformreturnc           	      r
   [         R                  " U [         R                  S9n [        U R                  5      S:w  d  U R                  S   S:w  a  [        S5      eUc  [         R                  S-  nSnO'[        R                  " U[         R                  S-  SS	9nUc"  [        U[         R                  S-  -  S
-  5      nUS-  n[         R                  " SX5      n[         R                  " [         R                  " U5      [         R                  " U5      45      n[        U 5      n	U SS2S4   n
U SS2S4   n[         R                  " [         R                  " USU	45      R                  S5      [         R                  " U
[        U5      5      R                  S5      -  [         R                  " U[        U5      5      45      nU(       a>  [         R"                  (       a#  [        R$                  " USU	 X* S SS	9(       d   eUSU	*  n[        U5      S-
  n[         R&                  " SU	SSXS-   /5      n[         R                  " XS-
  5      R                  S5      nU[         R                  " [         R(                  " U	S-
  5      S5      R*                  R                  S5      -  nU[,        R.                  " X   5      [         R0                  :     n[         R                  " [         R(                  " U5      U	-  [        U5      S45      R*                  R                  S5      n[         R                  " UR3                  5       U5      R                  S5      n[         R"                  (       a@  [         R$                  " UR                  SUR                  S   S45      U-
  S5      (       d   eUU-   [        U5      -  nU(       d  U(       a  [5        [7        U 5      SS9u  nn[         R"                  (       aJ  [8        R:                  " U5      S   n[=        U5      [=        [?        [        U 5      5      5      :X  d   S5       e[        U5      U	-
  nUU-   n[         R@                  " U5      n[         RB                  " UUU/5      nUb  [D        RF                  " X5      n[I        SUUS.UD6n[         R"                  (       av  [         R$                  " U
SS/   S5      (       d"  [         R$                  " U S   U S   5      (       a3  U(       d  U(       a  URJ                  (       d   eURL                  S:X  d   eU$ )a1  
Revolve a 2D line string around the 2D Y axis, with a result with
the 2D Y axis pointing along the 3D Z axis.

This function is intended to handle the complexity of indexing
and is intended to be used to create all radially symmetric primitives,
eventually including cylinders, annular cylinders, capsules, cones,
and UV spheres.

Note that if your linestring is closed, it needs to be counterclockwise
if you would like face winding and normals facing outwards.

Parameters
-------------
linestring : (n, 2) float
  Lines in 2D which will be revolved
angle
  Angle in radians to revolve curve by or if not
  passed will be a full revolution (`angle = 2*pi`)
cap
  If not a full revolution (`0.0 < angle < 2 * pi`)
  and cap is True attempt to add a tessellated cap.
sections
  Number of sections result should have
  If not specified default is 32 per revolution
transform : None or (4, 4) float
  Transform to apply to mesh after construction
**kwargs : dict
  Passed to Trimesh constructor

Returns
--------------
revolved : Trimesh
  Mesh representing revolved result
dtype   r   zlinestring must be 2D!N       @Tg|=)atol    r   r'   r,   r   g:0yE>r,      )r'   r   r,   r/   )force_verticeszTriangulation added vertices!verticesfaces         )'np
asanyarrayfloat64lenshape
ValueErrorpir   iscloseintlinspacecolumn_stackcossintilereshaper   strictallclosearrayarangeTr   areamergeraveltriangulate_polygonr   r   unique_rowssetrangefliplrvstacktftransform_pointsr	   	is_volume
body_count)r   r   r    r!   r"   kwargsclosedthetapointsperradiusheightr2   slicesquadsingleoffsetstackedr3   cap_0_verticescap_0_facesuniquecap_angle_facesflipped_cap_angle_facesmeshs                            j/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/trimesh/creation.pyrevolverj   )   s1   V z<J :!Z%5%5a%8A%=122} eRUUQYU;u	*R/0 MHKK5+E __bffUmRVVE];<F j/C 1F1FGGFQH%--g6ggfc&k*227;<GGFCK(	
H ::==$3$%tLLL EcT? Z!^F 88QQ3a01DWWT7#++G4F
bggbiia(&133;;GDDF INN8#34syy@AF
 WWRYYv&,s6{A.>?AAII'RFggfllnf-55g>G
zz{{7??BQ+CDvMqQQQQ vX.E c ':J'
# ::)).9!<Fv;#eC
O&<"== /=
 X$%."$))O"< 		5+/FGH&&x; <HE<V<D zz
FAr7OS))R[[A
SU-W-WS >>!>!###K    polygonr   r]   	mid_planec                     [        U 40 UD6u  pVU(       aL  [        R                  " S5      n[        [	        U5      5      S-  US'   Uc  UnO[        R
                  " X'5      n[        SXVXS.UD6nU$ )a  
Extrude a 2D shapely polygon into a 3D mesh

Parameters
----------
polygon : shapely.geometry.Polygon
  2D geometry to extrude
height : float
  Distance to extrude polygon along Z
transform : None or (4, 4) float
  Transform to apply to mesh after construction
triangle_args : str or None
  Passed to triangle
**kwargs : dict
  Passed to `triangulate_polygon`

Returns
----------
mesh : trimesh.Trimesh
  Resulting extrusion as watertight body
   g       r'   r/   )r2   r3   r]   r"   r5   )rM   r6   eyeabsfloatdotextrude_triangulation)	rl   r]   r"   rm   rW   r2   r3   translationrh   s	            ri   extrude_polygonrw      s{    : *'<V<OHffQif.5D#Iy6I ! vNTD Krk   pathanglesconnectrW   c                 H   [         R                  " U[         R                  S9n[        R                  " US5      (       d  [        S5      eUbS  [         R                  " U[         R                  S9nUR                  [        U5      4:w  a  [        UR                  5      eO,[         R                  " [        U5      [         R                  S9n[         R                  R                  US   US   -
  5      [        R                  :  n[        U 40 UD6u  p[        U	5      n
[        R                   " [         R"                  " U
SS9SS	9n[         R$                  " X   R'                  S5      S
S9u  p[         R(                  " X   [         R                  " [        U5      5      [         R*                  " [        U5      5      45      nUR'                  S5      n[        R,                  " USS USS -
  5      n[        R,                  " USS USS -   5      n[         R.                  " US   /UUS   //SS9nU(       a2  U(       a+  [        R,                  " USS/   R1                  SS95      US'   UR                  UR                  :X  d   e[        R2                  " U5      R4                  u  nn[         R6                  " U5      [         R8                  " U5      nn[         R6                  " U5      [         R8                  " U5      nn[         R6                  " U5      [         R8                  " U5      nn[         R                  " [        U5      5      n[         R*                  " [        U5      5      n[         R(                  " U* U-  U-  UU-  -   UU-  UU-  U-  -   UU-  USS2S4   U* U-  U-  UU-  -
  U* U-  UU-  U-  -   UU-  USS2S4   UU-  U* U-  UUSS2S4   UUUU/5      R'                  S5      n[        R:                  (       aP  [=        UU5       H@  u  nn[>        R@                  " / SQ/USS9S   n [         RB                  " U U5      (       a  M@   e   [         R.                  " U Vs/ s H$  n[         RD                  " UUR4                  5      PM&     snSS9SS2SS24   n![        U5      n"UU"-   n#[         R(                  " UU#SS2SS24   U#SS2SSS24   USS2SS24   /5      R'                  S5      n$[         RF                  " [        U5      S-
  5      U"-   V%s/ s H  n%U$U%-   PM
     n&n%U(       a+  U(       a$  [        U5      S-
  U"-  n'U!SU' n!U&S==   U'-  ss'   OU(       a  [I        U5      RK                  U	RM                  5       5      n([        U(5      S:  a  [O        S5      e[         R                  " URQ                  5       S-   [         RR                  S9n)[         RF                  " [        U5      5      U)U'   U)U	   n*U&RU                  [         RV                  " U*5      5        U&RU                  U*U"[        U5      S-
  -  -   5        Uc  0 nSU;  a  SUS'   [         R.                  " U&SS9n&[Y        SU!U&S.UD6n+[        R:                  (       a{  [        [         R$                  " U&5      5      [        U!5      :X  d   eU(       a  U+RZ                  (       d   eU(       a,  U(       a%  U+RZ                  (       d   eU+R\                  S:X  d   eU+$ s  snf s  sn%f )a  
Extrude a 2D polygon into a 3D mesh along a 3D path. Note that this
does *not* handle the case where there is very sharp curvature leading
the polygon to intersect the plane of a previous slice, and does *not*
scale the polygon along the induced normal to result in a constant cross section.

You may want to resample your path with a B-spline, i.e:
  `trimesh.path.simplify.resample_spline(path, smooth=0.2, count=100)`

Parameters
----------
polygon : shapely.geometry.Polygon
  Profile to sweep along path
path : (n, 3) float
  A path in 3D
angles : (n,) float
  Optional rotation angle relative to prior vertex
  at each vertex.
cap
  If an open path is passed apply a cap to both ends.
connect
  If a closed path is passed connect the sweep into
  a single watertight mesh.
kwargs : dict
  Passed to the mesh constructor.
**triangulation
  Passed to `triangulate_polygon`, i.e. `engine='triangle'`

Returns
-------
mesh : trimesh.Trimesh
  Geometry of result
r%   r.   zPath must be (n, 3)!Nr   r,   r   axisrequire_countT)return_inverser+   r'   )r,   ro   ro   )r4   r4         ?F)	translater/   z.triangulation added vertices: no logic to cap!processr1   r5   )/r6   r7   r8   r   is_shaper;   r:   r9   zeroslinalgnormr   rK   rM   r   r   
group_rowssortre   rD   r@   onesunitizeconcatenatemeanvector_to_sphericalrI   rA   rB   rE   ziprS   rT   rF   rt   rH   rO   
differencerL   NotImplementedErrormaxint64appendrQ   r	   rU   rV   ),rl   rx   ry   r    rz   rW   triangulationrX   vertices_2Dfaces_2Dedgesedges_uniquere   inversevertices_tfboundaryvectorvector_meannormalrY   phi	cos_theta	sin_thetacos_phisin_phicos_rollsin_rollr   r   
transformsnmatrixcheckvertices_3Dstrideboundary_nextfaces_slicera   r3   
max_vertex
unconsumedmappedcap_zerorh   s,                                               ri   sweep_polygonr      s)   V ==RZZ0D==w''/00vRZZ8<<CI<'V\\** ( #d)2::6 YY^^DGd2h./#));F/I=IK 8$E &&rwwu1'=QOLii 3 ; ;B ?PTUOF //		bhhs6{3RWWS[5IJK w'H \\$qr(T#2Y./F,,vabzF3BK78K^^fQi[+r
|D1MF'LLB!5!51!5!=>q	 <<4::%%% ))&133JE3 66%="&&-yIvvc{BFF3KWGhH HHSZ E773u:D I)+i(.BBy 7X#5	#AAiAJI	!G+h.BBI	!I$7($BBiAJhHxAJ!	
& gj' * zzVZ0IAv''(96USTUVE;;ua(((( 1
 ..5?@Z6VXX	&Z@q!eK
 [Fv%M//	=BQB'q$B$w)?!QR%Qgg 
 13		#d)a-0H60QR0Qf[6!0QER '$i!mv-
!+:.b	Z		
 [++HNN,<=
z?Q%&VWW &**,*"((;3v;/v (#RYYx()X#d)a- 889~ "y NN5q)E ?Ku??D
zz299U#$K(8888>>!>g>>!>??a'''KG 	A Ss   0+\&\abc                 P    U SS2S4   USS2S4   -  U SS2S4   USS2S4   -  -
  $ )z4
Numpy 2.0 depreciated cross products of 2D arrays.
Nr   r   r5   )r   r   s     ri   	_cross_2dr     s9     QT7Qq!tWqAw1a4000rk   r2   r3   c           
      .   [         R                  " U [         R                  S9n [        U5      n[         R                  " U[         R                  S9n[
        R                  " U S5      (       d  [        S5      e[
        R                  " US5      (       d  [        S5      e[         R                  " U5      [        R                  :  a  [        S5      e[        [         R                  " XSS2SS	24   R                     6 [         R                  " XSS2S
S24   R                     6 5      n[        U5      S:  aR  [         R                  " UR!                  5       5      [         R                  " U5      :w  a  [         R"                  " U5      n[%        U5      n[         R&                  " US
S9n[(        R*                  " US
S9nXU      n	[         R,                  " U	R/                  S5      S	5      R/                  S5      n
[         R0                  " U
[         R,                  " SUSU/[        U	5      5      45      n
[         R,                  " / SQ[        U	5      S
45      nU[         R2                  " [        U	5      5      R/                  S5      S-  -  nUR/                  S5      n[
        R4                  " U 5      nUSS2SSS24   UR7                  5       U/nXR7                  5       SSU/-   U
/n[
        R8                  " X5      u  pUb[  [:        R<                  " X5      n [:        R>                  " U5      (       a*  [         R@                  " [         R"                  " U5      5      n[C        SXS.UD6n[        RD                  (       a  URF                  S:  d   eU$ )a  
Extrude a 2D triangulation into a watertight mesh.

Parameters
----------
vertices : (n, 2) float
  2D vertices
faces : (m, 3) int
  Triangle indexes of vertices
height : float
  Distance to extrude triangulation
transform : None or (4, 4) float
  Transform to apply to mesh after construction
**kwargs : dict
  Passed to Trimesh constructor

Returns
---------
mesh : trimesh.Trimesh
  Mesh created from extrusion
r%   r+   zVertices must be (n,2)r.   zFaces must be (n,3)zHeight must be nonzero!N
   r'   r   r   r|   r~   )r/   r   r'   r'   r   r   r-   ro   r,   r4   r1   r5   )$r6   r7   r8   rs   r   r   r   r;   rr   r   rK   r   subtractrI   r9   signr   rQ   r   r   r   r   rC   rD   r@   rH   stack_3Dcopyappend_facesrS   rT   flips_windingascontiguousarrayr	   rE   volume)r2   r3   r]   r"   rW   signsr   edges_sortedr   r   verticalvertical_facesr   	faces_seqvertices_seqrh   s                   ri   ru   ru     s   8 }}XRZZ8H6]FMM%rxx0E==7++122==((.//	vvf~		!233 
XCRC!Gn../0"++xcrcSTSUgHXHX?Y2ZE 5zA~"''%**,/2776?B		%  5!E775q)L &&|1EL l+,H wwx''0!4<<WEH"''1fa2H#h-*XYZHWW/#h-1CDNbiiH.66w?!CCN#++G4N --)K q$B$w~>I!1!1!3sAv6F!FQL ''@OH&&x; I&&((5)9:E<H<V<D
zz{{S   Krk   triangle_argsenginer0   c                    Uc  [        S [         5       S5      nU b  U R                  (       a  / / 4$ SnUS:X  a  SSKJn  [
        R                  " U R                  R                  5      /nUR                  S U R                   5       5        [
        R                  " U Vs/ s H  n[        U5      PM     sn5      n[
        R                  " U5      nU" XX5      R                  S5      R                  [
        R                   5      R                  S5      n	GOAUS:X  a  SSKn
[
        R                  " U R                  R                  5      SSU R                  R$                  (       a  S	OS
2   SS
 /nUR                  S U R                   5       5        U
R'                  U5      R                  [
        R                   5      n	[
        R                  " U[
        R(                  S9nOrUS:X  al  SSKJn  Uc  Sn[-        U 5      nU" X5      nUS   US   R                  [
        R                   5      pU(       a!  [
        R.                  " US   U5      (       d   eUc!  [0        R2                  " S5        [5        S5      eUW	4$ s  snf )a/  
Given a shapely polygon create a triangulation using a
python interface to the permissively licensed `mapbox-earcut`
or the more robust `triangle.c`.
> pip install manifold3d
> pip install triangle
> pip install mapbox_earcut

Parameters
---------
polygon : Shapely.geometry.Polygon
    Polygon object to be triangulated.
triangle_args
    Passed to triangle.triangulate i.e: 'p', 'pq30', 'pY'="don't insert vert"
engine
  None or 'earcut' will use earcut, 'triangle' will use triangle
force_vertices
  Many operations can't handle new vertices being inserted, so this will
  attempt to generate a triangulation without new vertices and raise a
  ValueError if it is unable to do so.

Returns
--------------
vertices : (n, 2) float
   Points in space
faces : (n, 3) int
   Index of vertices that make up triangles
Nc              3   <   #    U  H  u  pU(       d  M  Uv   M     g 7fNr5   ).0nameexistss      ri   	<genexpr>&triangulate_polygon.<locals>.<genexpr>b  s     CFtts   	r   r   )triangulate_float64c              3   b   #    U  H%  n[         R                  " UR                  5      v   M'     g 7fr   )r6   rG   coords)r   is     ri   r   r   o  s"     F4Eq**4Es   -/r.   r   r   r,   c              3      #    U  HA  n[         R                  " UR                  5      S S UR                  (       a  SOS2   S S v   MC     g 7f)Nr,   r   )r6   rG   r   is_ccw)r   r   s     ri   r   r     s;      
IZABHHQXX92q9:3B?IZs   A	Ar%   r   )triangulatepr2   r   ztry running `pip install mapbox-earcut manifold3d`or `triangle`, `mapbox_earcut`, then explicitly pass:
`triangulate_polygon(*args, engine="triangle")`
to use the non-FSF-approved-license triangle enginez"No available triangulation engine!)next_enginesis_emptyr   r   r6   rG   exteriorr   extend	interiorscumsumr9   rR   rD   astyper   r   r   r   r8   r   _polygon_to_kwargsrF   r
   warningr;   )rl   r   r   r0   rW   r2   r   vringsr3   r   r   argblobs                 ri   rM   rM   <  s%   H ~CCTJ'**2vH5 HHW--4456FG4E4EFF		848a3q684599X&  0WWVBHHWW	 	 
:	 HHW%%,,-.Ww7G7G7N7N!TV.WX
 	 
IPIZIZ
 	
 &&u-44RXX>99U"**5	:	(  M )3.z*D,=,D,DRXX,N% ;;s:9999D	
 =>>U?i 5s   "Jc                   ^^^^ U R                   (       d  [        S5      eS mUUUU4S jn[        R                  " 5       m[        R                  " 5       m[        R                  " 5       mU" U R                  S5      nU R
                   H  n X!" X25      -  nM     [        R                  " T5      m[        R                  " T5      R                  5       mTR                  S   S:X  a  TSS2SS	24   mTTS
.n[        R                  " T5      SS m[        T5      S:  a  TUS'   U$ ! [         a    [        R                  " S5         M  f = f)z
Given a shapely polygon generate the data to pass to
the triangle mesh generator

Parameters
---------
polygon : Shapely.geometry.Polygon
  Input geometry

Returns
--------
result : dict
  Has keys: vertices, segments, holes
zinvalid shapely polygon passed!c                    [         R                  " [         R                  " X U-   5      R                  S5      S5      nUR                  S5      SS R                  S5      n[         R                  " X"S   S   US   S   /45      nU$ )z
Given a start index and length, create a series of (n, 2) edges which
create a closed traversal.

Examples
---------
start, length = 0, 3
returns:  [(0,1), (1,2), (2,0)]
r-   r'   r,   r   r+   r   )r6   rC   rH   rD   rR   )startlengthtileds      ri   
round_trip&_polygon_to_kwargs.<locals>.round_trip  sw     		%8@@I1Mb!!B'//8		59R=%(1+">?@rk   c                   > [         R                  " U R                  5      n[         R                  " [        R
                  " U5      S   5      nX#   nT	R                  U5        TR                  T" U[        U5      5      5        [        U5      nTR                  [         R                  " UR                  5       R                  5      S   5        [        U5      $ )Nr   )
r6   rG   r   r   r   rN   r   r9   r   representative_point)
r   r   r   re   cleanedtestfacetsholesr   r2   s
         ri   add_boundary(_polygon_to_kwargs.<locals>.add_boundary  s    
 (//* --f5a89. jG56 wRXXd779@@A!DE7|rk   r   zinvalid interior, continuingr   r/   Nr'   )r2   segmentsr   )is_validr;   collectionsdequer   r   BaseExceptionr
   r   r6   rR   tolistr:   rG   r9   )	rl   r   r   interiorresultr   r   r   r2   s	        @@@@ri   r   r     s0     :;; 2   "H FE))1-E%%	\(22E & yy"HYYv%%'F ~~aAArrE?"7F HHUOABE
5zA~wM)  	KK67	s   
D)) EEextentsboundsc                 p   [         R                  " [        S   S   S[         R                  S9n[         R                  " [        S   S   S[         R                  S9n[         R                  " [        S   S   S[         R                  S9nUbp  Uc  U b  [        S5      e[         R                  " U[         R                  S9nUR                  S	:w  a  [        S
5      e[         R                  " USS9n X@-  nXBS   -  nOsU bH  [         R                  " U [         R                  S9n U R                  S:w  a  [        S5      eUS-  nX@-  nO(US-  n[         R                  " S[         R                  S9n SU;  a  0 US'   US   R                  SU S.5        [        SXEUSS.UD6nUb  UR                  U5        U$ )aC  
Return a cuboid.

Parameters
------------
extents : (3,) float
  Edge lengths
transform: (4, 4) float
  Transformation matrix
bounds : None or (2, 3) float
  Corners of AABB, overrides extents and transform.
**kwargs:
    passed to Trimesh to create box

Returns
------------
geometry : trimesh.Trimesh
  Mesh of a cuboid
boxr2   C)orderr&   r3   face_normalsz)`bounds` overrides `extents`/`transform`!r%   rp   z`bounds` must be (2, 3) float!r   r|   )r/   zExtents must be (3,)!      ?)r   r   r   metadata)r:   r   F)r2   r3   r  r   r5   )r6   rG   _datar8   r   r;   r:   ptpr7   asarrayupdater	   apply_transform)r   r"   r   rW   r2   r3   r  r  s           ri   r  r    s   4 xxeZ02::NHHHU5\'*#RXXFE88E%L82::VL  G$7HII&

3<<6!=>>&&a(1I		--rzz:==D 455CC**_BJJ?z
:'BC
 \5TZC
 I&Jrk   c            	          [         R                  " [        S   S   [         R                  S9n[         R                  " [        S   S   [         R                  S9n[        SXU R                  SS5      S.U D6$ )	z
Create an icosahedron, one of the platonic solids which is has 20 faces.

Parameters
------------
kwargs : dict
  Passed through to `Trimesh` constructor.

Returns
-------------
ico : trimesh.Trimesh
  Icosahederon centered at the origin.
icosahedronr2   r%   r3   r   Fr2   r3   r   r5   )r6   rG   r  r8   r   r	   pop)rW   r2   r3   s      ri   r  r  E  sj     xxm,Z8

KHHHU=)'2"((CE 

9e0LPV rk   subdivisionsr\   c           
      V   [        U5      n[        U 5      n [        5       nSUl        [	        U 5       H  nUR                  5       nUR                  n[        R                  " [        R                  " US-  / SQ5      5      nXVR                  S5      -  nU=R                  XqU-
  R                  S5      -  -  sl        M     U S::  ax  UR                  n[        R                  " [        R                  " US-  / SQ5      5      nXVR                  S5      -  nU=R                  XqU-
  R                  S5      -  -  sl        SU;   a.  [        R                  " S[        SS9  UR                  S5      US	'   [        SUR                  UR                   S
US.UR                  SS5      S.UD6$ )a  
Create an icosphere centered at the origin.

Parameters
----------
subdivisions : int
  How many times to subdivide the mesh.
  Note that the number of faces will grow as function of
  4 ** subdivisions, so you probably want to keep this under ~5
radius : float
  Desired radius of sphere
kwargs : dict
  Passed through to `Trimesh` constructor.

Returns
---------
ico : trimesh.Trimesh
  Meshed sphere
Fr'   )r   r   r   r-   r   colorz`icosphere(color=...)` is deprecated and will be removed in June 2024: replace with Trimesh constructor kewyword argument `icosphere(face_colors=...)`)category
stacklevelface_colorsspherer:   r\   r   )r2   r3   r  r   r5   )rs   r>   r  	_validaterP   	subdivider2   r6   sqrtrt   rD   warningswarnDeprecationWarningr  r	   r3   )r  r\   rW   ico_vectorsscalarunits           ri   	icospherer$  [  sm   ( 6]F|$L
-CCM< mmo,,
I670088AAA ! q,,
I670088AAA&? (	
 !'

7 3} ii#v6

9e,	
  rk   countc           	         Uc&  [         R                  " SS/[         R                  S9nOJ[         R                  " U[         R                  S9nU[         R                  " US5      -  nUS==   S-  ss'   [         R                  " S[         R
                  US   S9n[         R                  " [         R                  " U5      [         R                  " U5      * 45      U -  n[        SUUS   US	U S
.S.UD6$ )a  
Create a UV sphere (latitude + longitude) centered at the
origin. Roughly one order of magnitude faster than an
icosphere but slightly uglier.

Parameters
----------
radius : float
  Radius of sphere
count : (2,) int
  Number of latitude and longitude lines
transform : None or (4, 4) float
  Transform to apply to mesh after construction
kwargs : dict
  Passed thgrough
Returns
----------
mesh : trimesh.Trimesh
   Mesh of UV sphere with specified parameters
r*   @   r%   r'   r   r4   r   )numr  r  )r   r!   r"   r  r5   )
r6   rG   r   modr?   r<   r@   rB   rA   rj   )r\   r%  r"   rW   rY   r   s         ri   	uv_spherer*    s    8 }"b2bhh/q!!aA KKRUUa1E"&&-"&&-!@AFJJ  q#v6	
  rk   c           	         Uc&  [         R                  " SS/[         R                  S9nO#[         R                  " U[         R                  S9nU[         R                  " US5      -  n[	        [        U 5      5      n [	        [        U5      5      n[         R                  " [         R                  * S-  [         R                  S-  US   5      n[         R                  " [         R                  " U5      [         R                  " U5      45      U-  n[        U5      S-  nUSU SS2S4==   U S-  -  ss'   XgS SS2S4==   U S-  -  ss'   [        U4US   US	XS
.S.UD6$ )a.  
Create a mesh of a capsule, or a cylinder with hemispheric ends.

Parameters
----------
height : float
  Center to center distance of two spheres
radius : float
  Radius of the cylinder and hemispheres
count : (2,) int
  Number of sections on latitude and longitude
transform : None or (4, 4) float
  Transform to apply to mesh after construction
Returns
----------
capsule : trimesh.Trimesh
  Capsule geometry with:
    - cylinder axis is along Z
    - one hemisphere is centered at the origin
    - other hemisphere is centered along the Z axis at height
Nr*   r'  r%   r'   r(   r   r   capsuler:   r]   r\   )r!   r"   r  )r6   rG   r   r)  rr   rs   r?   r<   r@   rA   rB   r9   rj   )r]   r\   r%  r"   rW   rY   r   halfs           ri   r,  r,    s5   8 }"b2bhh/	RVVE1EvFvF KKbeeck58<E"&&-!?@6IJ z?aDuadv|+uadv|+q$I	
  rk   c                 |    SS/U S/SU//nSU;  a  0 US'   US   R                  SXS.5        [        SXRUS.UD6nU$ )a  
Create a mesh of a cone along Z centered at the origin.

Parameters
----------
radius : float
  The radius of the cone at the widest part.
height : float
  The height of the cone.
sections : int or None
  How many pie wedges per revolution
transform : (4, 4) float or None
  Transform to apply after creation
**kwargs : dict
  Passed to Trimesh constructor

Returns
----------
cone: trimesh.Trimesh
  Resulting mesh of a cone
r   r  cone)r:   r\   r]   r   r!   r"   r5   )r  rj   )r\   r]   r!   r"   rW   r   r0  s          ri   r0  r0    si    : a&61+6{3Jz
:&ST IIOD Krk   segmentc                     Ub  [        US9u  pAUc  [        S5      e[        [        U5      5      S-  nSU* /X* /X/SU//nSU;  a  0 US'   US   R	                  SXS.5        [        S	XrUS.UD6$ )
a=  
Create a mesh of a cylinder along Z centered at the origin.

Parameters
----------
radius : float
  The radius of the cylinder
height : float or None
  The height of the cylinder, or None if `segment` has been passed.
sections : int or None
  How many pie wedges should the cylinder have
segment : (2, 3) float
  Endpoints of axis, overrides transform and height
transform : None or (4, 4) float
  Transform to apply to mesh after construction
**kwargs:
    passed to Trimesh to create cylinder

Returns
----------
cylinder: trimesh.Trimesh
  Resulting mesh of a cylinder
r2  ,either `height` or `segment` must be passed!r(   r   r  cylinderr-  r1  r5   )_segment_to_cylinderr;   rr   rs   r  rj   )r\   r]   r!   r2  r"   rW   r.  r   s           ri   r6  r6  '  s    @ 0A	~GHHuV}#Dte*vuo~4yIJz
:
fWX IIO rk   r_minr_maxc                    Ub  [        US9u  pBUc  [        S5      e[        [        U 5      5      n U [        R
                  :  a  [        S	XX4S.UD6$ [        [        U5      5      n[        [        U5      5      S-  nX* /X* /X/X/X* //nSU;  a  0 US'   US   R                  SXUS.5        [        S	XUS.UD6n	U	$ )
at  
Create a mesh of an annular cylinder along Z centered at the origin.

Parameters
----------
r_min : float
  The inner radius of the annular cylinder
r_max : float
  The outer radius of the annular cylinder
height : float
  The height of the annular cylinder
sections : int or None
  How many pie wedges should the annular cylinder have
transform : (4, 4) float or None
  Transform to apply to move result from the origin
segment : None or (2, 3) float
  Override transform and height with a line segment
**kwargs:
    passed to Trimesh to create annulus

Returns
----------
annulus : trimesh.Trimesh
  Mesh of annular cylinder
r4  r5  )r\   r]   r!   r"   r(   r  annulus)r:   r8  r9  r]   r1  r5   )	r7  r;   rr   rs   r   rK   r6  r  rj   )
r8  r9  r]   r!   r"   r2  rW   r.  r   r;  s
             ri   r;  r;  Z  s   D 0A	~GHHeEsyy 
(
SY
 	
 eEuV}#D 
				J z
:evN
  IIOG Nrk   c                 b   [         R                  " U [         R                  S9n U R                  S:w  a  [	        S5      eU S   U S   -
  n[         R
                  R                  U5      nU S   US-  -   n[        / SQU5      n[        R                  " U5      n[         R                  " XT5      nXb4$ )aA  
Convert a line segment to a transform and height for a cylinder
or cylinder-like primitive.

Parameters
-----------
segment : (2, 3) float
  3D line segment in space

Returns
-----------
transform : (4, 4) float
  Matrix to move a Z-extruded origin cylinder to segment
height : float
  The height of the cylinder needed
r%   rp   zsegment must be 2 3D points!r   r   r  r   r   r   )r6   r7   r8   r:   r;   r   r   r   rS   translation_matrixrt   )r2  r   r]   midpointrotationrv   r"   s          ri   r7  r7    s    " mmG2::6G}}788QZ'!*$FYY^^F#FqzVc\*HY/H''1K{-Irk   
face_countc                     [         R                  R                  U S-  S45      S-
  n[         R                  " U S-  5      R                  S5      n[	        XS9nU$ )z
Return random triangles as a Trimesh

Parameters
-----------
face_count : int
  Number of faces desired in mesh

Returns
-----------
soup : trimesh.Trimesh
  Geometry with face_count random faces
r/   r  r.   r1   )r6   randomrH   rD   r	   )rA  r2   r3   soups       ri   random_souprE    sR     yya 34s:HIIj1n%--g6EH2DKrk   origin_sizeorigin_coloraxis_radiusaxis_lengthc                    [        U 5      n Uc  [        R                  " S5      nUc  / SQnUc  U S-  nUc  U S-  n[        U S9nUR	                  U5        X%R
                  l        [        R                  " SSUS-  /5      n[        X4UR                  U5      S9n/ S	QUR
                  l        [        R                  " SSUS-  /5      n[        R                  " [        R                  " S
5      / SQ5      n[        UUUR                  U5      R                  U5      S9n	/ SQU	R
                  l        [        R                  " SSUS-  /5      n[        R                  " [        R                  " S5      / SQ5      n[        UUUR                  U5      R                  U5      S9n
/ SQU
R
                  l        [        R                  " XZX/5      nU$ )aJ  
Return an XYZ axis marker as a  Trimesh, which represents position
and orientation. If you set the origin size the other parameters
will be set relative to it.

Parameters
----------
origin_size : float
  Radius of sphere that represents the origin
transform : (4, 4) float
  Transformation matrix
origin_color : (3,) float or int, uint8 or float
  Color of the origin
axis_radius : float
  Radius of cylinder that represents x, y, z axis
axis_length: float
  Length of cylinder that represents x, y, z axis

Returns
-------
marker : trimesh.Trimesh
  Mesh geometry of axis indicators
ro   )   rK  rK  rK  g      @      $@)r\   r   r'   )r\   r]   r"   )r   r   rK  i)r   r   r   )r   rK  r   Z   )r   r   r   )rK  r   r   )rs   r6   rq   r$  r  visualr  rS   r>  r6  rt   rotation_matrixradiansr   r   )rF  r"   rG  rH  rI  axis_originrv   z_axisr@  y_axisx_axismarkers               ri   r}   r}     s   > $K FF1I	+!C'!D( ;/K	* &2" ''A{Q(?@K)--:TF !,FMM ''A{Q(?@K!!"**S/9=H--)--k:F !,FMM ''A{Q(?@K!!"**R.)<H--)--k:F !,FMM {FCDFMrk   marker_heightc           	         Uc  US-  n[        US9/n SSKJn  U[        R                  " [        R                  " U R                  S   5      S	-  5      -  nU[        R                  " [        R                  " U R                  S   5      S	-  5      -  nUn[        R                  " S
U* U* U* 4XV* U* 4XVU* 4U* Xg* 4/[        S9n[        R                  " [        R                  " U5      U45      R                  S5      n	[        R                  " X/ SQ   45      R                  S5      n	UR!                  U" U	5      5        U$ ! [         a    [        R
                  " SSS9  Us $ f = f)a  
Create a visual marker for a camera object, including an axis and FOV.

Parameters
---------------
camera : trimesh.scene.Camera
  Camera object with FOV and transform defined
marker_height : float
  How far along the camera Z should FOV indicators be
origin_size : float
  Sphere radius of the origin (default: marker_height / 10.0)

Returns
------------
meshes : list
  Contains Trimesh and Path3D objects which can be visualized
rL  )rF  r   )	load_pathz#unable to create FOV visualization!T)exc_infor   r(   )r   r   r   r%   r.   )r   r'   r'   r/   r/   ro   ro   r   )r,   r'   r/   )r}   path.exchange.loadrX  ImportErrorr
   r   r6   tandeg2radfovrG   rs   r@   
zeros_likerD   rR   r   )
camerarV  rF  meshesrX  xyzrZ   r   s
             ri   camera_markerre  /  sP   , #d* {+,F1 	rzz&**Q-83>??Arzz&**Q-83>??AA XX	aR!aRL1b1"+qbzQB2;GuF f 5v>?GGPH yy(+C$DEFNNzZH MM)H%&M5  9DIs   E !E('E(trisoriginr   c                    Uc  [         R                  " S5      nO	[        XS9n[        R                  " U R                  S5      U5      R                  S5      n[         R                  " XD45      R                  S5      nSUSSS	2SS2S	4'   [        R                  " UR                  S5      [         R                  R                  U5      S
9n[         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R                  " / SQ[        R                  " UR                  S5      5      R                  5      n[         R                  " U[        U5      S45      R                  S[        U5      S45      n	[         R                   " U5      XS:  '   U	[         R"                  " [        U	5      5      S-  R                  S5      -   R                  S5      n
[%        XjSS9nU$ )az  
Return a mesh consisting of multiple watertight prisms below
a list of triangles, truncated by a specified plane.

Parameters
-------------
triangles : (n, 3, 3) float
  Triangles in space
origin : None or (3,) float
  Origin of truncation plane
normal : None or (3,) float
  Unit normal vector of truncation plane

Returns
-----------
mesh : trimesh.Trimesh
  Triangular mesh
Nro   )rg  r   r.   )r,   	   )r,   r/   r/   r   r   r'   )r   )r'   r   r   )r/   ro      )r   r   ro   )r   r'   rj  )r'   r   r/   )ro   r/   r   )rj  ro   r   )r/   rj  r'   r=  r,   r/      )r,   r   r   Fr  )r6   rq   r   rS   rT   rD   r@   r   invrG   rt   r   crossrI   rC   r9   rQ   rH   r	   )rf  rg  r   r"   transformedvsr2   frm  f_seqr3   rh   s               ri   truncated_prismsrr  k  s   . ~FF1I	#6A	 %%dll7&;YGOOPWXK 
+3	4	<	<Z	HBBqt!tQzN ""2::g#6ryy}}Y?WXH 			
	A FF9iook.A.A*.MNPPQEGGAK(!,-55r3q61oFEyy|E!)biiE
+a/88DDMMgVE H5ADKrk   major_radiusminor_radiusmajor_sectionsminor_sectionsc                 N   [         R                  " SS[         R                  -  US-   SS9n[         R                  " U[         R                  " U5      -  U[         R
                  " U5      -  45      U S/-   nSU;  a  0 US'   US   R                  SXS.5        [        S
XrUS	.UD6$ )ay  Create a mesh of a torus around Z centered at the origin.

Parameters
------------
major_radius: (float)
  Radius from the center of the torus to the center of the tube.
minor_radius: (float)
  Radius of the tube.
major_sections: int
  Number of sections around major radius result should have
  If not specified default is 32 per revolution
minor_sections: int
  Number of sections around minor radius result should have
  If not specified default is 32 per revolution
transform : (4, 4) float
  Transformation matrix

**kwargs:
  passed to Trimesh to create torus

Returns
------------
geometry : trimesh.Trimesh
  Mesh of a torus
r   r'   r   T)endpointr  torus)r:   rs  rt  r1  r5   )r6   r?   r<   r@   rA   rB   r  rj   )rs  rt  ru  rv  r"   rW   r   r   s           ri   ry  ry    s    B ++aRUUNQ$6
FC	s	#\BFF3K%?@	qJ z
:<V
  )OU rk   )NFNN)NF)NTTNr   )NNF)NNN)r/   r   )r   NN)r   r   NN)NN)NNNN)d   )g{Gz?NNNN)g?N)r*   r*   N)C__doc__r   r  numpyr6    r   r   r   r   r   rS   baser	   	constantsr
   r   geometryr   r   r   	resourcesr   typedr   r   r   r   r   r   r   shapely.geometryr   shapely.wkbr   load_wkbr   EExceptionWrapperr  
has_moduler   boolrj   rw   r   r   ru   strr8   r   rM   r   r  r  r$  r*  r,  r0  r6  r;  r7  rE  r}   re  rr  ry  r5   rk   ri   <module>r     s      3 3 #   D D  M M M.(- 	! t/0./,- #"&%)bbFb 
b w	b
 	"b bP &*	+++ 	"+ 	+ +b #'!WW
W YW 
	W
 W TNW Wt1 1W 1 1 &*	\\\ \ 	"	\ \B $(  	iC=i SMi 	i 72:: 112iXY4 Yz $(%)"&>i >	"> Y>BW ,8G 8 8x !%%)..I. 	".
 .d !%%)	444 I4 	"	4 4t #'%)	&&& w& 	"	& &V  $"&#'%)00V0 w0 i 	0
 	"0l  $"&%)#'FFF VF w	F
 	"F i FR) DG * %)(,$($(SS	"S 9%S &!	S
 &!Sn JN9!96>v6F9| #'"&@
@Y@ Y@L ! %)/// / 	/
 	"/k,  . ))!,G**1-H	.s   I= =J2$J--J2