ó
¡¼™\c           @  su   d  d l  m Z m Z d  d l m Z m Z d d l m Z m Z d d l	 m
 Z
 d g Z d e f d „  ƒ  YZ d S(	   iÿÿÿÿ(   t   print_functiont   division(   t   ranget   string_typesi   (   t   Vectort   _check_vector(   t   _check_framet   Pointc           B  s¤   e  Z d  Z d „  Z d „  Z e Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sá   This object represents a point in a dynamic system.

    It stores the: position, velocity, and acceleration of a point.
    The position is a vector defined as the vector distance from a parent
    point to this point.

    c         C  sC   | |  _  i  |  _ i  |  _ i  |  _ |  j |  j |  j g |  _ d S(   s"   Initialization of a Point object. N(   t   namet	   _pos_dictt	   _vel_dictt	   _acc_dictt   _pdlist(   t   selfR   (    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyt   __init__   s
    				c         C  s   |  j  S(   N(   R   (   R   (    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyt   __str__   s    c         C  s"   t  | t ƒ s t d ƒ ‚ n  d  S(   Ns   A Point must be supplied(   t
   isinstanceR   t	   TypeError(   R   t   other(    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyt   _check_point   s    c         C  sG  |  g g } g  g } x¦ | | k r½ | } xŒ t  | ƒ D]~ \ } } | d j | j ƒ  } xX t  | ƒ D]J \ } }	 | j |	 ƒ sh | |	 g }
 | j |
 ƒ s² | j |
 ƒ q² qh qh Wq8 Wq Wx: t  | ƒ D], \ } } | d | k rË | j | ƒ qË qË W| j d t ƒ t | ƒ d k r%| d St d | j	 d |  j	 ƒ ‚ d S(   s3   Creates a list from self to other using _dcm_dict. iÿÿÿÿt   keyi    s!   No Connecting Path found between s    and N(
   t	   enumerateR   t   keyst   __contains__t   appendt   removet   sortt   lent
   ValueErrorR   (   R   R   t   numt   outlistt   oldlistt   it   vt   templistt   i2t   v2t   littletemplist(    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyt   _pdict_list#   s&    	c   
      C  s¼   t  | ƒ t  | ƒ |  j | ƒ |  j | ƒ } |  j | ƒ } | j | ƒ } |  j | ƒ } | j | ƒ } | j | ƒ }	 |  j | | d | | A| |	 | A| | | AAƒ |  j | ƒ S(   sE  Sets the acceleration of this point with the 1-point theory.

        The 1-point theory for point acceleration looks like this:

        ^N a^P = ^B a^P + ^N a^O + ^N alpha^B x r^OP + ^N omega^B x (^N omega^B
        x r^OP) + 2 ^N omega^B x ^B v^P

        where O is a point fixed in B, P is a point moving in B, and B is
        rotating in frame N.

        Parameters
        ==========

        otherpoint : Point
            The first point of the 1-point theory (O)
        outframe : ReferenceFrame
            The frame we want this point's acceleration defined in (N)
        fixedframe : ReferenceFrame
            The intermediate frame in this calculation (B)

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> from sympy.physics.vector import Vector, dynamicsymbols
        >>> q = dynamicsymbols('q')
        >>> q2 = dynamicsymbols('q2')
        >>> qd = dynamicsymbols('q', 1)
        >>> q2d = dynamicsymbols('q2', 1)
        >>> N = ReferenceFrame('N')
        >>> B = ReferenceFrame('B')
        >>> B.set_ang_vel(N, 5 * B.y)
        >>> O = Point('O')
        >>> P = O.locatenew('P', q * B.x)
        >>> P.set_vel(B, qd * B.x + q2d * B.y)
        >>> O.set_vel(N, 0)
        >>> P.a1pt_theory(O, N, B)
        (-25*q + q'')*B.x + q2''*B.y - 10*q'*B.z

        i   (   R   R   t   pos_fromt   velt   acct
   ang_vel_int
   ang_acc_int   set_acc(
   R   t
   otherpointt   outframet
   interframet   distR!   t   a1t   a2t   omegat   alpha(    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyt   a1pt_theory9   s    *

$c         C  sŽ   t  | ƒ t  | ƒ |  j | ƒ |  j | ƒ } | j | ƒ } | j | ƒ } | j | ƒ } |  j | | | | A| | | AAƒ |  j | ƒ S(   sA  Sets the acceleration of this point with the 2-point theory.

        The 2-point theory for point acceleration looks like this:

        ^N a^P = ^N a^O + ^N alpha^B x r^OP + ^N omega^B x (^N omega^B x r^OP)

        where O and P are both points fixed in frame B, which is rotating in
        frame N.

        Parameters
        ==========

        otherpoint : Point
            The first point of the 2-point theory (O)
        outframe : ReferenceFrame
            The frame we want this point's acceleration defined in (N)
        fixedframe : ReferenceFrame
            The frame in which both points are fixed (B)

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame, dynamicsymbols
        >>> q = dynamicsymbols('q')
        >>> qd = dynamicsymbols('q', 1)
        >>> N = ReferenceFrame('N')
        >>> B = N.orientnew('B', 'Axis', [q, N.z])
        >>> O = Point('O')
        >>> P = O.locatenew('P', 10 * B.x)
        >>> O.set_vel(N, 5 * N.x)
        >>> P.a2pt_theory(O, N, B)
        - 10*q'**2*B.x + 10*q''*B.y

        (   R   R   R'   R)   R*   R+   R,   (   R   R-   R.   t
   fixedframeR0   t   aR3   R4   (    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyt   a2pt_theoryp   s    $

$c         C  sX   t  | ƒ | |  j k rM |  j | d k r@ |  j | j | ƒ St d ƒ Sn  |  j | S(   sÏ  The acceleration Vector of this Point in a ReferenceFrame.

        Parameters
        ==========

        frame : ReferenceFrame
            The frame in which the returned acceleration vector will be defined in

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> N = ReferenceFrame('N')
        >>> p1 = Point('p1')
        >>> p1.set_acc(N, 10 * N.x)
        >>> p1.acc(N)
        10*N.x

        i    (   R   R   R
   t   dtR   (   R   t   frame(    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyR)   ž   s    
c         C  sv   t  | t ƒ s t d ƒ ‚ n  | d k r9 t d ƒ } n  t | ƒ } t | ƒ } | j |  | ƒ |  j | | ƒ | S(   sÖ  Creates a new point with a position defined from this point.

        Parameters
        ==========

        name : str
            The name for the new point
        value : Vector
            The position of the new point relative to this point

        Examples
        ========

        >>> from sympy.physics.vector import ReferenceFrame, Point
        >>> N = ReferenceFrame('N')
        >>> P1 = Point('P1')
        >>> P2 = P1.locatenew('P2', 10 * N.x)

        s   Must supply a valid namei    (   R   R   R   R   R   R   t   set_pos(   R   R   t   valuet   p(    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyt	   locatenew»   s    c         C  s`   t  d ƒ } |  j | d ƒ } x; t t | ƒ d ƒ D]# } | | | j | | d 7} q5 W| S(   sã  Returns a Vector distance between this Point and the other Point.

        Parameters
        ==========

        otherpoint : Point
            The otherpoint we are locating this one relative to

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> N = ReferenceFrame('N')
        >>> p1 = Point('p1')
        >>> p2 = Point('p2')
        >>> p1.set_pos(p2, 10 * N.x)
        >>> p1.pos_from(p2)
        10*N.x

        i    i   (   R   R&   R   R   R	   (   R   R-   t   outvect   plistR    (    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyR'   Ú   s
    !c         C  sL   | d k r t  d ƒ } n  t | ƒ } t | ƒ |  j j i | | 6ƒ d S(   s#  Used to set the acceleration of this Point in a ReferenceFrame.

        Parameters
        ==========

        frame : ReferenceFrame
            The frame in which this point's acceleration is defined
        value : Vector
            The vector value of this point's acceleration in the frame

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> N = ReferenceFrame('N')
        >>> p1 = Point('p1')
        >>> p1.set_acc(N, 10 * N.x)
        >>> p1.acc(N)
        10*N.x

        i    N(   R   R   R   R   t   update(   R   R:   R<   (    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyR,   ö   s
    
c         C  sg   | d k r t  d ƒ } n  t | ƒ } |  j | ƒ |  j j i | | 6ƒ | j j i | |  6ƒ d S(   sD  Used to set the position of this point w.r.t. another point.

        Parameters
        ==========

        otherpoint : Point
            The other point which this point's location is defined relative to
        value : Vector
            The vector which defines the location of this point

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> N = ReferenceFrame('N')
        >>> p1 = Point('p1')
        >>> p2 = Point('p2')
        >>> p1.set_pos(p2, 10 * N.x)
        >>> p1.pos_from(p2)
        10*N.x

        i    N(   R   R   R   R	   RA   (   R   R-   R<   (    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyR;     s    c         C  sL   | d k r t  d ƒ } n  t | ƒ } t | ƒ |  j j i | | 6ƒ d S(   s  Sets the velocity Vector of this Point in a ReferenceFrame.

        Parameters
        ==========

        frame : ReferenceFrame
            The frame in which this point's velocity is defined
        value : Vector
            The vector value of this point's velocity in the frame

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> N = ReferenceFrame('N')
        >>> p1 = Point('p1')
        >>> p1.set_vel(N, 10 * N.x)
        >>> p1.vel(N)
        10*N.x

        i    N(   R   R   R   R
   RA   (   R   R:   R<   (    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyt   set_vel2  s
    
c         C  s†   t  | ƒ t  | ƒ |  j | ƒ |  j | ƒ } |  j | ƒ } | j | ƒ } | j | ƒ } |  j | | | | | Aƒ |  j | ƒ S(   sè  Sets the velocity of this point with the 1-point theory.

        The 1-point theory for point velocity looks like this:

        ^N v^P = ^B v^P + ^N v^O + ^N omega^B x r^OP

        where O is a point fixed in B, P is a point moving in B, and B is
        rotating in frame N.

        Parameters
        ==========

        otherpoint : Point
            The first point of the 2-point theory (O)
        outframe : ReferenceFrame
            The frame we want this point's velocity defined in (N)
        interframe : ReferenceFrame
            The intermediate frame in this calculation (B)

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> from sympy.physics.vector import Vector, dynamicsymbols
        >>> q = dynamicsymbols('q')
        >>> q2 = dynamicsymbols('q2')
        >>> qd = dynamicsymbols('q', 1)
        >>> q2d = dynamicsymbols('q2', 1)
        >>> N = ReferenceFrame('N')
        >>> B = ReferenceFrame('B')
        >>> B.set_ang_vel(N, 5 * B.y)
        >>> O = Point('O')
        >>> P = O.locatenew('P', q * B.x)
        >>> P.set_vel(B, qd * B.x + q2d * B.y)
        >>> O.set_vel(N, 0)
        >>> P.v1pt_theory(O, N, B)
        q'*B.x + q2'*B.y - 5*q*B.z

        (   R   R   R'   R(   R*   RB   (   R   R-   R.   R/   R0   t   v1R$   R3   (    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyt   v1pt_theoryO  s    )

c         C  ss   t  | ƒ t  | ƒ |  j | ƒ |  j | ƒ } | j | ƒ } | j | ƒ } |  j | | | | Aƒ |  j | ƒ S(   s  Sets the velocity of this point with the 2-point theory.

        The 2-point theory for point velocity looks like this:

        ^N v^P = ^N v^O + ^N omega^B x r^OP

        where O and P are both points fixed in frame B, which is rotating in
        frame N.

        Parameters
        ==========

        otherpoint : Point
            The first point of the 2-point theory (O)
        outframe : ReferenceFrame
            The frame we want this point's velocity defined in (N)
        fixedframe : ReferenceFrame
            The frame in which both points are fixed (B)

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame, dynamicsymbols
        >>> q = dynamicsymbols('q')
        >>> qd = dynamicsymbols('q', 1)
        >>> N = ReferenceFrame('N')
        >>> B = N.orientnew('B', 'Axis', [q, N.z])
        >>> O = Point('O')
        >>> P = O.locatenew('P', 10 * B.x)
        >>> O.set_vel(N, 5 * N.x)
        >>> P.v2pt_theory(O, N, B)
        5*N.x + 10*q'*B.y

        (   R   R   R'   R(   R*   RB   (   R   R-   R.   R6   R0   R!   R3   (    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyt   v2pt_theory‚  s    $

c         C  sE   t  | ƒ | |  j k r: t d |  j d | j ƒ ‚ n  |  j | S(   sÉ  The velocity Vector of this Point in the ReferenceFrame.

        Parameters
        ==========

        frame : ReferenceFrame
            The frame in which the returned velocity vector will be defined in

        Examples
        ========

        >>> from sympy.physics.vector import Point, ReferenceFrame
        >>> N = ReferenceFrame('N')
        >>> p1 = Point('p1')
        >>> p1.set_vel(N, 10 * N.x)
        >>> p1.vel(N)
        10*N.x

        s   Velocity of point s(    has not been defined in ReferenceFrame (   R   R
   R   R   (   R   R:   (    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyR(   ¯  s
    
c         G  s\   g  | D]' } |  j  | ƒ j | | d t ƒ^ q } t | ƒ d k rN | d St | ƒ Sd S(   s  Returns the partial velocities of the linear velocity vector of this
        point in the given frame with respect to one or more provided
        generalized speeds.

        Parameters
        ==========
        frame : ReferenceFrame
            The frame with which the velocity is defined in.
        gen_speeds : functions of time
            The generalized speeds.

        Returns
        =======
        partial_velocities : tuple of Vector
            The partial velocity vectors corresponding to the provided
            generalized speeds.

        Examples
        ========

        >>> from sympy.physics.vector import ReferenceFrame, Point
        >>> from sympy.physics.vector import dynamicsymbols
        >>> N = ReferenceFrame('N')
        >>> A = ReferenceFrame('A')
        >>> p = Point('p')
        >>> u1, u2 = dynamicsymbols('u1, u2')
        >>> p.set_vel(N, u1 * N.x + u2 * A.y)
        >>> p.partial_velocity(N, u1)
        N.x
        >>> p.partial_velocity(N, u1, u2)
        (N.x, A.y)

        t
   var_in_dcmi   i    N(   R(   t   difft   FalseR   t   tuple(   R   R:   t
   gen_speedst   speedt   partials(    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyt   partial_velocityÊ  s
    "1(   t   __name__t
   __module__t   __doc__R   R   t   __repr__R   R&   R5   R8   R)   R>   R'   R,   R;   RB   RD   RE   R(   RM   (    (    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyR   	   s$   					7	.							3	-	N(   t
   __future__R    R   t   sympy.core.compatibilityR   R   t   vectorR   R   R:   R   t   __all__t   objectR   (    (    (    s9   lib/python2.7/site-packages/sympy/physics/vector/point.pyt   <module>   s
   	