Files
intellecton/venv/lib/python3.12/site-packages/matplotlib/__pycache__/bezier.cpython-312.pyc
T

277 lines
21 KiB
Plaintext
Raw Normal View History

Ë
†RjiJãóú—dZddlmZddlZddlZddlZddlmZejed¬«d„««Z
Gd„d e «Z d
„Z
d „Zd „Zd
„Z dd„ZGd„d«Z dd„Zdd„Zd„Zd„Zdd„Zd„Zd„Zdd„Zy)uP
A module providing some utility functions regarding Bézier path manipulation.
é)Ú lru_cacheN)Ú_apié€)ÚmaxsizecóÀ—||kDryt|||z
«}tjd|dz«}tj|dz|z
|z «j t
«S)Nré)ÚminÚnpÚarangeÚprodÚastypeÚint)ÚnÚkÚis úT/home/antigravity/intellecton/venv/lib/python3.12/site-packages/matplotlib/bezier.pyÚ_combrsW€ð ˆ1‚uØÜ ˆAˆq�1‰u‹
€AÜ
� ‰ �!�Q˜‘UÓ€AÜ
�7‰7�A˜‘E˜A‘I˜q‘=Ó !× (Ñ (¬Ó -Ð-ócó —eZdZy)ÚNonIntersectingPathExceptionN)Ú__name__Ú
__module__Ú __qualname__©rrrrs„Ørrcóü‡—||z||zz
}||z||zz
} || } }
|| }
} |
|
z| | zz
Št‰«dkr td«‚|
| }}| |
}}ˆfd„||||fD«\}}}}||z|| zz}||z|| zz}||fS)zŽ
Return the intersection between the line through (*cx1*, *cy1*) at angle
*t1* and the line through (*cx2*, *cy2*) at angle *t2*.
gê-�™—q=zcGiven lines do not intersect. Please verify that the angles are not equal or differ by 180 degrees.c3ó(•K—|] }|‰z –—Œ y­w)Nr)Ú.0rÚad_bcs €rú <genexpr>z#get_intersection.<locals>.<genexpr>9søèø€Ò: A�a˜%•iÑ:ùsƒ)ÚabsÚ
ValueError)Úcx1Úcy1Úcos_t1Úsin_t1Úcx2Úcy2Úcos_t2Úsin_t2Ú line1_rhsÚ line2_rhsÚaÚbÚcÚdÚa_Úb_Úc_Úd_ÚxÚyrs @rÚget_intersectionr6 sÓø€ð˜‘ ˜v¨™|Ñ+€Iؘ‘ ˜v¨™|Ñ+€Ið �F�7€q€AØ �F�7€q€Aà
�‰E�A˜‘E‰M€EÜ
ˆ5ƒz�EÒÜðNóOð Oð��ˆ€B؈R�ˆ€BÛ:¨"¨b°"°bÐ)9Ô:�N€BˆˆB�à
ˆY‰˜˜i™Ñ'€AØ
ˆY‰˜˜i™Ñ'€Aà ˆaˆ4€Krcóx—|dk(r||||fS|| }}| |}}||z|z||z|z}
} ||z|z||z|z} } | |
| | fS)z·
For a line passing through (*cx*, *cy*) and having an angle *t*, return
locations of the two points located along its perpendicular line at the
distance of *length*.
çr)
ÚcxÚcyÚcos_tÚsin_tÚlengthr$r%r(r)Úx1Úy1Úx2Úy2s
rÚget_normal_pointsrBAss€ð�‚|Ø�2�r˜2ˆ~Ðà˜U˜FˆF€FØ�V˜UˆF€Fà
�f‰_˜rÑ
! 6¨F¡?°RÑ#7ˆ€BØ
�f‰_˜rÑ
! 6¨F¡?°RÑ#7ˆ€Bà
ˆr�2�rˆ>Ðrcó.—|ddd|z
z|dd|zz}|S)Néÿÿÿÿrr)ÚbetaÚtÚ next_betas rÚ_de_casteljau1rHZs+€Ø�S�b� ˜Q ™UÑ# d¨1¨2 h°¡lÑ2€IØ Ðrcó—tj|«}|g} t||«}|j|«t |«dk(rnŒ-|D�cgc]}|d‘Œ }}t |«D�cgc]}|d‘Œ }}||fScc}wcc}w)u•
Split a Bézier segment defined by its control points *beta* into two
separate segments divided at *t* and return their control points.
rrrD)r
ÚasarrayrHÚappendÚlenÚreversed)rErFÚ beta_listÚ left_betaÚ
right_betas rÚsplit_de_casteljaurQ_s‘€ô
�:‰:�dÓ €DØ�€IØ
ܘd AÓ&ˆØ×јÔÜ ˆt‹9˜Š>Ø ð ð
&/Ö/˜T��a“Ð/€IÐ/Ü'/° Ó':Ö;˜t�$�r“(Ð;€JÐ;à �jÐ Ð ùò0ùÚ;s Á A8Á& A=cóB—||«}||«}||«}||«}||k(r||k7r td«‚ tj|d|dz
|d|dz
«|kr||fSd||zz} || «}
||
«} || z r| }||
k(r||fS|
}n| }||
k(r||fS|
}| }Œj)uŒ
Find the intersection of the Bézier curve with a closed path.
The intersection point *t* is approximated by two parameters *t0*, *t1*
such that *t0* <= *t* <= *t1*.
Search starts from *t0* and *t1* and uses a simple bisecting algorithm
therefore one of the end points must be inside the path while the other
doesn't. The search stops when the distance of the points parametrized by
*t0* and *t1* gets smaller than the given *tolerance*.
Parameters
----------
bezier_point_at_t : callable
A function returning x, y coordinates of the Bézier at parameter *t*.
It must have the signature::
bezier_point_at_t(t: float) -> tuple[float, float]
inside_closedpath : callable
A function returning True if a given point (x, y) is inside the
closed path. It must have the signature::
inside_closedpath(point: tuple[float, float]) -> bool
t0, t1 : float
Start parameters for the search.
tolerance : float
Maximal allowed distance between the final points.
Returns
-------
t0, t1 : float
The Bézier path parameters.
z3Both points are on the same side of the closed pathrrçà?)rr
Úhypot) Úbezier_point_at_tÚinside_closedpathÚt0Út1Ú toleranceÚstartÚendÚ start_insideÚ
end_insideÚmiddle_tÚmiddleÚ
middle_insides rÚ*find_bezier_t_intersecting_with_closedpathraqs÷€ñL
˜bÓ !€EÙ
˜BÓ
€Cá$ UÓ+€LÙ" 3Ó'€Jà�zÒ! e¨s¢lÜ*Ø AóCð Cð ô �8‰8�E˜!‘H˜s 1™vÑ% u¨Q¡x°#°a±&Ñ'8Ó 9¸IÒ EØ�r�6ˆMð˜"˜r™'‘?ˆÙ" 8Ó,ˆÙ)¨&Ó1ˆ
à ˜-Ò '؈BØ�fŠ}ð˜2�v�
؉CàˆBؘŠð˜2�v�
؈EØ(ˆLð3 rcóh—eZdZdZd„Zd„Zd„Zed„«Zed„«Z ed„«Z
ed„«Z d „Z y
) Ú
BezierSegmentu—
A d-dimensional Bézier segment.
Parameters
----------
control_points : (N, d) array
Location of the *N* control points.
c ó—tj|«|_|jj\|_|_tj |j«|_t|j«D�cgc]`}tj|jdz
«tj|«tj|jdz
|z
«zz‘Œb}}|jj|zj|_ ycc}w)Nr)
r
rJÚ_cpointsÚshapeÚ_NÚ_dr Ú_ordersÚrangeÚmathÚ factorialÚTÚ_px)ÚselfÚcontrol_pointsrÚcoeffs rÚ__init__zBezierSegment.__init__ÇsÀÜŸ
™
 >Ó2ˆŒ
ØŸ=™=×.Ñ.шŒ�”Ü—y‘y §¡Ó)ˆŒ ô  §¡›.ö*àô—‘ §¡¨!¡ Ó,Ü—^‘^ AÓ&¬¯©¸¿¹À!¹ Àa¹Ó)HÑHóJð*ˆð*ð—M‘M—O‘O eÑ+×.Ñ.ˆ�ùò*sÁ9A%D có—tj|«}tjjd|z
|jddd…«tjj||j«z|j
zS)u)
Evaluate the Bézier curve at point(s) *t* in [0, 1].
Parameters
----------
t : (k,) array-like
Points at which to evaluate the curve.
Returns
-------
(k, d) array
Value of the curve for each point in *t*.
rNrD)r
rJÚpowerÚouterrirn©rorFs rÚ__call__zBezierSegment.__call__Ðs`€ô
�J‰J�q‹MˆÜ—‘—‘˜q 1™u d§l¡l±4°R°4Ñ&8Ó9Ü—(‘(—.‘.  D§L¡LÓ1ñ2Ø59·X±Xñ>ð >rcó$—t||««S)zX
Evaluate the curve at a single point, returning a tuple of *d* floats.
)Útuplervs rÚ
point_at_tzBezierSegment.point_at_tâs€ô‘T˜!“W‹~Ðrcó—|jS)z The control points of the curve.)re©ros rrpzBezierSegment.control_pointsès€ð�}‰}Ðrcó—|jS)zThe dimension of the curve.)rhr|s rÚ dimensionzBezierSegment.dimensionís
€ð�w‰wˆrcó —|jdz
S)z@Degree of the polynomial. One less the number of control points.r)rgr|s rÚdegreezBezierSegment.degreeòs€ð�w‰w˜‰{Ðrcó:—|j}|dkDrtjdt«|j}t j |dz«dd…df}t j |dz«ddd…f}d||zzt||«z}t||«|z|zS)uº
The polynomial coefficients of the Bézier curve.
.. warning:: Follows opposite convention from `numpy.polyval`.
Returns
-------
(n+1, d) array
Coefficients after expanding in polynomial basis, where :math:`n`
is the degree of the Bézier curve and :math:`d` its dimension.
These are the numbers (:math:`C_j`) such that the curve can be
written :math:`\sum_{j=0}^n C_j t^j`.
Notes
-----
The coefficients are calculated as
.. math::
{n \choose j} \sum_{i=0}^j (-1)^{i+j} {j \choose i} P_i
where :math:`P_i` are the control points of the curve.
é
zFPolynomial coefficients formula unstable for high order Bezier curves!rNrD)r€ÚwarningsÚwarnÚRuntimeWarningrpr
r r)rorÚPÚjrÚ prefactors rÚpolynomial_coefficientsz%BezierSegment.polynomial_coefficients÷s–€ð2
�K‰Kˆà ˆrŠ6Ü �M‰Mð1Ü2@ô
Bà × Ñ ˆÜ �I‰I�a˜‘c‹Nš1˜d˜7Ñ #ˆÜ �I‰I�a˜‘c‹N˜4¢˜7Ñ #ˆØ˜1˜q™5‘M¤E¨!¨Q£KÑ/ˆ Ü�Q˜‹{˜YÑ&¨Ñ*Ð*rcó�—|j}|dkr*tjg«tjg«fS|j}tjd|dz«dd…df|ddz}g}g}t |j «D]V\}}tj|ddd…«}|j|«|jtj||««ŒXtj|«}tj|«}tj|«|dk\z|dkz} || tj|«| fS)aã
Return the dimension and location of the curve's interior extrema.
The extrema are the points along the curve where one of its partial
derivatives is zero.
Returns
-------
dims : array of int
Index :math:`i` of the partial derivative which is zero at each
interior extrema.
dzeros : array of float
Of same size as dims. The :math:`t` such that :math:`d/dx_i B(t) =
0`
rNrDr)
r€r
Úarrayr‰r Ú enumeratermÚrootsrKÚ full_likeÚ concatenateÚisrealÚreal)
rorÚCjÚdCjÚdimsr�rÚpiÚrÚin_ranges
rÚaxis_aligned_extremaz"BezierSegment.axis_aligned_extremas€ð
�K‰KˆØ �Š6Ü—8‘8˜B“<¤§¡¨"£Ð-Ð -Ø
×
)Ñ
)ˆÜ�i‰i˜˜1˜Q™3Ó¢ 4 Ñ(¨2¨a¨b¨6Ñ1ˆØˆØˆÜ˜sŸu™uÓ%ò ,‰EˆAˆrÜ—‘˜™D˜b˜D™Ó"ˆAØ �L‰L˜ŒOØ �K‰KœŸ ™  Q¨Ó*Õ +ð ,ô—‘˜uÓ%ˆÜ�~‰~˜dÓ#ˆÜ—9‘9˜UÓ# u°¡zÑ2°e¸q±jÑAˆØ�H‰~œrŸw™w u›~¨hÑ7Ð7Ð7rN)
rrrÚ__doc__rrrwrzÚpropertyrpr~r€r‰r˜rrrrcrc½sl„ñò/ò>ò$ð ñóððñóððñóððñ!+óð!+óF8rrccó„—t|«}|j}t|||¬«\}}t|||zdz «\}}||fS)ur
Split a Bézier curve into two at the intersection with a closed path.
Parameters
----------
bezier : (N, 2) array-like
Control points of the Bézier segment. See `.BezierSegment`.
inside_closedpath : callable
A function returning True if a given point (x, y) is inside the
closed path. See also `.find_bezier_t_intersecting_with_closedpath`.
tolerance : float
The tolerance for the intersection. See also
`.find_bezier_t_intersecting_with_closedpath`.
Returns
-------
left, right
Lists of control points for the two Bézier segments.
)rYg@)rcrzrarQ) ÚbezierrVrYÚbzrUrWrXÚ_leftÚ_rights rÚ)split_bezier_intersecting_with_closedpathr <sS€ô,
�vÓ €BØŸ
™
Ðä
7ØÐ,¸ ôC�F€Bˆô' v°°R±¸2©~Ó>�M€Eˆ6Ø �&ˆ=Ðrc óJ—ddlm}|j«}t|«\}}||dd«}|} d}
d} |D]D\}}| }
| t |«dzz
} ||dd«|k7rt j | dd|g«} n|} ŒFtd«‚| jd«}
t|
||«\}}t |«dk(r&|jg}|j|jg}nµt |«d k(r<|j|jg}|j|j|jg}nkt |«d
k(rR|j|j|jg}|j|j|j|jg}n td «‚|dd}|dd}|j€U|t j |j d| |g««}|t j ||j | dg««}nš|t j |j d|
|g«t j |jd|
|g««}|t j ||j | dg«t j ||j| dg««}|r|s||}}||fS) z`
Divide a path into two segments at the point where ``inside(x, y)`` becomes
False.
r)ÚPathéþÿÿÿNréz*The path does not intersect with the patch)rDr¤éézThis should never be reached)Úpathr¢Ú
iter_segmentsÚnextrLr
r�r!Úreshaper ÚLINETOÚMOVETOÚCURVE3ÚCURVE4ÚAssertionErrorÚcodesÚvertices)r§ÚinsiderYÚ
reorder_inoutr¢Ú path_iterÚ
ctl_pointsÚcommandÚ begin_insideÚctl_points_oldÚioldrÚ bezier_pathÚbpÚleftÚrightÚ
codes_leftÚ codes_rightÚ
verts_leftÚ verts_rightÚpath_inÚpath_outs rÚsplit_path_inoutrÄ_sˆ€õ
Ø×"Ñ"Ó$€Iä˜y›/Ñ€J�Ù˜* R S˜/Ó*€Là€Nà €DØ €Aà(òGш
�GØˆØ ŒS�‹_ Ñ
!Ñ!ˆÙ �*˜R˜S�/Ó " lÒ 2ÜŸ.™.¨.¸¸Ð*=¸zÐ)JÓKˆKÙ Ø#‰ð
GôÐEÓFÐFà × Ñ ˜WÓ %€BÜ;Ø
ˆF�Ió�K€Dˆ%ä
ˆ4ƒy�A‚~Ø—k‘k�]ˆ
Ø—{‘{ D§K¡KÐ0‰ Ü ˆT‹�aŠØ—k‘k 4§;¡;Ð/ˆ
Ø—{‘{ D§K¡K°·±Ð=‰ Ü ˆT‹�aŠØ—k‘k 4§;¡;°· ± Ð<ˆ
Ø—{‘{ D§K¡K°·±¸d¿k¹kÐJ‰ äÐ;Ó<Ð<à�a�b�€JØ™�(€Kà ‡z�zÐÙ”r—~‘~ t§}¡}°R°aÐ'8¸*Ð&EÓFÓGˆÙœŸ™¨ °T·]±]À1À2Ð5FÐ'GÓHÓI‰ñ”r—~‘~ t§}¡}°U°dÐ';¸ZÐ&HÓIÜ—~‘~ t§z¡z°%°4Ð'8¸*Ð&EÓFóHˆñœŸ™¨ °T·]±]À1À2Ð5FÐ'GÓHÜŸ™¨ °T·Z±ZÀÀ°^Ð'DÓEóGˆñ™\Ø$ g�ˆà �HÐ Ðrcó$‡‡‡—|dzŠˆˆˆfd„}|S)zÎ
Return a function that checks whether a point is in a circle with center
(*cx*, *cy*) and radius *r*.
The returned function has the signature::
f(xy: tuple[float, float]) -> bool
r¤có6•—|\}}|‰z
dz|‰z
dzz‰kS)Nr¤r)Úxyr4r5r9r:Úr2s €€€rÚ_fzinside_circle.<locals>._f§s,ø€Ø‰ˆˆ1Ø�B‘˜1‰}  B¡¨1™}Ñ,¨rÑ1Ð1rr)r9r:r–rÉrÈs`` @rÚ
inside_circlerÊœsú€ð
ˆa‰€Bö2ð €IrcóR—||z
||z
}}||z||zzdz}|dk(ry||z ||z fS)NrSr)r8r8r)Úx0Úy0r>r?ÚdxÚdyr/s rÚ get_cos_sinrЯsF€Ø
�"‰W�b˜2‘gˆ€BØ ˆb‰�2˜‘7Ñ ˜rÑ!€AàˆA‚vØØ
�‰6�2˜‘6ˆ>ÐrcóÄ—tj||«}tj||«}t||z
«}||kryt|tjz
«|kryy)aË
Check if two lines are parallel.
Parameters
----------
dx1, dy1, dx2, dy2 : float
The gradients *dy*/*dx* of the two lines.
tolerance : float
The angular tolerance in radians up to which the lines are considered
parallel.
Returns
-------
is_parallel
- 1 if two lines are parallel in same direction.
- -1 if two lines are parallel in opposite direction.
- False otherwise.
rrDF)r
Úarctan2r r•)Údx1Údy1Údx2Údy2rYÚtheta1Útheta2Údthetas rÚcheck_if_parallelrÚ¸sX€ô&�Z‰Z˜˜SÓ