K i5.dZddlZddlmZmZmZddlmZddlm Z ddl m Z ddl m Z ddlmZmZdd lmZdd lmZdd lmZdd lmZmZdd lmZddlmZddlmZm Z ddl!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(Gdde&Z)Gdde)Z*Gdde)Z+y)aDGeometrical Points. Contains ======== Point Point2D Point3D When methods of Point require 1 or more points as arguments, they can be passed as a sequence of coordinates or Points: >>> from sympy import Point >>> Point(1, 1).is_collinear((2, 2), (3, 4)) False >>> Point(1, 1).is_collinear(Point(2, 2), Point(3, 4)) False N)SsympifyExpr)Add)Tuple)Float)global_parameters) nsimplifysimplify) GeometryError)sqrt)im)cossin)Matrix) Transpose)uniq is_sequence) filldedent func_name Undecidable)GeometryEntity) prec_to_dpsc\eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZedZedZedZedZdZdZdZd(dZdZdZdZ edZ!dZ"edZ#edZ$d Z%ed!Z&ed"Z'ed#Z(d$Z)d%Z*ed&Z+y'))PointaA point in a n-dimensional Euclidean space. Parameters ========== coords : sequence of n-coordinate values. In the special case where n=2 or 3, a Point2D or Point3D will be created as appropriate. evaluate : if `True` (default), all floats are turn into exact types. dim : number of coordinates the point should have. If coordinates are unspecified, they are padded with zeros. on_morph : indicates what should happen when the number of coordinates of a point need to be changed by adding or removing zeros. Possible values are `'warn'`, `'error'`, or `ignore` (default). No warning or error is given when `*args` is empty and `dim` is given. An error is always raised when trying to remove nonzero coordinates. Attributes ========== length origin: A `Point` representing the origin of the appropriately-dimensioned space. Raises ====== TypeError : When instantiating with anything but a Point or sequence ValueError : when instantiating with a sequence with length < 2 or when trying to reduce dimensions if keyword `on_morph='error'` is set. See Also ======== sympy.geometry.line.Segment : Connects two Points Examples ======== >>> from sympy import Point >>> from sympy.abc import x >>> Point(1, 2, 3) Point3D(1, 2, 3) >>> Point([1, 2]) Point2D(1, 2) >>> Point(0, x) Point2D(0, x) >>> Point(dim=4) Point(0, 0, 0, 0) Floats are automatically converted to Rational unless the evaluate flag is False: >>> Point(0.5, 0.25) Point2D(1/2, 1/4) >>> Point(0.5, 0.25, evaluate=False) Point2D(0.5, 0.25) Tc |jdtj}|jdd}t|dk(r|dn|}t |t r+d}t||jdt|k(r|St |s,ttdjt|t|dk(r5|jddr#tjf|jdz}t|}|jdt|}t|d krttd t||k7rcd j|t||}|dk(rnA|d k(r t||d k(rtj |d nttdt#||dr tdt#d|Dr tdt%d|Ds td|d|tjf|t|z zz}|rG|j'|j)t*Dcic]}|t-t/|dc}}t|d k(rd|d<t1|i|St|dk(rd|d<t3|i|St5j6|g|Scc}w)Nevaluateon_morphignorerrFdimz< Expecting sequence of coordinates, not `{}`z[ Point requires 2 or more coordinates or keyword `dim` > 1.z2Dimension of {} needs to be changed from {} to {}.errorwarn) stacklevelzf on_morph value should be 'error', 'warn' or 'ignore'.z&Nonzero coordinates cannot be removed.c3fK|])}|jxrt|jdu+yw)FN) is_numberris_zero.0as Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/geometry/point.py z Point.__new__..s)F!q{{5r!u}}55Fs/1z(Imaginary coordinates are not permitted.c3<K|]}t|tywN) isinstancerr)s r,r-z Point.__new__..s71:a&7sz,Coordinates must be valid SymPy expressions.T)rational_nocheck)getr rlenr0rr TypeErrorrformatrrZeror ValueErrorwarningsr$anyallxreplaceatomsrr r Point2DPoint3Dr__new__) clsargskwargsrrcoordsr!messagefs r,rAz Point.__new__ms::j*;*D*DE::j(3 INa fe $H6{fjjF << 6"J(?(.y/@(ACD D v;!  5$ 7ffYvzz%00FjjF , v;?Z)&'( ( v;# ()/F S)I 8#W$ ))V# g!4 -/"011 vcd| EF F FvF FGH H777JK K 3V+< == __ ,,u-&/8Ia$788&/0F v;! !%F: F-f- - [A !%F: F-f- -%%c3F33&/sKc^tdgt|z}tj||S)z7Returns the distance between this point and the origin.r)rr5distance)selforigins r,__abs__z Point.__abs__s's3t9}%~~fd++c tj|t|d\}}t ||Dcgc]\}}t ||z}}}t|dS#t$rtdj |wxYwcc}}w)a8Add other to self by incrementing self's coordinates by those of other. Notes ===== >>> from sympy import Point When sequences of coordinates are passed to Point methods, they are converted to a Point internally. This __add__ method does not do that so if floating point values are used, a floating point result (in terms of SymPy Floats) will be returned. >>> Point(1, 2) + (.1, .2) Point2D(1.1, 2.2) If this is not desired, the `translate` method can be used or another Point can be added: >>> Point(1, 2).translate(.1, .2) Point2D(11/10, 11/5) >>> Point(1, 2) + Point(.1, .2) Point2D(11/10, 11/5) See Also ======== sympy.geometry.point.Point.translate Frz+Don't know how to add {} and a Point object)r_normalize_dimensionr6r r7zipr )rJothersor+brEs r,__add__z Point.__add__s> ]--dE%%4PQDAq/2!Qi8da(1q5/88Ve,,  ] M T TUZ [\ \ ]9s$AB$Bc||jvSr/rCrJitems r, __contains__zPoint.__contains__styy  rMct|}|jDcgc]}t||z }}t|dScc}w)z'Divide point's coordinates by a factor.FrOrrCr r)rJdivisorxrEs r, __truediv__zPoint.__truediv__s>'"/3yy9!(1W9%99Ve,,:>ct|tr+t|jt|jk7ry|j|jk(S)NF)r0rr5rCrJrRs r,__eq__z Point.__eq__s9%'3tyy>S_+LyyEJJ&&rMc |j|Sr/rX)rJkeys r, __getitem__zPoint.__getitem__syy~rMc,t|jSr/)hashrCrJs r,__hash__zPoint.__hash__sDIIrMc6|jjSr/)rC__iter__rjs r,rmzPoint.__iter__syy!!##rMc,t|jSr/)r5rCrjs r,__len__z Point.__len__s499~rMct|}|jDcgc]}t||z}}t|dScc}w)alMultiply point's coordinates by a factor. Notes ===== >>> from sympy import Point When multiplying a Point by a floating point number, the coordinates of the Point will be changed to Floats: >>> Point(1, 2)*0.1 Point2D(0.1, 0.2) If this is not desired, the `scale` method can be used or else only multiply or divide by integers: >>> Point(1, 2).scale(1.1, 1.1) Point2D(11/10, 11/5) >>> Point(1, 2)*11/10 Point2D(11/10, 11/5) See Also ======== sympy.geometry.point.Point.scale FrOr])rJfactorr_rEs r,__mul__z Point.__mul__s?6.2ii8(1V8$88Ve,,9rac$|j|S)z)Multiply a factor by point's coordinates.)rr)rJrqs r,__rmul__zPoint.__rmul__s||F##rMcZ|jDcgc]}| }}t|dScc}w)zNegate the point.FrO)rCr)rJr_rEs r,__neg__z Point.__neg__s-"ii(1"((Ve,,)s (c4||Dcgc]}| c}zScc}w)zPSubtract two points, or subtract a factor from this point's coordinates.)rJrRr_s r,__sub__z Point.__sub__#s5)ar))))s ct|dd|jdtd|Dtfd|Dr t |S|d<|jdd|d<|Dcgc]}t |fi|c}Scc}w)z~Ensure that points have the same dimension. By default `on_morph='warn'` is passed to the `Point` constructor._ambient_dimensionNr!c34K|]}|jywr/ambient_dimensionr*is r,r-z-Point._normalize_dimension..3s:aa)):sc3<K|]}|jk(ywr/r})r*rr!s r,r-z-Point._normalize_dimension..4s:aq""c):srr$)getattrr4maxr<listr)rBpointsrDrr!s @r,rPzPoint._normalize_dimension(s c/6jj$ ;:6::C :6: :< u #ZZ F;z,23qa"6"333s2Bc0t|dk(rytj|Dcgc] }t|c}}|d}|ddDcgc]}||z  }}t|Dcgc]}|jc}}|j dScc}wcc}wcc}w)agThe affine rank of a set of points is the dimension of the smallest affine space containing all the points. For example, if the points lie on a line (and are not all the same) their affine rank is 1. If the points lie on a plane but not a line, their affine rank is 2. By convention, the empty set has affine rank -1.rrNcl|jrt|jddkS|jS)Nr"g-q=)r'absnr()r_s r,z#Point.affine_rank..Ms-#$;;CAK% 45IIrM) iszerofunc)r5rrPrrCrank)rCrrrKms r, affine_rankzPoint.affine_rank:s t9>++-E1eAh-EF&,QRj1!f*11 F+qAFF+ ,vv$>v? ? .F1+sB  BBc.t|dt|S)z$Number of components this point has.r{)rr5rjs r,r~zPoint.ambient_dimensionPst13t9==rMct|dkry|j|Dcgc] }t|c}}|djdk(ryt t |}tj |dkScc}w)aReturn True if there exists a plane in which all the points lie. A trivial True value is returned if `len(points) < 3` or all Points are 2-dimensional. Parameters ========== A set of points Raises ====== ValueError : if less than 3 unique points are given Returns ======= boolean Examples ======== >>> from sympy import Point3D >>> p1 = Point3D(1, 2, 2) >>> p2 = Point3D(2, 7, 2) >>> p3 = Point3D(0, 0, 2) >>> p4 = Point3D(1, 1, 2) >>> Point3D.are_coplanar(p1, p2, p3, p4) True >>> p5 = Point3D(0, 1, 3) >>> Point3D.are_coplanar(p1, p2, p3, p5) False rTrr")r5rPrr~rrr)rBrrs r, are_coplanarzPoint.are_coplanarUstH v;! )))f+EE!H+EF !9 & &! +d6l#  &)Q.. ,FsA2c t|ts t||j}t|trDtj |t|\}}ttdt||DSt|dd}|t dt |z||S#t$rt dt |zwxYw)azThe Euclidean distance between self and another GeometricEntity. Returns ======= distance : number or symbolic expression. Raises ====== TypeError : if other is not recognized as a GeometricEntity or is a GeometricEntity for which distance is not defined. See Also ======== sympy.geometry.line.Segment.length sympy.geometry.point.Point.taxicab_distance Examples ======== >>> from sympy import Point, Line >>> p1, p2 = Point(1, 1), Point(4, 5) >>> l = Line((3, 1), (2, 2)) >>> p1.distance(p2) 5 >>> p1.distance(l) sqrt(2) The computed distance may be symbolic, too: >>> from sympy.abc import x, y >>> p3 = Point(x, y) >>> p3.distance((0, 0)) sqrt(x**2 + y**2) r!z'not recognized as a GeometricEntity: %sc32K|]\}}||z dzywr"Nrxr*r+rUs r,r-z!Point.distance..s?TQq1uqj?srINz,distance between Point and %s is not defined) r0rrr~r6typerPr rrQr)rJrRrSprIs r,rIzPoint.distancesN%0 Ye)?)?@ eU #--dE%LADAq?SAY?@A A5*d3  JTRW[XY Y~ Y IDQVK WXX Ys B++!C c`t|s t|}tdt||DS)z.Return dot product of self with another Point.c3,K|] \}}||zywr/rxrs r,r-zPoint.dot..s2TQQqS2s)rrrrQ)rJrs r,dotz Point.dots)1~aA2Sq\233rMct|trt|t|k7rytdt ||DS)z8Returns whether the coordinates of self and other agree.Fc3DK|]\}}|j|ywr/)equalsrs r,r-zPoint.equals..s<41a188A;>> from sympy import Point, Rational >>> p1 = Point(Rational(1, 2), Rational(3, 2)) >>> p1 Point2D(1/2, 3/2) >>> p1.evalf() Point2D(0.5, 1.5) rrFrx)rrCevalfr)rJprecoptionsdpsr_rEs r, _eval_evalfzPoint._eval_evalfsN8$59YY?'!''+C+7+??f-u--@sAct|ts t|}t|tr0||k(r|gStj||\}}||k(r||k(r|gSgS|j |S)a|The intersection between this point and another GeometryEntity. Parameters ========== other : GeometryEntity or sequence of coordinates Returns ======= intersection : list of Points Notes ===== The return value will either be an empty list if there is no intersection, otherwise it will contain this point. Examples ======== >>> from sympy import Point >>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(0, 0) >>> p1.intersection(p2) [] >>> p1.intersection(p3) [Point2D(0, 0)] )r0rrrP intersection)rJrRp1p2s r,rzPoint.intersectionso<%0%LE eU #u}v //e>> from sympy import Point >>> from sympy.abc import x >>> p1, p2 = Point(0, 0), Point(1, 1) >>> p3, p4, p5 = Point(2, 2), Point(x, x), Point(1, 2) >>> Point.is_collinear(p1, p2, p3, p4) True >>> Point.is_collinear(p1, p2, p3, p5) False r)rrPrrr)rJrCrrs r, is_collinearzPoint.is_collinear sYB4++-G1eAh-GHd6l#  &)Q...HsAc |f|z}tj|Dcgc] }t|c}}tt|}tj|dksy|d}|Dcgc]}||z  }}t |Dcgc] }t||j |gz"c}}|j\}}t||vryycc}wcc}wcc}w)aDo `self` and the given sequence of points lie in a circle? Returns True if the set of points are concyclic and False otherwise. A trivial value of True is returned if there are fewer than 2 other points. Parameters ========== args : sequence of Points Returns ======= is_concyclic : boolean Examples ======== >>> from sympy import Point Define 4 points that are on the unit circle: >>> p1, p2, p3, p4 = Point(1, 0), (0, 1), (-1, 0), (0, -1) >>> p1.is_concyclic() == p1.is_concyclic(p2, p3, p4) == True True Define a point not on that circle: >>> p = Point(1, 1) >>> p.is_concyclic(p1, p2, p3) False r"FrT) rrPrrrrrrrefr5) rJrCrrrKrmatrpivotss r, is_concycliczPoint.is_concyclic3sL4++-G1eAh-GHd6l#  &)Q.&,-!f*-- F;qd1gq *;<xxz f v;f $.H . .s*QqDy*sNT)rCrr;)rJr_nonzeros r,r(z Point.is_zerosB*.3A1<<33 w< *'* * 4sAc"tjS)z Treating a Point as a Line, this returns 0 for the length of a Point. Examples ======== >>> from sympy import Point >>> p = Point(0, 1) >>> p.length 0 )rr8rjs r,lengthz Point.lengths vv rMc tj|t|\}}tt||Dcgc]$\}}t||ztj z&c}}Scc}}w)aThe midpoint between self and point p. Parameters ========== p : Point Returns ======= midpoint : Point See Also ======== sympy.geometry.line.Segment.midpoint Examples ======== >>> from sympy import Point >>> p1, p2 = Point(1, 1), Point(13, 5) >>> p1.midpoint(p2) Point2D(7, 3) )rrPrQr rHalf)rJrrSr+rUs r,midpointzPoint.midpointsR6))$a913q!9E41ahAqvv~.EFFEs)A( c6tdgt|zdS)zOA point of all zeros of the same ambient dimension as the current pointrFrO)rr5rjs r,rKz Point.originsaST]U33rMc|j}|djrtdg|dz dgzzS|djrtddg|dz dgzzSt|d |dg|dz dgzzS)auReturns a non-zero point that is orthogonal to the line containing `self` and the origin. Examples ======== >>> from sympy import Line, Point >>> a = Point(1, 2, 3) >>> a.orthogonal_direction Point3D(-2, 1, 0) >>> b = _ >>> Line(b, b.origin).is_perpendicular(Line(a, a.origin)) True rrr")r~r(r)rJr!s r,orthogonal_directionzPoint.orthogonal_directions $$ 7??!a!},- - 7??!A#'A3./ /tAwhQ(C!GaS=899rMctjt|t|\}}|jr td||j ||j |z zS)aProject the point `a` onto the line between the origin and point `b` along the normal direction. Parameters ========== a : Point b : Point Returns ======= p : Point See Also ======== sympy.geometry.line.LinearEntity.projection Examples ======== >>> from sympy import Line, Point >>> a = Point(1, 2) >>> b = Point(2, 5) >>> z = a.origin >>> p = Point.project(a, b) >>> Line(p, a).is_perpendicular(Line(p, b)) True >>> Point.is_collinear(z, p, b) True "Cannot project to the zero vector.)rrPr(r9r)r+rUs r,projectz Point.projectsVD))%(E!H=1 99AB B!%%(QUU1X%&&rMcxtj|t|\}}tdt||DS)a2The Taxicab Distance from self to point p. Returns the sum of the horizontal and vertical distances to point p. Parameters ========== p : Point Returns ======= taxicab_distance : The sum of the horizontal and vertical distances to point p. See Also ======== sympy.geometry.point.Point.distance Examples ======== >>> from sympy import Point >>> p1, p2 = Point(1, 1), Point(4, 5) >>> p1.taxicab_distance(p2) 7 c3>K|]\}}t||z ywr/rrs r,r-z)Point.taxicab_distance..%s6DAqSQZ6s)rrPrrQrJrrSs r,taxicab_distancezPoint.taxicab_distances5<))$a916C1I677rMctj|t|\}}|jr|jr tdt dt ||DS)a=The Canberra Distance from self to point p. Returns the weighted sum of horizontal and vertical distances to point p. Parameters ========== p : Point Returns ======= canberra_distance : The weighted sum of horizontal and vertical distances to point p. The weight used is the sum of absolute values of the coordinates. Examples ======== >>> from sympy import Point >>> p1, p2 = Point(1, 1), Point(3, 3) >>> p1.canberra_distance(p2) 1 >>> p1, p2 = Point(0, 0), Point(3, 3) >>> p1.canberra_distance(p2) 2 Raises ====== ValueError when both vectors are zero. See Also ======== sympy.geometry.point.Point.distance rc3nK|]-\}}t||z t|t|zz /ywr/rrs r,r-z*Point.canberra_distance..Ss-J1c!a%j#a&3q6/2Js35)rrPr(r9rrQrs r,canberra_distancezPoint.canberra_distance'sOR))$a91 <@HF4P, %-N!- ' $->$- * 44"??*>>+/+/Z2h4 =.@'(R$/L6p&  G<44 ::2$'$'L8B,L\  rMrceZdZdZdZdddZdZedZdd Z dd Z d Z dd Z ed Z edZedZy)r?aA point in a 2-dimensional Euclidean space. Parameters ========== coords A sequence of 2 coordinate values. Attributes ========== x y length Raises ====== TypeError When trying to add or subtract points with different dimensions. When trying to create a point with more than two dimensions. When `intersection` is called with object other than a Point. See Also ======== sympy.geometry.line.Segment : Connects two Points Examples ======== >>> from sympy import Point2D >>> from sympy.abc import x >>> Point2D(1, 2) Point2D(1, 2) >>> Point2D([1, 2]) Point2D(1, 2) >>> Point2D(0, x) Point2D(0, x) Floats are automatically converted to Rational unless the evaluate flag is False: >>> Point2D(0.5, 0.25) Point2D(1/2, 1/4) >>> Point2D(0.5, 0.25, evaluate=False) Point2D(0.5, 0.25) r"Fr2cR|sd|d<t|i|}tj|g|S)Nr"r!rrrArBr2rCrDs r,rAzPoint2D.__new__3F5M$)&)D%%c1D11rMc ||k(Sr/rxrYs r,r[zPoint2D.__contains__ t|rMc^|j|j|j|jfS)zwReturn a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure. )r_yrjs r,boundszPoint2D.boundss#//rMNct|}t|}|}|t|d}||z}|j\}}t||z||zz ||z||zz}|||z }|S)a[Rotate ``angle`` radians counterclockwise about Point ``pt``. See Also ======== translate, scale Examples ======== >>> from sympy import Point2D, pi >>> t = Point2D(1, 0) >>> t.rotate(pi/2) Point2D(0, 1) >>> t.rotate(pi/2, (2, 0)) Point2D(2, -1) r"r)rrrrC)rJangleptcrSrr_rs r,rotatezPoint2D.rotatesy& J J  >rq!B "HBww1 1Q319acAaCi ( > "HB rMc|rNt|d}|j| jj||j|jSt|j|z|j |zS)aScale the coordinates of the Point by multiplying by ``x`` and ``y`` after subtracting ``pt`` -- default is (0, 0) -- and then adding ``pt`` back again (i.e. ``pt`` is the point of reference for the scaling). See Also ======== rotate, translate Examples ======== >>> from sympy import Point2D >>> t = Point2D(1, 1) >>> t.scale(2) Point2D(2, 1) >>> t.scale(2, 2) Point2D(2, 2) r"r)r translaterCscaler_r)rJr_rrs r,rz Point2D.scalese, rq!BD>4>>RC::.44Q:DDbggN NTVVAXtvvax((rMc |jr|jdk(s td|j\}}t t dd||dg|zj dddS)aReturn the point after applying the transformation described by the 3x3 Matrix, ``matrix``. See Also ======== sympy.geometry.point.Point2D.rotate sympy.geometry.point.Point2D.scale sympy.geometry.point.Point2D.translate )r3r3zmatrix must be a 3x3 matrixrr3rNr") is_Matrixshaper9rCrrtolist)rJmatrixr_rs r, transformzPoint2D.transformse  V\\V%;:; ;yy1vaQ1I.v5==?B2AFGGrMcNt|j|z|j|zS)aShift the Point by adding x and y to the coordinates of the Point. See Also ======== sympy.geometry.point.Point2D.rotate, scale Examples ======== >>> from sympy import Point2D >>> t = Point2D(0, 1) >>> t.translate(2) Point2D(2, 1) >>> t.translate(2, 2) Point2D(2, 3) >>> t + Point2D(2, 2) Point2D(2, 3) )rr_r)rJr_rs r,rzPoint2D.translates!*TVVaZ!,,rMc|jS)z Returns the two coordinates of the Point. Examples ======== >>> from sympy import Point2D >>> p = Point2D(0, 1) >>> p.coordinates (0, 1) rXrjs r, coordinateszPoint2D.coordinatesyyrMc |jdS)z Returns the X coordinate of the Point. Examples ======== >>> from sympy import Point2D >>> p = Point2D(0, 1) >>> p.x 0 rrXrjs r,r_z Point2D.xyy|rMc |jdS)z Returns the Y coordinate of the Point. Examples ======== >>> from sympy import Point2D >>> p = Point2D(0, 1) >>> p.y 1 rrXrjs r,rz Point2D.y"rrMr/)rrN)rr)rrrrr{rAr[rrrrrrrr_rrxrMr,r?r?\s0d%*2 00@)6 H-.      rMr?ceZdZdZdZdddZdZedZdZ d Z d Z dd Z d Z ddZedZedZedZedZy )r@a>A point in a 3-dimensional Euclidean space. Parameters ========== coords A sequence of 3 coordinate values. Attributes ========== x y z length Raises ====== TypeError When trying to add or subtract points with different dimensions. When `intersection` is called with object other than a Point. Examples ======== >>> from sympy import Point3D >>> from sympy.abc import x >>> Point3D(1, 2, 3) Point3D(1, 2, 3) >>> Point3D([1, 2, 3]) Point3D(1, 2, 3) >>> Point3D(0, x, 3) Point3D(0, x, 3) Floats are automatically converted to Rational unless the evaluate flag is False: >>> Point3D(0.5, 0.25, 2) Point3D(1/2, 1/4, 2) >>> Point3D(0.5, 0.25, 3, evaluate=False) Point3D(0.5, 0.25, 3) r3FrcR|sd|d<t|i|}tj|g|S)Nr3r!rrs r,rAzPoint3D.__new__arrMc ||k(Sr/rxrYs r,r[zPoint3D.__contains__grrMc&tj|S)aIs a sequence of points collinear? Test whether or not a set of points are collinear. Returns True if the set of points are collinear, or False otherwise. Parameters ========== points : sequence of Point Returns ======= are_collinear : boolean See Also ======== sympy.geometry.line.Line3D Examples ======== >>> from sympy import Point3D >>> from sympy.abc import x >>> p1, p2 = Point3D(0, 0, 0), Point3D(1, 1, 1) >>> p3, p4, p5 = Point3D(2, 2, 2), Point3D(x, x, x), Point3D(1, 2, 6) >>> Point3D.are_collinear(p1, p2, p3, p4) True >>> Point3D.are_collinear(p1, p2, p3, p5) False )rr)rs r, are_collinearzPoint3D.are_collinearjsD!!6**rMc|j|}ttd|D}|j|jz |z |j|jz |z |j |j z |z gS)ap Gives the direction cosine between 2 points Parameters ========== p : Point3D Returns ======= list Examples ======== >>> from sympy import Point3D >>> p1 = Point3D(1, 2, 3) >>> p1.direction_cosine(Point3D(2, 3, 5)) [sqrt(6)/6, sqrt(6)/6, sqrt(6)/3] c3&K|] }|dz ywrrxrs r,r-z+Point3D.direction_cosine..s'q!t's)direction_ratior rr_rz)rJpointr+rUs r,direction_cosinezPoint3D.direction_cosinesq,   ' 'Q'( )466!Q&$&&(8A'=466!Q&( (rMc|j|jz |j|jz |j|jz gS)aV Gives the direction ratio between 2 points Parameters ========== p : Point3D Returns ======= list Examples ======== >>> from sympy import Point3D >>> p1 = Point3D(1, 2, 3) >>> p1.direction_ratio(Point3D(2, 3, 5)) [1, 1, 2] )r_rr)rJrs r,rzPoint3D.direction_ratios8,466!EGGdff$4uww7GIIrMct|ts t|d}t|tr ||k(r|gSgS|j |S)aThe intersection between this point and another GeometryEntity. Parameters ========== other : GeometryEntity or sequence of coordinates Returns ======= intersection : list of Points Notes ===== The return value will either be an empty list if there is no intersection, otherwise it will contain this point. Examples ======== >>> from sympy import Point3D >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(0, 0, 0) >>> p1.intersection(p2) [] >>> p1.intersection(p3) [Point3D(0, 0, 0)] r3r)r0rrr@rrcs r,rzPoint3D.intersectionsH<%0%Q'E eW %u}v I!!$''rMNc|rMt|}|j| jj|||j|jSt|j|z|j |z|j |zS)aScale the coordinates of the Point by multiplying by ``x`` and ``y`` after subtracting ``pt`` -- default is (0, 0) -- and then adding ``pt`` back again (i.e. ``pt`` is the point of reference for the scaling). See Also ======== translate Examples ======== >>> from sympy import Point3D >>> t = Point3D(1, 1, 1) >>> t.scale(2) Point3D(2, 1, 1) >>> t.scale(2, 2) Point3D(2, 2, 1) )r@rrCrr_rr)rJr_rrrs r,rz Point3D.scalesn, BG>4>>RC::.44Q1=GGQ Qtvvax466!844rMc |jr|jdk(s td|j\}}}t |}t t dd|||dg|zjdddS)zReturn the point after applying the transformation described by the 4x4 Matrix, ``matrix``. See Also ======== sympy.geometry.point.Point3D.scale sympy.geometry.point.Point3D.translate )r zmatrix must be a 4x4 matrixrr rNr3)rrr9rCrr@rr)rJrr_rrrs r,rzPoint3D.transformss  V\\V%;:; ;))1a f 1q!Ql3A5==?B2AFGGrMcjt|j|z|j|z|j|zS)aShift the Point by adding x and y to the coordinates of the Point. See Also ======== scale Examples ======== >>> from sympy import Point3D >>> t = Point3D(0, 1, 1) >>> t.translate(2) Point3D(2, 1, 1) >>> t.translate(2, 2) Point3D(2, 3, 1) >>> t + Point3D(2, 2, 2) Point3D(2, 3, 3) )r@r_rr)rJr_rrs r,rzPoint3D.translates+*tvvz466A:tvvz::rMc|jS)z Returns the three coordinates of the Point. Examples ======== >>> from sympy import Point3D >>> p = Point3D(0, 1, 2) >>> p.coordinates (0, 1, 2) rXrjs r,rzPoint3D.coordinates(rrMc |jdS)z Returns the X coordinate of the Point. Examples ======== >>> from sympy import Point3D >>> p = Point3D(0, 1, 3) >>> p.x 0 rrXrjs r,r_z Point3D.x7rrMc |jdS)z Returns the Y coordinate of the Point. Examples ======== >>> from sympy import Point3D >>> p = Point3D(0, 1, 2) >>> p.y 1 rrXrjs r,rz Point3D.yFrrMc |jdS)z Returns the Z coordinate of the Point. Examples ======== >>> from sympy import Point3D >>> p = Point3D(0, 1, 1) >>> p.z 1 r"rXrjs r,rz Point3D.zUrrM)rrrN)rrr)rrrrr{rAr[rrrrrrrrrrr_rrrxrMr,r@r@1s+Z%*2 !+!+F(6J0$(L56 H;.        rMr@),rr: sympy.corerrrsympy.core.addrsympy.core.containersrsympy.core.numbersrsympy.core.parametersr sympy.simplify.simplifyr r sympy.geometry.exceptionsr (sympy.functions.elementary.miscellaneousr $sympy.functions.elementary.complexesr(sympy.functions.elementary.trigonometricrrsympy.matricesrsympy.matrices.expressionsrsympy.utilities.iterablesrrsympy.utilities.miscrrrentityrmpmath.libmp.libmpfrrr?r@rxrMr,r sq&'''$37393=!07CC"+o  No  dSeSjqeqrM