;ò dˆDc@sgdklZdkZdkZdkZdkZdkZdkZdkZdk Z dkl Z l Z ye gƒWne j od„Z nXdefd„ƒYZd„Zdd„Zd „Zd „Zd eifd „ƒYZd efd„ƒYZeieƒe_defd„ƒYZeieƒe_defd„ƒYZeieƒe_dS((s nested_scopesN(sdegreessradianscCsttt|ƒƒ|ƒSdS(N(szipsxrangeslenslist(slist((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys enumerate!ssInvalidParamExceptioncBstZd„ZRS(NcCs ||_dS(N(sparamsselfsnormsubpathitemparam(sselfsparam((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys__init__)s(s__name__s __module__s__init__(((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysInvalidParamException'scCs|d ti|Œ|d ti|Œf}|dti|Œ|dti|Œf} d|} d| tid| | d| ƒd} |d| ||d|d| ||df}|d| || d|d| || df}|d| ||d|d| ||df} |d| || d|d| || df} |d||d|d||df}|d|| d|d|| df} d|d|dd|d|df}|| |||| | fSdS( Niif0.31919999999999998f15.0f-15.0f24.0f12.0f0.5(stangent1smathshypotsd1stangent2sd2ssoftnesssfssqrtsgsBsr1sf1sr2sf2sg1sg2se(sBstangent1stangent2sr1sr2ssoftnesssf1sf2sesfsg2sgsg1sd2sd1((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pyscurvescontrols_from_endlines_pt,s0. +4444,,,ic sºd}d„}d„}d„} d„}ˆdˆdˆdˆd}ˆdˆdˆdˆdˆdˆd}ˆdˆdˆdˆdˆdˆd}t i ˆdˆdˆdˆdƒ} ||||| |||ƒ}|o|Sn|o.ddfddfddfddfg} nddfg} g}g}xZ| D]R\}}|d|||d | |d ||||d |d ||||||f}|d|||d | |d ||||d |d ||||||f} |gi}ti|ŒD]%}||djo||ƒq8q8~7}|gi}ti| ŒD]%}||djo||ƒqq~7}q^Wg} |o|oWxT|D]H}||d ||t!|ƒ||ƒ\}}| i||fƒqÏWnxnd dgD]`}| o%||||| ||||ƒ} n| o%| |||| ||||ƒ} q,q,W‡‡‡‡d†}| i&|ƒ| SdS(sfFor a curve with given tangents and curvatures at the endpoints this gives the distances between the controlpoints This helper routine returns a list of two distances between the endpoints and the corresponding control points of a (cubic) bezier curve that has prescribed tangents tangentA, tangentB and curvatures curvA, curvB at the end points. Note: The returned distances are not always positive. But only positive values are geometrically correct, so please check! The outcome is sorted so that the first entry is expected to be the most reasonable one ic CsÞd„} | |ƒ}| |ƒ} | |ƒ} |o| o…t|ƒdjpt ‚|d}| o(t|ƒdjpt ‚|d} qKtit|d|ƒƒti||ƒ} q½tit|d|ƒƒti||ƒ}| o(t|ƒdjpt ‚|d} q½tit|d|ƒƒti||ƒ} no| o.||} |d|| t| ƒ|}n:| o.||}|d||t|ƒ|} ngS|o dGHn|| fgSdS(NcCs.y d|Wntj o dSnXdSdS(Nf1.0ii(sxsZeroDivisionError(sx((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysis_zerods   f1e-10f3.0f1.5sfallback with exact zero value(sis_zerosTs T_is_zeroscurvAs curvA_is_zeroscurvBs curvB_is_zerosabssDsAssertionErrorsABsasEsbsmathssqrts mathutilsssignsdebug( sTsDsEsABscurvAscurvBsdebugsas T_is_zeros curvB_is_zeros curvA_is_zerosis_zerosb((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pystest_divisionsbs6     2.2 $ $ c Cs}tit|d|ƒƒti||ƒ}tit|d|ƒƒti||ƒ} t td|||ƒt|ƒƒ} t td| | |ƒt|ƒƒ} |djoš| djot| |ƒ|| jortd|t|ƒ||ƒ|| joEt||ƒ|| jo*td| t| ƒ||ƒ|| jo!|o dGHn|| fgSngSdS(Nf1.5isfallback with T approx 0(smathssqrtsabssDscurvAs mathutilsssignsasEscurvBsbsminsq1sq2sTs thresholdsdebug( sTsDsEsABscurvAscurvBs thresholdsdebugsasq1sq2sb((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysfallback_smallTs..''ª c CsÌg} ||}|d||t|ƒ|} |djo~| djoqtd| | |ƒ|t t||ƒt|ƒƒjo5t|||ƒ|t t||ƒt|ƒƒjo'|o dGHn| i || fƒn||} |d|| t| ƒ|}|djo~| djoqtd|||ƒ|t t| |ƒt|ƒƒjo5t| ||ƒ|t t| |ƒt|ƒƒjo'|o dGHn| i || fƒn| SdS(Nf1.5isfallback with curvB approx 0sfallback with curvA approx 0( sresultsEsTsasDscurvAsabssbscurvBs thresholdsminsdebugsappend( sTsDsEsABscurvAscurvBs thresholdsdebugsasbsresult((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysfallback_smallcurvšs  Ž   Ž cCsˆd}||}t||ƒ}xWt|dƒD]E\}}t||ƒ}||jo|||f\}}}q1q1W||fSdS(Nii( sIsyssYsabssxsmindists enumeratesisysdist(sxsyssdistsIsysismindistsY((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys findnearest³s    iiÿÿÿÿf3.375f0.0f4.5if1.5f0.01f0.10000000000000001csÀ|ddjo|ddj}|ddjo|ddj}|dd|dd}|dd|dd}|djo |djotˆˆˆˆƒ\}}t |ƒt |ƒf\}}|djo,||djo|djo||djoU|djo,||djo|djo||djot||ƒSq«dSq¼|djo,||djo|djo||djodSq¼t||ƒSnt||ƒSdS(Niiiiÿÿÿÿ(sxssxsyssyserrxserrys intersectionsAsBstangAstangBstsssabsscmp(sxsyssyssxssserryserrxst(sAstangAsBstangB(s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysmycmpðs!!<<<N('sdebugstest_divisionssfallback_smallTsfallback_smallcurvs findneareststangAstangBsTsBsAsDsEsmathshypotsABscurvAscurvBstestsolss allownegativessignss candidates_as candidates_bssign_assign_bscoeffs_ascoeffs_bsappends_[1]s mathutilss realpolyrootssroots solutionssasabssisbsthrsmycmpssort( sAsBstangAstangBscurvAscurvBs allownegatives candidates_bs candidates_asfallback_smallcurvsABs solutionsssignsscoeffs_bsfallback_smallTs findnearestsEsDscoeffs_asmycmpsTssign_assign_bsasbsisthrstest_divisionss_[1]sdebugsrootstestsols((sAsBstangAstangBs@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys controldists_from_endgeometry_ptRsN  +  "22* . ZZIM/ %)0 c Cs›t||||||ƒd\}}t i |d|d|d||d|d||d|d||d|d||d|d|dƒSdS(Nii( s controldists_from_endgeometry_ptsAsBstangAstangBscurvAscurvBsasbsnormpaths normcurve_pt(sAsBstangAstangBscurvAscurvBsasb((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysnormcurve_from_endgeometry_pt%s%&cCsÏ|d |d|d|d}y d|Wntj ottfSnX|d|d|d|df}|d |d|d|d|}|d |d|d|d|}||fSdS(s…returns the intersection parameters of two evens they are defined by: x(t) = A + t * tangA x(s) = D + s * tangD iif1.0N( stangAstangDsdetsArithmeticErrorsNonesDsAsDAstss(sAsDstangAstangDsdetsDAssst((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys intersection,s# $''sdeformercBstZd„ZRS(NcCs|SdS(N(sbasepath(sselfsbasepath((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysdeformDs(s__name__s __module__sdeform(((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysdeformerBsscycloidcBsqtZdZdeiddeideidddd„Zeeeeeeed„Zd„Zd „Z RS( sþWraps a cycloid around a path. The outcome looks like a spring with the originalpath as the axis. radius: radius of the cycloid halfloops: number of halfloops skipfirst/skiplast: undeformed end lines of the original path curvesperhloop: sign: start left (1) or right (-1) with the first halfloop turnangle: angle of perspective on a (3D) spring turnangle=0 will produce a sinus-like cycloid, turnangle=90 will procude a row of connected circles f0.5i iii-cCsC||_||_||_||_||_||_||_dS(N(s skipfirstsselfsskiplastsradiuss halfloopsscurvesperhloopssigns turnangle(sselfsradiuss halfloopss skipfirstsskiplastscurvesperhloopssigns turnangle((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys__init__Vs      cCsë|tjo |i}n|tjo |i}n|tjo |i}n|tjo |i}n|tjo |i}n|tjo |i}n|tjo |i}nt d|d|d|d|d|d|d|ƒSdS(Nsradiuss halfloopss skipfirstsskiplastscurvesperhloopssigns turnangle( sradiussNonesselfs halfloopss skipfirstsskiplastscurvesperhloopssigns turnanglescycloid(sselfsradiuss halfloopss skipfirstsskiplastscurvesperhloopssigns turnangle((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys__call__`s               cCsJgi}|iƒiD]}||i|ƒƒq~}ti|ƒSdS(N( sappends_[1]sbasepathsnormpaths normsubpathssnspsselfs deformsubpathsresultnormsubpaths(sselfsbasepaths_[1]snspsresultnormsubpaths((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysdeformts9c%Cstti|iƒƒ}tti|iƒƒ}tti|iƒƒ}t|iƒ} t i |i ƒ}t i | ƒ} t i| ƒ}|iƒ}|||d||jotidƒ|Snt i|i}#gi}t|i|idƒD]}|||#ƒq÷~}!|||d||d|it i| }d|dt i |#dƒdt i|#dƒ}gi}|!D]9}||||||t i |ƒ| ||ƒq†~}$|i"|$ƒd}g} x¾t%|!|ƒD]­\}} |i'| gƒd}d|t i|ƒf\} }| |t i|ƒ||}|t i |ƒ}||t i|ƒ|| }t i.||||||ƒ}"||"||"f\}}|i0| gƒd}|t2i3j o|||} t| ƒ} nd} || }| |||||f\}}| |||||f\}}| i|i:|||ƒ|i:| ||ƒ|i:|||ƒƒqñWt;| ƒdjotidƒ|Sn||i<joQ|i=d|dgƒd}|it2i?| ddd!| ddd!Œƒn-t2i?| ddd!| ddd!Œg}xUtdt;| ƒdƒD]:}|it2i?| |dd!| |ddd!ŒƒqqW||i<jo>x;|i=|d t;|ƒgƒD]}|iA|i>ƒqßWnt2i|d |i<ƒSdS( NisDnormsubpath is too short for deformation with cycloid -- skipping...if1.0iiiiiÿÿÿÿsepsilon(Bsabssunitstoptsselfs skipfirstsskiplastsradiussdegreess turnangles mathutilsssignsmathscosscosTurnssinssinTurns normsubpaths arclen_pts totlengthswarningsswarnspiscurvesperhloopsDphisappends_[1]sranges halfloopssisphissDzDphisLsphisZss_arclentoparam_ptsparamsspointsszipsparamstrafos basetrafosbaseZsbaseYstangentXstangentYstangentZssqrtsnormscurveradius_pts pathradiussnormpathsinvalidsfactorslspreeZspreeYspostZspostYsapply_ptslensepsilonssegmentssnormsubpathitemss normcurve_ptsnspsextend(%sselfs normsubpathssinTurns basetrafos pathradiusssignsradiussnspsbaseYsbaseZs turnanglesparamscosTurnsfactors skipfirstsparamssphispostZspostYsLsnormsubpathitemsspreeYspreeZsDzDphis totlengthsskiplastsistangentXstangentZsls_[1]stangentYspointssphissnormsDphisZs((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys deformsubpathxsf  ?04P  # ""I 4,8 ( s__name__s __module__s__doc__sunitst_cms__init__sNones__call__sdeforms deformsubpath(((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pyscycloidGs 3  ssmoothedcBsGtZdZdddd„Zeeeed„Zd„Zd„ZRS(s"Bends corners in a normpath. This decorator replaces corners in a normpath with bezier curves. There are two cases: - If the corner lies between two lines, _two_ bezier curves will be used that are highly optimized to look good (their curvature is to be zero at the ends and has to have zero derivative in the middle). Additionally, it can controlled by the softness-parameter. - If the corner lies between curves then _one_ bezier is used that is (except in some special cases) uniquely determined by the tangents and curvatures at its end-points. In some cases it is necessary to use only the absolute value of the curvature to avoid a cusp-shaped connection of the new bezier to the old path. In this case the use of "obeycurv=0" allows the sign of the curvature to switch. - The radius argument gives the arclength-distance of the corner to the points where the old path is cut and the beziers are inserted. - Path elements that are too short (shorter than the radius) are skipped iif0.01cCs(||_||_||_||_dS(N(sradiussselfssoftnesssobeycurvs relskipthres(sselfsradiusssoftnesssobeycurvs relskipthres((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys__init__ës   c Cs‹|tjo |i}n|tjo |i}n|tjo |i}n|tjo |i}ntd|d|d|d|ƒSdS(Nsradiusssoftnesssobeycurvs relskipthres(sradiussNonesselfssoftnesssobeycurvs relskipthresssmoothed(sselfsradiusssoftnesssobeycurvs relskipthres((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys__call__ñs        cCsDtigi}|iƒiD]}||i|ƒƒq~ƒSdS(N(snormpathsappends_[1]sbasepaths normsubpathss normsubpathsselfs deformsubpath(sselfsbasepaths_[1]s normsubpath((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysdeformüsc. CsÀti|iƒ} |i}t||i| ƒ}t i|i d|ƒ}*|*i ƒ|*i } g} g}xs| D]k}-|-i|ƒ}| i|ƒt| d|ƒ}!td||| ƒ} |i|-i|!| g|ƒƒqoW|i o~d}!td| d| ƒ} | di|!| g|ƒ|di?|d|d|"d|d|d|"dƒ },t>i?|'d|d|"d|'d|d|"dƒ }+|,tB|ƒ}|+tB|ƒ}ntC|"|||'||ƒ}|o'|dddjo|dddjo¾|d\}}$t||ƒ}t|$|ƒ}$|i= otG|"|||'ƒ\})}|)tJj o$|tJj o|)djo |djo.t|tB|)ƒƒ}t|$tB|ƒƒ}$qiqn²tG|"|||'ƒ\})}|)tJj o |tJj o$dtB|)ƒ}dtB|ƒ}$nYtKiL|"d|d|"d|dƒ}|dtKiL|Œ}|dtKiL|'Œ}$|"d||d|"d||df} |d|$|'d|d|$|'df}|it i9|"| ||ŒƒqqW|io|iPƒn|SdS( Nsepsilonf0.5iiÿÿÿÿissoftnessf0.65000000000000002f3.0(Qsunitstoptsselfsradiuss radius_pts normsubpathsepsilonsmaxs relskipthresspertinentepsilonsnormpathsnormsubpathitemsspertinentnormsubpathsflushskippedlinespertinentnormsubpathitemss arclens_ptsparamsspertinentnormsubpathitems arclen_ptsappendsminsl1_ptsl2_ptsarclentoparam_ptsclosedsnewnormsubpathsrangeslensisthissnexts thisparamss nextparamssthisnormsubpathitemsnextnormsubpathitems thisarclen_pts nextarclen_ptssegmentssrotationsapply_ptst1st2s isinstances normline_ptscurvescontrols_from_endlines_ptsatend_ptssoftnesssd1sg1sf1sesf2sg2sd2sat_ptsp1sp2s normcurve_pts curvature_ptsc1sc2sobeycurvs mathutilsssignss1ss2sabss controldists_from_endgeometry_pts controldistssasds intersectionstsssNonesmathshypotsdistsq1sq2sclose(.sselfs normsubpathsf1sdistspertinentepsilonst1sf2sasthisnormsubpathitems radius_ptspertinentnormsubpathitemssq1sl2_pts arclens_ptsd2sssnextsparamssd1sp2snextnormsubpathitemsg1sepsilons thisparamss nextarclen_ptsq2snewnormsubpaths controldistssc2sc1sg2s arclen_pts thisarclen_ptsl1_ptsp1sesdsis nextparamsst2sthisstspertinentnormsubpathss2ss1spertinentnormsubpathitem((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys deformsubpathsš      #   $      &&&>"& <<1 4!*,,* (s__name__s __module__s__doc__s__init__sNones__call__sdeforms deformsubpath(((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pyssmoothedØs  sparallelcBs¹tZdZddddgded„Zeeeeeeed„Zd„Zd „Zd „Zd d d „Z d„Z ddd„Z d„Z d„Z d„Zd„Zd„ZRS(screates a parallel normpath with constant distance to the original normpath A positive 'distance' results in a curve left of the original one -- and a negative 'distance' in a curve at the right. Left/Right are understood in terms of the parameterization of the original curve. For each path element a parallel curve/line is constructed. At corners, either a circular arc is drawn around the corner, or, if possible, the parallel curve is cut in order to also exhibit a corner. distance: the distance of the parallel normpath relerr: distance*relerr is the maximal allowed error in the parallel distance sharpoutercorners: make the outer corners not round but sharp. The inner corners (corners after inflection points) will stay round dointersection: boolean for doing the intersection step (default: 1). Set this value to 0 if you want the whole parallel path checkdistanceparams: a list of parameter values in the interval (0,1) where the parallel distance is checked on each normpathitem lookforcurvatures: number of points per normpathitem where is looked for a critical value of the curvature f0.050000000000000003iif0.5i cCsC||_||_||_||_||_||_||_dS(N(sdistancesselfsrelerrssharpoutercornersscheckdistanceparamsslookforcurvaturessdointersectionsdebug(sselfsdistancesrelerrssharpoutercornerssdointersectionscheckdistanceparamsslookforcurvaturessdebug((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys__init__¦s      cCsë|tjo |i}n|tjo |i}n|tjo |i}n|tjo |i}n|tjo |i}n|tjo |i}n|tjo |i}nt d|d|d|d|d|d|d|ƒSdS(Nsdistancesrelerrssharpoutercornerssdointersectionscheckdistanceparamsslookforcurvaturessdebug( sdistancesNonesselfsrelerrssharpoutercornerssdointersectionscheckdistanceparamsslookforcurvaturessdebugsparallel(sselfsdistancesrelerrssharpoutercornerssdointersectionscheckdistanceparamsslookforcurvaturessdebug((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys__call__°s(              cCshti|iƒ|_g}x3|iƒiD]"}|i |ƒ}||i7}q+Wti|ƒ}|SdS(N( sunitstoptsselfsdistancesdist_ptsresultnormsubpathssbasepathsnormpaths normsubpathssnsps deformsubpathsparallel_normpathsresult(sselfsbasepathsresultsparallel_normpathsnspsresultnormsubpaths((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysdeformÉsc' Csý|i}|i}t|ƒt|ƒjo|Sntiƒ}xõtt |i ƒƒD]Þ}!|!d}|!}|i |} |i |}d}|i| dd|d|ƒ\}#} |i|dd|d|ƒ\}}| iddƒ}$|iddƒ}y|i||ƒ}Wn‚tj ov}|i}&d}|i||&dƒ|joê|i||&dƒ|jo|i||&d|d|ƒ\}} |i||&d|d|ƒ\}} |i#d||dgƒ}%|%d|%di$|%di%ƒŒf}%qq|i||&d|d|ƒ\}} |i#d|gƒ}%n;|i||&d|d|ƒ\}} |i#|dgƒ}%|i&ti'|%d|ƒƒ}nX|i(o |di oqUn|i( o |}qUn|$d|d|$d|d}|$d|d|$d|d}|djpt|t+i,|ƒƒ|joé|i-o||djoÎ|i%ƒ|i.ƒf\}}t1|||$|ƒ\} }"|d| |$d|d| |$df}titi'ti5|d|d|d|dƒti5|d|d|d|dƒgƒgƒ}nã|i.ƒ}|i%ƒ} |i.ƒ} t+i:| d|d| d|dƒ}t+i:| d|d| d|dƒ}|djo t=i>}n t=i@}t=i=||d|dt|ƒtA|ƒtA|ƒƒƒid|ƒ}|iB|ƒ|iB|ƒqU|iB|ƒqUW|i(o |di o|Sn|iCodd}|i|dddd|d|ƒ\}#} |i|dddd|d|ƒ\}}| iddƒ}$|iddƒ}|$d|d|$d|d}|$d|d|$d|d}|djpt|t+i,|ƒƒ|jo|i-o||djoÎ|i%ƒ|i.ƒf\}}t1|||$|ƒ\} }"|d| |$d|d| |$df}titi'ti5|d|d|d|dƒti5|d|d|d|dƒgƒgƒ}nã|i%ƒ}|i%ƒ} |i.ƒ} t+i:| d|d| d|dƒ}t+i:| d|d| d|dƒ}|djo t=i>}n t=i@}t=i=||d|dt|ƒtA|ƒtA|ƒƒƒid|ƒ}|i(o#|di o|i(o |di o|iB|ƒqgnt |ƒdjo|diDƒqÆx#|dD]}|diF|ƒq—W|i(d|_(n|iGo%|iH|ti|gƒ|ƒ}n|SdS( s:returns a list of normsubpaths building the parallel curveif0.01if0.5isepsiloniÿÿÿÿN(Isselfsdist_ptsdistsorig_nspsepsilonsabssnormpathsresultsrangeslensnormsubpathitemssisprevsnextsprev_orig_nspitemsnext_orig_nspitemsstepsizesvalid_near_rotations prev_params prev_rotations next_params next_rotationsapply_pts prev_tangents next_tangentsdeformsubpathitemsnext_parallel_normpathsInvalidParamExceptionsesnormsubpathitemparamsinvalid_nspitem_params length_ptsp1sfoosp2ssegmentssmodifiedbegin_ptsatend_pts deformsubpaths normsubpaths normsubpathsssinanglescosanglesmathsasinssharpoutercornerss atbegin_ptsA1sA2s intersectionst1st2sBs normline_pts arc_normpaths arccentersarcbegsarcendsatan2sangle1sangle2spathsarcn_ptsarcclasssarc_ptsdegreessjoinsclosedsclosesnspitemsappendsdointersectionsrebuild_intersected_normpath('sselfsorig_nspsarcclasssdists next_tangentssinanglesangle1sresultsangle2sarcbegs prev_rotationst1sprev_orig_nspitemsfoosnext_orig_nspitemsnext_parallel_normpaths arc_normpathsnextsA1snspitems arccentersprevsA2scosanglesBsepsilonsstepsizes next_paramsp2sp1ses next_rotationsarcendsist2s prev_params prev_tangentssegmentssinvalid_nspitem_param((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys deformsubpathÒsÀ      %% %%+%%# ""-,i   **    '  --""-,i   **    '0  %c Csº|i}t|tiƒo |idgƒdiddƒ}|i ƒ} |i ƒ}ti| d||d| d||d|d||d|d||dƒid|ƒSn|i||ƒ} | o[tiƒ} |i|| ddƒ|jo| iddƒn|i|| ddƒ|jo| idƒnxßtt| ƒdƒD]Ç}d| || |d}|i|gƒd} | tijot|ƒ‚n| |djpt|| ƒdjoI|i |i!| ||d!ƒd|ƒ}|i#o| i|ƒq$q]q]W| Sn‡|idgƒd} || djpt|| ƒdjo>|i ||ƒ}|i#oti|gƒSq¶tiƒSn tiƒSdS(s=Returns a parallel normpath for a single normsubpathitem Analyzes the curvature of a normsubpathitem and returns a normpath with the appropriate number of normsubpaths. This must be a normpath because a normcurve can be strongly curved, such that the parallel path must contain a holeiisepsiloniÿÿÿÿf0.5iN($sselfsdist_ptsdists isinstancesnspitemsnormpaths normline_ptsrotationsapply_ptsnormals atbegin_ptsstartsatend_ptsendspathsline_ptsepsilonsdistcrossingparameterss crossingssresults length_ptsinsertsappendsrangeslensis middleparams curvature_pts middlecurvsinvalidsInvalidParamExceptionsabssdeformnicecurvessegmentss parallel_nspsnormsubpathitems( sselfsnspitemsepsilons parallel_nspsdistsnormalsisends middleparamsstartsresults middlecurvs crossings((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysdeformsubpathitemzsB "  ,:   (* ( f0.0f1.0c Cs|i}d}|i||gƒ\}}|t i jot |ƒ‚n|t i jot |ƒ‚n|i ddƒ}|i ddƒ}|i||gƒ\} } | d||d| d||df}| d||d| d||df} ti|d| d|d| dƒ|jo.ti|d|d|d|dƒ|jo6t it i|d|d| d| dƒgƒSnt id|ƒ} t| | |d |df|d |dfƒ\}}|tjp+||djpt|ƒt|ƒ|jp8|tjp+||djpt|ƒt|ƒ|jo£|i||gƒ\}} |t i j pt!‚| t i j pt!‚|d||}| d|| }t$|| ||||ƒ}|o.|d\}}|djo |djo||jo ||jo>t it i|d|d| d| dƒgd|ƒ} qt&||ƒ}t&||ƒ}t it i'|d|d|d||d|d||d| d||d| d||d| d| dƒgd|ƒ} qn| i( p.|i)o$| i(o|i*|| |||ƒ o¦|i+|||d||ƒ}|i+||d|||ƒ}|i(o|i( o>t it i|d|d| d| dƒgd|ƒ} qù|i.|ƒ} qýn| SdS(sÚReturns a parallel normsubpath for the normcurve. This routine assumes that the normcurve is everywhere 'less' curved than 1/dist and contains no point with an invalid parameterization f1.0000000000000001e-05iisepsilonf1.0f0.5N(/sselfsdist_ptsdists T_thresholds normcurvesrotations startparamsendparamstangAstangDsnormpathsinvalidsInvalidParamExceptionsapply_ptsat_ptsorig_Asorig_DsAsDsmathshypotsepsilons normsubpaths normline_ptsresults intersectionsasdsNonesabss curvature_pts orig_curvAs orig_curvDsAssertionErrorscurvAscurvDs controldists_from_endgeometry_ptscontroldistpairssmaxs normcurve_ptsnormsubpathitemsscheckdistanceparamss distcheckedsdeformnicecurvesfirstnsps secondnspsjoined(sselfs normcurvesepsilons startparamsendparamstangAsdiststangDs orig_curvAs orig_curvDsresultsDsorig_Dsorig_As secondnsps T_thresholdsAscontroldistpairsscurvAscurvDsasfirstnspsd((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysdeformnicecurveÁsV ,,b69v>&&<  >c Cs|i}ti|ƒtt|i|ƒ|ƒ} gi }|i D]}|||||ƒqC~}x‘t||i|ƒ|i|ƒƒD]k\} }}|tijot| ƒ‚n|iddƒ} titi|d|d| | d|d|d| | d|d|d| | d|d|d| | dƒgd|ƒ}|i|ƒ} gi }|i| dƒD]4} |t"i#|d| d|d| dƒƒq‚~}| p&tt%|ƒt|ƒƒt| ƒjodSqqWdSdS(sœChecks the distances between orig_normcurve and parallel_normsubpath The checking is done at parameters self.checkdistanceparams of orig_normcurve.iiisepsilonN(&sselfsdist_ptsdists mathutilsssignsmaxsabssrelerrsepsilons dist_relerrsappends_[1]scheckdistanceparamsstststartstendszipsorig_normcurvesat_ptsrotationsparamsPsnormpathsinvalidsInvalidParamExceptionsapply_ptsnormals normsubpaths normline_ptscutlinesparallel_normsubpaths intersects cutparamsscutpointsmathshypots distancessmin(sselfsorig_normcurvesparallel_normsubpathsepsilonststartstendscheckdistanceparamss distancessdistscutpoints dist_relerrs cutparamssparamsnormalsPsrotations_[1]stscutline((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys distcheckeds* )6  '! X1 cCs|i}gi}t|iƒD]+}|||||d|idƒq ~}|i |ƒ}x=t||ƒD],\}}|tijot|ƒ‚qsqsWt|d |dƒ}t|d |dƒ}g} x2t||ƒD]!\} } | \}}| \} } | |d| |ddjoÜ|t| |dƒ|t| |dƒt| |dƒt| |dƒ}|i|gƒd}|tijot|ƒ‚nt||ƒ|jo| i|ƒq|i"||d|d|ƒ}| |7} qçqçW| SdS(s>Returns a list of parameters where the curvature is 1/distancef1.0iiÿÿÿÿiststartstendN($sselfsdist_ptsdistsappends_[1]srangeslookforcurvaturessiststartstendsparamss normcurves curvature_ptscurvsszipsparamscurvsnormpathsinvalidsInvalidParamExceptions parampairss curvpairsscrossingparamss parampairscurvpairsbegparamsendparamsbegcurvsendcurvsabss middleparamscurveradius_pts middleradiussepsilonsdistcrossingparametersscps(sselfs normcurvesepsilonststartstendscurvsdistsparamsparamsscurvpairsbegcurvsendcurvs parampairscrossingparamss middleparamsbegparams parampairssis curvpairss middleradiuss_[1]scurvsscpssendparam((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysdistcrossingparametersCs2 K    !Rc Csd|}|i|gƒd} xA| tijo0d||||}|i|gƒd} qW|i ||gƒ\}} t i |d| d|d| dƒ}|} x˜||joŠd|| ||} |i || gƒ\}} t i |d| d|d| dƒ}|i| gƒdtijoPq®| }q®W||i|gƒdfSdS(Nii(sparamspsnspitemsrotationsrotsnormpathsinvalidsstepsizes otherparamsat_ptsendsnewsmathshypotsfarspnewsepsilon( sselfsnspitemsparams otherparamsstepsizesepsilonsendspsfarspnewsnewsrot((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pysvalid_near_rotationvs$* *  cCsG|i||gƒ\}}ti|d|d|d|dƒSdS(Nii(spathsat_ptsparam1sparam2spoint1spoint2smathshypot(sselfspathsparam1sparam2spoint1spoint2((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys length_ptŒsc Cst|ƒ}g}g} h} xÚt|ƒD]Ì}xÃt||ƒD]²}x©tt||ƒƒD]‘}||jo!t|dt||ƒƒ} ntt||ƒƒ} xD| D]<}|||i ||||ƒ}|o x |D]þ\} } t| ƒ|jotd| ƒ|jp't| ƒ|jotd| ƒ|joqånti||t|ƒ| ƒ}ti||t|ƒ| ƒ}|i|ƒ|i|ƒt| ƒ| t|ƒ   !" T  + c CsA|i}|i||gƒ\}}|t i jp |t i jodSn|i ||gƒ\} } |iddƒ} |iddƒ} || d|| df} | d| d| d| d}d}t|ƒ|jo|djSnN| t i jp | t i jodSn|djo| | jSn | | jSdS(Niiiÿÿÿÿf9.9999999999999995e-07(sselfsdist_ptsdistspar_npsrotationsparam1sparam2srot1srot2snormpathsinvalids curvature_ptscurv1scurv2sapply_ptstang2snorm1smult12sepssabs( sselfspar_npsparam1sparam2sdistsrot1smult12srot2sepsscurv1stang2snorm1scurv2((s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys can_continueµs"  "  csfˆi}ˆiˆ|ƒ\‰ ‰‰ˆi |ƒd‰ˆi t j oöx•ˆD]\}}ˆi||gƒ\}}ˆi iti|d|ddƒtiigƒˆi iti|d|ddƒtiigƒqNWx[ˆD]O}ˆi|gƒd}ˆi iti|d|ddƒtiigƒqæWntiƒ} ˆ oˆo| SqhˆSng}g‰x\t!t"ˆƒƒD]H}|i$ti%ˆ|dƒƒˆi$ti%ˆ|t"ˆ|ƒƒƒq‡Wˆ ˆ|ˆ‰ ˆ i'ƒh‰x*t)ˆ ƒD]\}}|ˆt*|ƒƒn| i?|gƒq‡W| SdS( Niif0.050000000000000003f0.029999999999999999cs=ˆˆt|ƒ}||djo |dSn |dSdS(Nii(s selfintpairss selfintsriapsidspspair(spspair(s selfintpairss selfintsriap(s@/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/deformer.pys otherparamüs csýh}x(ˆD] }ˆt|ƒ|t|ƒ