U
    ˜9%e¤  ã                   @   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ršd |_||_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__© úQ/var/www/html/Darija-Ai-API/env/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   