K i)dZddlmZddlmZddlmZmZddlm Z m Z ddl m Z m Z ddlmZmZmZmZmZddlmZdd lmZdd lmZdd lmZGd d e Zy)z4Parabolic geometrical entity. Contains * Parabola )S)ordered)_symbolsymbols)GeometryEntity GeometrySet)PointPoint2D)LineLine2DRay2D Segment2DLinearEntity3D)Ellipse)sign)simplify)solveceZdZdZddZedZedZedZedZ ddZ ed Z ed Z d Z ed Zed Zy)ParabolaaA parabolic GeometryEntity. A parabola is declared with a point, that is called 'focus', and a line, that is called 'directrix'. Only vertical or horizontal parabolas are currently supported. Parameters ========== focus : Point Default value is Point(0, 0) directrix : Line Attributes ========== focus directrix axis of symmetry focal length p parameter vertex eccentricity Raises ====== ValueError When `focus` is not a two dimensional point. When `focus` is a point of directrix. NotImplementedError When `directrix` is neither horizontal nor vertical. Examples ======== >>> from sympy import Parabola, Point, Line >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7,8))) >>> p1.focus Point2D(0, 0) >>> p1.directrix Line2D(Point2D(5, 8), Point2D(7, 8)) Nc |rt|d}n tdd}t|}|j|r tdt j |||fi|S)N)dimrz*The focus must not be a point of directrix)r r contains ValueErrorr__new__)clsfocus directrixkwargss ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/geometry/parabola.pyrzParabola.__new__AsY %Q'E!QKEO   e $IJ J%%c5)FvFFcy)aXReturns the ambient dimension of parabola. Returns ======= ambient_dimension : integer Examples ======== >>> from sympy import Parabola, Point, Line >>> f1 = Point(0, 0) >>> p1 = Parabola(f1, Line(Point(5, 8), Point(7, 8))) >>> p1.ambient_dimension 2 rselfs r ambient_dimensionzParabola.ambient_dimensionOs&r!cL|jj|jS)aReturn the axis of symmetry of the parabola: a line perpendicular to the directrix passing through the focus. Returns ======= axis_of_symmetry : Line See Also ======== sympy.geometry.line.Line Examples ======== >>> from sympy import Parabola, Point, Line >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7, 8))) >>> p1.axis_of_symmetry Line2D(Point2D(0, 0), Point2D(0, 1)) )rperpendicular_linerr$s r axis_of_symmetryzParabola.axis_of_symmetryds0~~00<>> from sympy import Parabola, Point, Line >>> l1 = Line(Point(5, 8), Point(7, 8)) >>> p1 = Parabola(Point(0, 0), l1) >>> p1.directrix Line2D(Point2D(5, 8), Point2D(7, 8)) argsr$s r rzParabola.directrix~0yy|r!c"tjS)aThe eccentricity of the parabola. Returns ======= eccentricity : number A parabola may also be characterized as a conic section with an eccentricity of 1. As a consequence of this, all parabolas are similar, meaning that while they can be different sizes, they are all the same shape. See Also ======== https://en.wikipedia.org/wiki/Parabola Examples ======== >>> from sympy import Parabola, Point, Line >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7, 8))) >>> p1.eccentricity 1 Notes ----- The eccentricity for every Parabola is 1 by definition. )rOner$s r eccentricityzParabola.eccentricitysBuu r!ct|d}t|d}|jj}|tjurJd|j z||j jz z}||j jz dz}||z S|dk(rJd|j z||j jz z}||j jz dz}||z S|j\}}|jjdd\}} ||z dz||z dzz}|jj||dz|dz| dzzz }||z S)azThe equation of the parabola. Parameters ========== x : str, optional Label for the x-axis. Default value is 'x'. y : str, optional Label for the y-axis. Default value is 'y'. Returns ======= equation : SymPy expression Examples ======== >>> from sympy import Parabola, Point, Line >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7, 8))) >>> p1.equation() -x**2 - 16*y + 64 >>> p1.equation('f') -f**2 - 16*y + 64 >>> p1.equation(y='z') -x**2 - 16*z + 64 TrealrrN) rrsloperInfinity p_parametervertexxyr coefficientsequation) r%r:r;mt1t2abcds r r=zParabola.equations?6 AD ! AD ! NN   ?d&&'1t{{}}+<=Bdkkmm#a'BBw!Vd&&'1t{{}}+<=Bdkkmm#a'B Bw ::DAq>>..r2DAqa%!q1uqj(B((A.11a4!Q$;?BBwr!cZ|jj|j}|dz }|S)aYThe focal length of the parabola. Returns ======= focal_lenght : number or symbolic expression Notes ===== The distance between the vertex and the focus (or the vertex and directrix), measured along the axis of symmetry, is the "focal length". See Also ======== https://en.wikipedia.org/wiki/Parabola Examples ======== >>> from sympy import Parabola, Point, Line >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7, 8))) >>> p1.focal_length 4 r)rdistancer)r%rF focal_lengths r rGzParabola.focal_lengths+<>>**4::6z r!c |jdS)aThe focus of the parabola. Returns ======= focus : Point See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Parabola, Point, Line >>> f1 = Point(0, 0) >>> p1 = Parabola(f1, Line(Point(5, 8), Point(7, 8))) >>> p1.focus Point2D(0, 0) rr,r$s r rzParabola.focus r.r!c tdd\}}|j}t|trS||vr|gSt t t ||jg||gddDcgc] }t|c}St|trBt|j||jdf||jdfgdk(r|gSgSt|ttfrwt |t|jd|jdjg||gdd}t t |Dcgc]}||vst|c}St|tt frLt t t ||jg||gddDcgc] }t|c}St|t"r t%dt%dcc}wcc}wcc}w) aThe intersection of the parabola and another geometrical entity `o`. Parameters ========== o : GeometryEntity, LinearEntity Returns ======= intersection : list of GeometryEntity objects Examples ======== >>> from sympy import Parabola, Point, Ellipse, Line, Segment >>> p1 = Point(0,0) >>> l1 = Line(Point(1, -2), Point(-1,-2)) >>> parabola1 = Parabola(p1, l1) >>> parabola1.intersection(Ellipse(Point(0, 0), 2, 5)) [Point2D(-2, 0), Point2D(2, 0)] >>> parabola1.intersection(Line(Point(-7, 3), Point(12, 3))) [Point2D(-4, 3), Point2D(4, 3)] >>> parabola1.intersection(Segment((-12, -65), (14, -68))) [] zx yTr3)setr+rz5Entity must be two dimensional, not three dimensionalzWrong type of argument were put)rr= isinstancerlistrrr r rsubs_argsrr r pointsrr TypeError)r%or:r; parabola_eqiresults r intersectionzParabola.intersection$s8u4(1mmo a "Dys Gu !**,/!QT8CCD8F%G!U1X%GHII 7 # ((1aggaj/Aqwwqz?)KLMQRRs  Iu- .Kqxx{AHHQK099;=AD""#%FV FqAv FGH H FG, -Uajjl+aV6??@6B!C!CDE E > *ST T=> >%%G!G!Cs'G+  G0 G0 (G5 c|jj}|tjur?|jjd}t |j jd|z}n|dk(r?|jjd}t |j jd|z}nQ|jj|j }t |j j|jz }||jzS)aP is a parameter of parabola. Returns ======= p : number or symbolic expression Notes ===== The absolute value of p is the focal length. The sign on p tells which way the parabola faces. Vertical parabolas that open up and horizontal that open right, give a positive value for p. Vertical parabolas that open down and horizontal that open left, give a negative value for p. See Also ======== https://www.sparknotes.com/math/precalc/conicsections/section2/ Examples ======== >>> from sympy import Parabola, Point, Line >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7, 8))) >>> p1.p_parameter -4 rrr+) rr6rr7r<rrr- projectionr:rG)r%r>r:pr;rDs r r8zParabola.p_parameterZsB NN   ?++A.ATZZ__Q'!+,A !V++A.ATZZ__Q'!+,A))$**5ATZZ\\ACC'(A4$$$$r!c|j}|jj}|tjur5t |j d|jz |j d}|S|dk(r5t |j d|j d|jz }|S|jj|d}|S)apThe vertex of the parabola. Returns ======= vertex : Point See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Parabola, Point, Line >>> p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7, 8))) >>> p1.vertex Point2D(0, 4) rr+) rrr6rr7r r-r8r)rU)r%rr>r9s r r9zParabola.vertexs.  NN   ?5::a=4+;+;;UZZ]KF  !V5::a=%**Q-$:J:J*JKF **77=a@F r!)NN)r:r;)__name__ __module__ __qualname____doc__rpropertyr&r)rr1r=rGrrUr8r9r#r!r rrs*X G(==22  D*X  D24?l*%*%Xr!rN)r] sympy.corersympy.core.sortingrsympy.core.symbolrrsympy.geometry.entityrrsympy.geometry.pointr r sympy.geometry.liner r r rrsympy.geometry.ellipsersympy.functionsrsympy.simplify.simplifyrsympy.solvers.solversrrr#r!r ris;&.=/NN* ,'R{Rr!