U
    L?h                     @   s\   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ G dd deZd	S )
    )Basic)Str)Vector)
CoordSys3D)_path)cacheitc                       sL   e Zd ZdZejdf fdd	Zedd Zdd Z	d	d
 Z
dd Z  ZS )Pointz*
    Represents a point in 3-D space.
    Nc                    s   t |}t|ts"tdt| t|tsD|d k	rDtdt| |d krbt | t||}nt | t|||}||_	||_
|d krd |_||_n||_|j|_|S )Nz0position should be an instance of Vector, not %sz3parent_point should be an instance of Point, not %s)str
isinstancer   	TypeErrortyper   super__new__r   _name_pos_parent_root)clsnamepositionZparent_pointobj	__class__ D/var/www/html/venv/lib/python3.8/site-packages/sympy/vector/point.pyr      s4    

zPoint.__new__c                 C   s   t |ts$t |ts$tt|d t |tr4|j}|| krBtjS || jkrR| j	S |j| krfd|j	 S t
| |\}}tj}d}t|D ]}||| j	7 }q|d7 }|t|k r||| j	8 }|d7 }q|S )aL  
        Returns the position vector of this Point with respect to
        another Point/CoordSys3D.

        Parameters
        ==========

        other : Point/CoordSys3D
            If other is a Point, the position of this Point wrt it is
            returned. If its an instance of CoordSyRect, the position
            wrt its origin is returned.

        Examples
        ========

        >>> from sympy.vector import CoordSys3D
        >>> N = CoordSys3D('N')
        >>> p1 = N.origin.locate_new('p1', 10 * N.i)
        >>> N.origin.position_wrt(p1)
        (-10)*N.i

        zis not a Point or CoordSys3D      )r
   r   r   r   r	   originr   zeror   r   r   rangelen)selfotherZ	rootindexpathresultir   r   r   position_wrt+   s0    





zPoint.position_wrtc                 C   s   t ||| S )ai  
        Returns a new Point located at the given position wrt this
        Point.
        Thus, the position vector of the new Point wrt this one will
        be equal to the given 'position' parameter.

        Parameters
        ==========

        name : str
            Name of the new point

        position : Vector
            The position vector of the new Point wrt this one

        Examples
        ========

        >>> from sympy.vector import CoordSys3D
        >>> N = CoordSys3D('N')
        >>> p1 = N.origin.locate_new('p1', 10 * N.i)
        >>> p1.position_wrt(N.origin)
        10*N.i

        )r   )r"   r   r   r   r   r   
locate_new]   s    zPoint.locate_newc                 C   s   |  |j}t||S )aA  
        Returns the Cartesian/rectangular coordinates of this point
        wrt the origin of the given CoordSys3D instance.

        Parameters
        ==========

        coordinate_system : CoordSys3D
            The coordinate system to express the coordinates of this
            Point in.

        Examples
        ========

        >>> from sympy.vector import CoordSys3D
        >>> N = CoordSys3D('N')
        >>> p1 = N.origin.locate_new('p1', 10 * N.i)
        >>> p2 = p1.locate_new('p2', 5 * N.j)
        >>> p2.express_coordinates(N)
        (10, 5, 0)

        )r'   r   tupleZ	to_matrix)r"   Zcoordinate_systemZpos_vectr   r   r   express_coordinatesy   s    zPoint.express_coordinatesc                 C   s   | j S )N)r   )r"   printerr   r   r   	_sympystr   s    zPoint._sympystr)__name__
__module____qualname____doc__r   r   r   r   r'   r(   r*   r,   __classcell__r   r   r   r   r   	   s   
1r   N)Zsympy.core.basicr   Zsympy.core.symbolr   Zsympy.vector.vectorr   Zsympy.vector.coordsysrectr   Zsympy.vector.functionsr   Zsympy.core.cacher   r   r   r   r   r   <module>   s   