
    sg                     b    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e      Zy	)
    )Basic)Str)Vector)
CoordSys3D)_path)cacheitc                   ^     e Zd ZdZej
                  df fd	Zed        Zd Z	d Z
d Z xZS )Pointz*
    Represents a point in 3-D space.
    Nc                    t        |      }t        |t              st        dt	        |      z        t        |t
              s|t        dt	        |      z        |t        |   | t        |      |      }nt        |   | t        |      ||      }||_	        ||_
        |d |_        ||_        |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__s        E/var/www/html/venv/lib/python3.12/site-packages/sympy/vector/point.pyr   zPoint.__new__   s    4y(F+BTF   </(E I" "# # '/#s4y(;C'/#s4y(LIC	CKCI
 
 'CK$**CI
    c                 @   t        |t              s't        |t              st        t	        |      dz         t        |t              r|j
                  }|| k(  rt        j                  S || j                  k(  r| j                  S |j                  | k(  rd|j                  z  S t        | |      \  }}t        j                  }d}t        |      D ]  }|||   j                  z  } |dz  }|t        |      k  r&|||   j                  z  }|dz  }|t        |      k  r&|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is         r   position_wrtzPoint.position_wrt+   s   2 5%(uj1CJ:; < <eZ(LLED=;;dll"99]]d"

?"e,	4y! 	#Ad1gll"F	#	Q#d)md1gll"FFA #d)m r   c                     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   s      r   
locate_newzPoint.locate_new]   s    4 T8T**r   c                 l    | j                  |j                        }t        |j                  |            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_vects      r   express_coordinateszPoint.express_coordinatesy   s2    2 $$%6%=%=>X''(9:;;r   c                     | j                   S )N)r   )r&   printers     r   	_sympystrzPoint._sympystr   s    zzr   )__name__
__module____qualname____doc__r   r#   r   r   r,   r.   r4   r7   __classcell__)r   s   @r   r
   r
   	   s<     %+KKd : / /b+8<:r   r
   N)sympy.core.basicr   sympy.core.symbolr   sympy.vector.vectorr   sympy.vector.coordsysrectr   sympy.vector.functionsr   sympy.core.cacher   r
    r   r   <module>rD      s%    " ! & 0 ( $NE Nr   