� ��g,���B�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(Gd�de&��Z)Gd�de)��Z*Gd�de)��Z+dS)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)�S�sympify�Expr)�Add)�Tuple)�Float)�global_parameters)� nsimplify�simplify)� GeometryError)�sqrt)�im)�cos�sin)�Matrix)� Transpose)�uniq� is_sequence)� filldedent� func_name� Undecidable�)�GeometryEntity)� prec_to_dpsc��eZdZdZdZd�Zd�Zd�Zd�Zd�Z d�Z d �Z d �Z d �Z d �Zd �Zd�Zd�Zd�Zed���Zed���Zed���Zed���Zd�Zd�Zd�Zd)d�Zd�Zd�Zd�Z ed���Z!d�Z"ed���Z#ed ���Z$d!�Z%ed"���Z&ed#���Z'ed$���Z(d%�Z)d&�Z*ed'���Z+d(S)*�Pointa�A 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 ��|�dtj��}|�dd��}t|��dkr|dn|}t |t ��r8d}t|��|�dt|����kr|St |��s<ttd� t|���������t|��dkr9|�dd��r#tj f|�d��z}t|�}|�dt|����}t|��d krttd �����t|��|kryd � |t|��|��}|dkrnN|d krt|���|d krtj|d ���nttd�����t#||d���rtd���t#d�|D����rtd���t%d�|D����std���|d|�tj f|t|��z zz}|r7|�d�|�t*��D����}t|��d krd|d<t-|i|��St|��dkrd|d<t/|i|��St1j|g|�R�S)N�evaluate�on_morph�ignorerrF�dimz< Expecting sequence of coordinates, not `{}`�z[ Point requires 2 or more coordinates or keyword `dim` > 1.z2Dimension of {} needs to be changed from {} to {}.�error�warn)� stacklevelzf on_morph value should be 'error', 'warn' or 'ignore'.z&Nonzero coordinates cannot be removed.c3�PK�|]!}|jot|��jduV��"dS)FN)� is_numberr�is_zero��.0�as �d/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/geometry/point.py� <genexpr>z Point.__new__.<locals>.<genexpr>�s6����F�F�!�q�{�5�r�!�u�u�}��5�F�F�F�F�F�F�z(Imaginary coordinates are not permitted.c3�@K�|]}t|t��V��dS�N)� isinstancerr)s r,r-z Point.__new__.<locals>.<genexpr>�s,����7�7�1�:�a��&�&�7�7�7�7�7�7r.z,Coordinates must be valid SymPy expressions.c �L�i|]!}|tt|d�������"S)T)�rational)r r )r*�fs r,� <dictcomp>z!Point.__new__.<locals>.<dictcomp>�s?��&/�&/�&/���8�I�a�$�7�7�7�8�8�&/�&/�&/r.T�_nocheck�)�getr r�lenr1rr� TypeErrorr�formatrr�Zeror� ValueError�warningsr$�any�all�xreplace�atomsr�Point2D�Point3Dr�__new__)�cls�args�kwargsrr�coordsr!�messages r,rEz Point.__new__ms���:�:�j�*;�*D�E�E���:�:�j�(�3�3�� ��I�I��N�N��a����� �f�e� $� $� ��H��6�{�{�f�j�j���F� � �<�<�<�<�� ��6�"�"� D��J�(?�(.��y��/@�/@�(A�(A�C�C�D�D� D� �v�;�;�!� � �� � �5�$� 7� 7� ��f�Y�v�z�z�%�0�0�0�F������j�j���F� � �,�,�� �v�;�;��?�?��Z�)&�'�'�(�(� (� �v�;�;�#� � �(�)/����F� � �S�)I�)I� ��8�#�#���W�$�$� ��)�)�)��V�#�#�� �g�!�4�4�4�4�4� ��-/�"0�"0�1�1�1� �v�c�d�d�|� � � G��E�F�F� F� �F�F�v�F�F�F� F� F� I��G�H�H� H��7�7��7�7�7�7�7� L��J�K�K� K�������� �3��V���+<� =�=�� � 0��_�_�&/�&/� �,�,�u�-�-�&/�&/�&/�0�0�F� �v�;�;�!� � �!%�F�:� ��F�-�f�-�-� -� ��[�[�A� � �!%�F�:� ��F�-�f�-�-� -��%�c�3�F�3�3�3�3r.c�x�tdgt|��z��}t�||��S)z7Returns the distance between this point and the origin.r)rr9�distance)�self�origins r,�__abs__z Point.__abs__�s/����s�3�t�9�9�}�%�%���~�~�f�d�+�+�+r.c�� t�|t|d�����\}}n0#t$r#td�|�����wxYwd�t ||��D��}t|d���S)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 F�rz+Don't know how to add {} and a Point objectc�8�g|]\}}t||z����S��r �r*r+�bs r,� <listcomp>z!Point.__add__.<locals>.<listcomp>�s&��8�8�8�d�a��(�1�q�5�/�/�8�8�8r.)r�_normalize_dimensionr:r r;�zip)rM�other�s�orIs r,�__add__z Point.__add__�s���> ]��-�-�d�E�%�%�4P�4P�4P�Q�Q�D�A�q�q��� ]� ]� ]�� M� T� T�UZ� [� [�\�\� \� ]����9�8�c�!�Q�i�i�8�8�8���V�e�,�,�,�,s �-0�-Ac��||jvSr0�rG�rM�items r,� __contains__zPoint.__contains__�s���t�y� � r.c�j��t�����fd�|jD��}t|d���S)z'Divide point's coordinates by a factor.c�4��g|]}t|�z ����SrSrT)r*�x�divisors �r,rWz%Point.__truediv__.<locals>.<listcomp>�s%���9�9�9�!�(�1�W�9�%�%�9�9�9r.FrQ�rrGr)rMrfrIs ` r,� __truediv__zPoint.__truediv__�s>����'�"�"��9�9�9�9�t�y�9�9�9���V�e�,�,�,�,r.c��t|t��r*t|j��t|j��krdS|j|jkS)NF)r1rr9rG�rMrZs r,�__eq__z Point.__eq__�sB���%��'�'� �3�t�y�>�>�S���_�_�+L�+L��5��y�E�J�&�&r.c��|j|Sr0r_)rM�keys r,� __getitem__zPoint.__getitem__�s���y��~�r.c�*�t|j��Sr0)�hashrG�rMs r,�__hash__zPoint.__hash__�s���D�I���r.c�4�|j���Sr0)rG�__iter__rqs r,rtzPoint.__iter__�s���y�!�!�#�#�#r.c�*�t|j��Sr0)r9rGrqs r,�__len__z Point.__len__�s���4�9�~�~�r.c�j��t�����fd�|jD��}t|d���S)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 c�4��g|]}t|�z����SrSrT)r*re�factors �r,rWz!Point.__mul__.<locals>.<listcomp>s%���8�8�8��(�1�V�8�$�$�8�8�8r.FrQrg)rMryrIs ` r,�__mul__z Point.__mul__�s>���6�����8�8�8�8�d�i�8�8�8���V�e�,�,�,�,r.c�,�|�|��S)z)Multiply a factor by point's coordinates.)rz)rMrys r,�__rmul__zPoint.__rmul__s���|�|�F�#�#�#r.c�F�d�|jD��}t|d���S)zNegate the point.c��g|]}| ��SrSrS�r*res r,rWz!Point.__neg__.<locals>.<listcomp> s��(�(�(��1�"�(�(�(r.FrQ)rGr)rMrIs r,�__neg__z Point.__neg__s*��(�(�d�i�(�(�(���V�e�,�,�,�,r.c� �|d�|D��zS)zPSubtract two points, or subtract a factor from this point's coordinates.c��g|]}| ��SrSrSrs r,rWz!Point.__sub__.<locals>.<listcomp>&s��)�)�)�a��r�)�)�)r.rSrjs r,�__sub__z Point.__sub__#s���)�)�5�)�)�)�)�)r.c�6���t|dd�����d������td�|D�����t�fd�|D����rt |��S��d<��dd���d<�fd�|D��S) z~Ensure that points have the same dimension. By default `on_morph='warn'` is passed to the `Point` constructor.�_ambient_dimensionNr!c3�$K�|] }|jV�� dSr0��ambient_dimension�r*�is r,r-z-Point._normalize_dimension.<locals>.<genexpr>3s%����:�:�a�a�)�:�:�:�:�:�:r.c3�.�K�|]}|j�kV��dSr0r�)r*r�r!s �r,r-z-Point._normalize_dimension.<locals>.<genexpr>4s+�����:�:�a�q�"�c�)�:�:�:�:�:�:r.rr$c�*��g|]}t|fi�����SrS�r)r*r�rHs �r,rWz.Point._normalize_dimension.<locals>.<listcomp>8s)���3�3�3�q��a�"�"�6�"�"�3�3�3r.)�getattrr8�maxr@�list)rF�pointsrHr!s `@r,rXzPoint._normalize_dimension(s����� �c�/��6�6���j�j���$�$�� �;��:�:�6�:�:�:�:�:�C� �:�:�:�:�6�:�:�:� :� :� ���<�<� ���u� �#�Z�Z� �F�;�;��z��3�3�3�3�F�3�3�3�3r.c����t|��dkrdStjd�|D���}|d��fd�|dd�D��}td�|D����}|�d�� ��S) 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.r�����c�,�g|]}t|����SrSr�r�s r,rWz%Point.affine_rank.<locals>.<listcomp>Gs��-E�-E�-E�1�e�A�h�h�-E�-E�-Er.c���g|]}|�z ��SrSrS)r*r�rNs �r,rWz%Point.affine_rank.<locals>.<listcomp>Is���1�1�1��!�f�*�1�1�1r.rNc��g|] }|j�� SrSr_r�s r,rWz%Point.affine_rank.<locals>.<listcomp>Ks��+�+�+�q�A�F�+�+�+r.c�j�|jr&t|�d����dkn|jS)Nr"g�-���q=)r'�abs�nr()res r,�<lambda>z#Point.affine_rank.<locals>.<lambda>Ms-��#$�;� =�C����A���K�K�%� � �A�I�r.)� iszerofunc)r9rrXr�rank)rGr��mrNs @r,� affine_rankzPoint.affine_rank:s���� �t�9�9��>�>��2��+�-E�-E��-E�-E�-E�F������1�1�1�1�f�Q�R�R�j�1�1�1�� �+�+�F�+�+�+� ,� ,���v�v�$>�$>�v�?�?� ?r.c�>�t|dt|����S)z$Number of components this point has.r�)r�r9rqs r,r�zPoint.ambient_dimensionPs���t�1�3�t�9�9�=�=�=r.c���t|��dkrdS|jd�|D���}|djdkrdStt |����}t j|�dkS)a�Return 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 rTc�,�g|]}t|����SrSr�r�s r,rWz&Point.are_coplanar.<locals>.<listcomp>|s��+E�+E�+E��E�!�H�H�+E�+E�+Er.rr")r9rXr�r�rrr�)rFr�s r,� are_coplanarzPoint.are_coplanarUsv��H �v�;�;�!� � ��4�)��)�+E�+E�f�+E�+E�+E�F�� �!�9� &�!� +� +��4��d�6�l�l�#�#��� �&�)�Q�.�.r.c � �t|t��sE t||j���}n-#t$r t dt |��z���wxYwt|t��rYt�|t|����\}}ttd�t||��D�����St|dd��}|�t dt |��z���||��S)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: %sc3�,K�|]\}}||z dzV��dS�r"NrSrUs r,r-z!Point.distance.<locals>.<genexpr>�s.����?�?�T�Q��q�1�u�q�j�?�?�?�?�?�?r.rLNz,distance between Point and %s is not defined) r1rrr�r:�typerXr rrYr�)rMrZr[�prLs r,rLzPoint.distance�s ��N�%��0�0� Y� Y��e��)?�@�@�@����� Y� Y� Y�� I�D�QV�K�K� W�X�X�X� Y���� �e�U� #� #� B��-�-�d�E�%�L�L�A�A�D�A�q���?�?�S��A�Y�Y�?�?�?�@�A�A� A��5�*�d�3�3�� � ��J�T�RW�[�[�X�Y�Y� Y��x��~�~�s �.�*Ac��t|��st|��}td�t||��D���S)z.Return dot product of self with another Point.c3�&K�|] \}}||zV�� dSr0rSrUs r,r-zPoint.dot.<locals>.<genexpr>�s*����2�2�T�Q��Q�q�S�2�2�2�2�2�2r.)rrrrY)rMr�s r,�dotz Point.dot�s=���1�~�~� ��a���A��2�2�S��q�\�\�2�2�2�3�3r.c��t|t��r t|��t|��krdStd�t ||��D����S)z8Returns whether the coordinates of self and other agree.Fc3�FK�|]\}}|�|��V��dSr0)�equalsrUs r,r-zPoint.equals.<locals>.<genexpr>�s0����<�<�4�1�a�1�8�8�A�;�;�<�<�<�<�<�<r.)r1rr9r@rYrjs r,r�z Point.equals�sX���%��'�'� �3�t�9�9��E� � �+B�+B��5��<�<�3�t�U�+;�+;�<�<�<�<�<�<r.�c �d���t|�����fd�|jD��}t|ddi�S)aFEvaluate the coordinates of the point. This method will, where possible, create and return a new Point where the coordinates are evaluated as floating point numbers to the precision indicated (default=15). Parameters ========== prec : int Returns ======= point : Point Examples ======== >>> 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) c�.��g|]}|jdd�i�����S)r�rS)�evalf)r*re�dps�optionss ��r,rWz%Point._eval_evalf.<locals>.<listcomp>�s0���?�?�?��'�!�'�+�+�C�+�7�+�+�?�?�?r.rF)rrGr)rM�precr�rIr�s ` @r,� _eval_evalfzPoint._eval_evalf�sD����8�$����?�?�?�?�?�T�Y�?�?�?���f�-�u�-�-�-r.c��t|t��st|��}t|t��r8||kr|gSt�||��\}}||kr ||kr|gSgS|�|��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)] )r1rrrX� intersection)rMrZ�p1�p2s r,r�zPoint.intersection�s���<�%��0�0� !��%�L�L�E� �e�U� #� #� ��u�}�}��v� ��/�/��e�<�<�F�B���T�z�z�b�B�h�h��v� ��I��!�!�$�'�'�'r.c��|f|z}tjd�|D���}tt|����}tj|�dkS)a�Returns `True` if there exists a line that contains `self` and `points`. Returns `False` otherwise. A trivially True value is returned if no points are given. Parameters ========== args : sequence of Points Returns ======= is_collinear : boolean See Also ======== sympy.geometry.line.Line Examples ======== >>> 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 c�,�g|]}t|����SrSr�r�s r,rWz&Point.is_collinear.<locals>.<listcomp>/���-G�-G�-G�1�e�A�h�h�-G�-G�-Gr.r)rrXr�rr�)rMrGr�s r,� is_collinearzPoint.is_collinear sR��B��4����+�-G�-G��-G�-G�-G�H���d�6�l�l�#�#��� �&�)�Q�.�.r.c�V��|f|z}tjd�|D���}tt|����}tj|�dksdS|d��fd�|D��}t d�|D����}|���\}}t���|vrdSdS)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 c�,�g|]}t|����SrSr�r�s r,rWz&Point.is_concyclic.<locals>.<listcomp>Zr�r.r"Frc���g|]}|�z ��SrSrS)r*r�rNs �r,rWz&Point.is_concyclic.<locals>.<listcomp>_s���-�-�-��!�f�*�-�-�-r.c�Z�g|](}t|��|�|��gz��)SrS)r�r�r�s r,rWz&Point.is_concyclic.<locals>.<listcomp>es/��;�;�;�q�d�1�g�g����q��� �*�;�;�;r.T)rrXr�rr�r�rrefr9)rMrGr��matr��pivotsrNs @r,� is_concycliczPoint.is_concyclic3s����L��4����+�-G�-G��-G�-G�-G�H���d�6�l�l�#�#��� �&�)�Q�.�.��5�����-�-�-�-�f�-�-�-�� �;�;�F�;�;�;�<�<���x�x�z�z� ��f� �v�;�;�f� $� $��4��ur.c��|j}|�dS| S)zrTrue if any coordinate is nonzero, False if every coordinate is zero, and None if it cannot be determined.N)r()rMr(s r,� is_nonzerozPoint.is_nonzeroks���,�� �?��4��{�r.c��t�|t|����\}}|jdkrW|j|jc\}}\}}||z||zz �d��}|�"t t d|�d|�������t|j|jg��} | ���dkS)z{Returns whether each coordinate of `self` is a scalar multiple of the corresponding coordinate in point p. r"rNzCannot determine if z- is a scalar multiple of ) rrXr�rGr�rrrr�) rMr�r[r\�x1�y1�x2�y2�rvr�s r,�is_scalar_multiplezPoint.is_scalar_multiplets����)�)�$��a���9�9���1� � �!� #� #�!"���� �H�R��h�r�2��R�%�"�R�%�-�'�'��*�*�B��z�!�*�*��Q�Q���#�#$�#$�%�%�%� �A�F�A�F�#� $� $���v�v�x�x�!�|�r.c��d�|jD��}t|��rdStd�|D����rdSdS)zsTrue if every coordinate is zero, False if any coordinate is not zero, and None if it cannot be determined.c��g|] }|j�� SrS)r�rs r,rWz!Point.is_zero.<locals>.<listcomp>�s��3�3�3�A�1�<�3�3�3r.Fc3�K�|]}|duV�� dSr0rSrs r,r-z Point.is_zero.<locals>.<genexpr>�s&����*�*�Q�q�D�y�*�*�*�*�*�*r.NT)rGr?)rM�nonzeros r,r(z Point.is_zero�sU��4�3���3�3�3�� �w�<�<� ��5� �*�*�'�*�*�*� *� *� ��4��tr.c��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 )rr<rqs r,�lengthz Point.length�s ���v� r.c��t�|t|����\}}td�t||��D����S)a�The 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) c�R�g|]$\}}t||ztjz����%SrS)r r�HalfrUs r,rWz"Point.midpoint.<locals>.<listcomp>�s.��E�E�E�4�1�a�h��A��q�v�~�.�.�E�E�Er.)rrXrY�rMr�r[s r,�midpointzPoint.midpoint�sH��6�)�)�$��a���9�9���1��E�E�3�q�!�9�9�E�E�E�F�F�Fr.c�F�tdgt|��zd���S)zOA point of all zeros of the same ambient dimension as the current pointrFrQ)rr9rqs r,rNz Point.origin�s#���a�S��T���]�U�3�3�3�3r.c���|j}|djrtdg|dz dgzz��S|djrtddg|dz dgzz��St|d |dg|dz dgzz��S)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)rMr!s r,�orthogonal_directionzPoint.orthogonal_direction�s��� �$�� ��7�?� .��!���a��!��}�,�-�-� -� ��7�?� 0��!�A��#��'�A�3��.�/�/� /��t�A�w�h��Q��(�C�!�G�a�S�=�8�9�9�9r.c���t�t|��t|����\}}|jrtd���||�|��|�|��z zS)a�Project 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.)rrXr(r=r�)r+rVs r,�projectz Point.project�sh��D�)�)�%��(�(�E�!�H�H�=�=���1� �9� C��A�B�B� B��!�%�%��(�(�Q�U�U�1�X�X�%�&�&r.c��t�|t|����\}}td�t||��D���S)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 ��V��dSr0�r�rUs r,r-z)Point.taxicab_distance.<locals>.<genexpr>%s0����6�6�D�A�q�S��Q��Z�Z�6�6�6�6�6�6r.)rrXrrYr�s r,�taxicab_distancezPoint.taxicab_distancesE��<�)�)�$��a���9�9���1��6�6�C��1�I�I�6�6�6�7�7r.c���t�|t|����\}}|jr|jrtd���t d�t ||��D���S)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 r�c3�K�|]9\}}t||z ��t|��t|��zz V��:dSr0r�rUs r,r-z*Point.canberra_distance.<locals>.<genexpr>SsE����J�J���1�c�!�a�%�j�j�#�a�&�&�3�q�6�6�/�2�J�J�J�J�J�Jr.)rrXr(r=rrYr�s r,�canberra_distancezPoint.canberra_distance'sj��R�)�)�$��a���9�9���1� �<� C�A�I� C��A�B�B� B��J�J��A�q� � �J�J�J�K�Kr.c�&�|t|��z S)zdReturn the Point that is in the same direction as `self` and a distance of 1 from the originr�rqs r,�unitz Point.unitUs���c�$�i�i��r.N)r�),�__name__� __module__� __qualname__�__doc__�is_PointrErOr]rbrhrkrnrrrtrvrzr|r�r�� classmethodrX� staticmethodr��propertyr�r�rLr�r�r�r�r�r�r�r�r(r�r�rNr�r�r�r�r�rSr.r,rr*s�������>�>�@�H�F4�F4�F4�P,�,�,� %-�%-�%-�N!�!�!�-�-�-� '�'�'� ������$�$�$����-�-�-�>$�$�$�-�-�-� *�*�*� �4�4��[�4�"�?�?��\�?�*�>�>��X�>��+/�+/��[�+/�Z2�2�2�h4�4�4� =�=�=�.�.�.�.�@'(�'(�'(�R$/�$/�$/�L6�6�6�p����X�����&����X��� � ��X� �G�G�G�<�4�4��X�4� �:�:��X�:�2�$'�$'��\�$'�L8�8�8�B,L�,L�,L�\� � ��X� � � r.rc��eZdZdZdZdd�d�Zd�Zed���Zdd �Z dd �Z d �Z dd�Z ed���Z ed���Zed���ZdS)rCa�A 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"F�r6c�L�|sd|d<t|i|��}tj|g|�R�S)Nr"r!�rrrE�rFr6rGrHs r,rEzPoint2D.__new__��>��� *��F�5�M��$�)�&�)�)�D��%�c�1�D�1�1�1�1r.c��||kSr0rSr`s r,rbzPoint2D.__contains__�� ���t�|�r.c�6�|j|j|j|jfS)zwReturn a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure. )re�yrqs r,�boundszPoint2D.bounds�s����������/�/r.Nc���t|��}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) Nr"r�)rrrrG)rM�angle�pt�cr[r�rer�s r,�rotatezPoint2D.rotate�s���& ��J�J�� ��J�J�� �� �>��r�q�!�!�!�B� �"�H�B��w���1� �1�Q�3��1��9�a��c�A�a�C�i� (� (�� �>� �"�H�B�� r.rc���|rBt|d���}|j| j��||��j|j�St|j|z|j|z��S)a�Scale 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� translaterG�scalerer�)rMrer�r�s r,rz Point2D.scale�sj��, � O��r�q�!�!�!�B�D�>�4�>�R�C�:�.�4�4�Q��:�:�D�b�g�N� N��T�V�A�X�t�v�a�x�(�(�(r.c ���|jr |jdkstd���|j\}}t t dd||dg��|z���ddd��S)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 )r7r7zmatrix must be a 3x3 matrixrr7rNr")� is_Matrix�shaper=rGrr�tolist)rM�matrixrer�s r,� transformzPoint2D.transform�sq��� � <�V�\�V�%;�%;��:�;�;� ;��y���1��v�a��Q��1�I�.�.�v�5�=�=�?�?��B�2�A�2�F�G�Gr.rc�B�t|j|z|j|z��S)a�Shift 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) )rrer�)rMrer�s r,rzPoint2D.translate�s ��*�T�V�a�Z���!��,�,�,r.c��|jS)z� Returns the two coordinates of the Point. Examples ======== >>> from sympy import Point2D >>> p = Point2D(0, 1) >>> p.coordinates (0, 1) r_rqs r,� coordinateszPoint2D.coordinates� ���y�r.c��|jdS)z� Returns the X coordinate of the Point. Examples ======== >>> from sympy import Point2D >>> p = Point2D(0, 1) >>> p.x 0 rr_rqs r,rez Point2D.x����y��|�r.c��|jdS)z� Returns the Y coordinate of the Point. Examples ======== >>> from sympy import Point2D >>> p = Point2D(0, 1) >>> p.y 1 rr_rqs r,r�z Point2D.y"rr.r0)rrN)rr)r�r�r�r�r�rErbr�r�rrr rr rer�rSr.r,rCrC\s ������0�0�d��%*�2�2�2�2�2� ����0�0��X�0�����@)�)�)�)�6 H� H� H�-�-�-�-�.� � ��X� �� � ��X� �� � ��X� � � r.rCc��eZdZdZdZdd�d�Zd�Zed���Zd�Z d �Z d �Z dd �Z d�Z dd�Zed���Zed���Zed���Zed���Zd S)rDa>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) r7Fr�c�L�|sd|d<t|i|��}tj|g|�R�S)Nr7r!r�r�s r,rEzPoint3D.__new__ar�r.c��||kSr0rSr`s r,rbzPoint3D.__contains__gr�r.c��tj|�S)a�Is 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�)r�s r,� are_collinearzPoint3D.are_collinearjs��D�!�6�*�*r.c���|�|��}ttd�|D�����}|j|jz |z |j|jz |z |j|jz |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�|] }|dzV�� dSr�rSr�s r,r-z+Point3D.direction_cosine.<locals>.<genexpr>�s&����'�'��q�!�t�'�'�'�'�'�'r.)�direction_ratior rrer��z)rM�pointr+rVs r,�direction_cosinezPoint3D.direction_cosine�st��, � � �� '� '�� ��'�'�Q�'�'�'�(� )� )����4�6�!�Q�&���$�&�(8�A�'=���4�6�!�Q�&�(� (r.c�Z�|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] )rer�r)rMrs r,rzPoint3D.direction_ratio�s,��,��4�6�!�E�G�d�f�$4�u�w���7G�I�Ir.c��t|t��st|d���}t|t��r ||kr|gSgS|�|��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 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)] r7r�)r1rrrDr�rjs r,r�zPoint3D.intersection�sc��<�%��0�0� (��%�Q�'�'�'�E� �e�W� %� %� ��u�}�}��v� ��I��!�!�$�'�'�'r.rNc���|rAt|��}|j| j��|||��j|j�St|j|z|j|z|j|z��S)a�Scale 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) )rDrrGrrer�r)rMrer�rr�s r,rz Point3D.scale�sm��, � R�����B�G�>�4�>�R�C�:�.�4�4�Q��1�=�=�G���Q� Q��t�v�a�x�����4�6�!�8�4�4�4r.c ���|jr |jdkstd���|j\}}}t |��}t t dd|||dg��|z���ddd��S)z�Return 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!rNr7)rrr=rGrrDrr)rMr rer�rr�s r,r zPoint3D.transforms���� � <�V�\�V�%;�%;��:�;�;� ;��)���1�a� �f� � �����1�q�!�Q��l�3�3�A�5�=�=�?�?��B�2�A�2�F�G�Gr.rc�T�t|j|z|j|z|j|z��S)a�Shift 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) )rDrer�r)rMrer�rs r,rzPoint3D.translates(��*�t�v��z�4�6�A�:�t�v��z�:�:�:r.c��|jS)z� Returns the three coordinates of the Point. Examples ======== >>> from sympy import Point3D >>> p = Point3D(0, 1, 2) >>> p.coordinates (0, 1, 2) r_rqs r,r zPoint3D.coordinates(rr.c��|jdS)z� Returns the X coordinate of the Point. Examples ======== >>> from sympy import Point3D >>> p = Point3D(0, 1, 3) >>> p.x 0 rr_rqs r,rez Point3D.x7rr.c��|jdS)z� Returns the Y coordinate of the Point. Examples ======== >>> from sympy import Point3D >>> p = Point3D(0, 1, 2) >>> p.y 1 rr_rqs r,r�z Point3D.yFrr.c��|jdS)z� Returns the Z coordinate of the Point. Examples ======== >>> from sympy import Point3D >>> p = Point3D(0, 1, 1) >>> p.z 1 r"r_rqs r,rz Point3D.zUrr.)rrrN)rrr)r�r�r�r�r�rErbr�rrrr�rr rr�r rer�rrSr.r,rDrD1sE������+�+�Z��%*�2�2�2�2�2� ����!+�!+��\�!+�F(�(�(�6J�J�J�0$(�$(�$(�L5�5�5�5�6 H� H� H�;�;�;�;�.� � ��X� �� � ��X� �� � ��X� �� � ��X� � � r.rD),r�r>� sympy.corerrr�sympy.core.addr�sympy.core.containersr�sympy.core.numbersr�sympy.core.parametersr �sympy.simplifyr r �sympy.geometry.exceptionsr �(sympy.functions.elementary.miscellaneousr �$sympy.functions.elementary.complexesr�(sympy.functions.elementary.trigonometricrr�sympy.matricesr�sympy.matrices.expressionsr�sympy.utilities.iterablesrr�sympy.utilities.miscrrr�entityr�mpmath.libmp.libmpfrrrCrDrSr.r,�<module>r7s����&����'�'�'�'�'�'�'�'�'�'�������'�'�'�'�'�'�$�$�$�$�$�$�3�3�3�3�3�3�.�.�.�.�.�.�.�.�3�3�3�3�3�3�9�9�9�9�9�9�3�3�3�3�3�3�=�=�=�=�=�=�=�=�!�!�!�!�!�!�0�0�0�0�0�0�7�7�7�7�7�7�7�7�C�C�C�C�C�C�C�C�C�C�"�"�"�"�"�"�+�+�+�+�+�+�o  �o  �o  �o  �o  �N�o  �o  �o  �dS�S�S�S�S�e�S�S�S�jq�q�q�q�q�e�q�q�q�q�qr.
Memory