o
    oÇ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ƒs"|d ur"tdt|ƒ ƒ‚|d u r1tƒ  | t|ƒ|¡}ntƒ  | t|ƒ||¡}||_	||_
|d u rNd |_||_|S ||_|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ÚpositionÚparent_pointÚobj©Ú	__class__© úf/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/vector/point.pyr      s4   
ÿÿ
ÿÿýzPoint.__new__c                 C   sÔ   t |tƒst |tƒstt|ƒd ƒ‚t |tƒr|j}|| kr!tjS || jkr)| j	S |j| kr3d|j	 S t
| |ƒ\}}tj}d}t|ƒD ]	}||| j	7 }qC|d7 }|t|ƒk rh||| j	8 }|d7 }|t|ƒk sW|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ÚotherÚ	rootindexÚpathÚresultÚir   r   r   Úposition_wrt+   s2   
ÿÿ



þ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   ÚtupleÚ	to_matrix)r#   Úcoordinate_systemÚ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/   r1   Ú__classcell__r   r   r   r   r   	   s    
1r   N)Úsympy.core.basicr   Úsympy.core.symbolr   Úsympy.vector.vectorr   Úsympy.vector.coordsysrectr   Úsympy.vector.functionsr   Úsympy.core.cacher   r   r   r   r   r   Ú<module>   s    