
    \hJ                    "   S SK JrJr  S SKJrJrJr  S SKJr  S SK	J
r
  S SKJr  S SKJrJrJrJrJr  S SKJr  S SKJr  / S	Qr " S
 S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)    )ABCabstractmethod)pi
DerivativeMatrix)AppliedUndef)BodyBase)_validate_coordinates)VectordynamicsymbolscrossPointReferenceFrame)iterable)sympy_deprecation_warning)JointPinJointPrismaticJointCylindricalJointPlanarJointSphericalJoint	WeldJointc                      \ rS rSrSr    S!S jrS rS r\S 5       r	\S 5       r
\S	 5       r\S
 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\  S"S j5       rS r S#S jr!S#S jr"  S$S jr#S r$g)%r      a  Abstract base class for all specific joints.

Explanation
===========

A joint subtracts degrees of freedom from a body. This is the base class
for all specific joints and holds all common methods acting as an interface
for all joints. Custom joint can be created by inheriting Joint class and
defining all abstract functions.

The abstract methods are:

- ``_generate_coordinates``
- ``_generate_speeds``
- ``_orient_frames``
- ``_set_angular_velocity``
- ``_set_linear_velocity``

Parameters
==========

name : string
    A unique name for the joint.
parent : Particle or RigidBody
    The parent body of joint.
child : Particle or RigidBody
    The child body of joint.
coordinates : iterable of dynamicsymbols, optional
    Generalized coordinates of the joint.
speeds : iterable of dynamicsymbols, optional
    Generalized speeds of joint.
parent_point : Point or Vector, optional
    Attachment point where the joint is fixed to the parent body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the parent's mass
    center.
child_point : Point or Vector, optional
    Attachment point where the joint is fixed to the child body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the child's mass
    center.
parent_axis : Vector, optional
    .. deprecated:: 1.12
        Axis fixed in the parent body which aligns with an axis fixed in the
        child body. The default is the x axis of parent's reference frame.
        For more information on this deprecation, see
        :ref:`deprecated-mechanics-joint-axis`.
child_axis : Vector, optional
    .. deprecated:: 1.12
        Axis fixed in the child body which aligns with an axis fixed in the
        parent body. The default is the x axis of child's reference frame.
        For more information on this deprecation, see
        :ref:`deprecated-mechanics-joint-axis`.
parent_interframe : ReferenceFrame, optional
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the parent's own frame.
child_interframe : ReferenceFrame, optional
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the child's own frame.
parent_joint_pos : Point or Vector, optional
    .. deprecated:: 1.12
        This argument is replaced by parent_point and will be removed in a
        future version.
        See :ref:`deprecated-mechanics-joint-pos` for more information.
child_joint_pos : Point or Vector, optional
    .. deprecated:: 1.12
        This argument is replaced by child_point and will be removed in a
        future version.
        See :ref:`deprecated-mechanics-joint-pos` for more information.

Attributes
==========

name : string
    The joint's name.
parent : Particle or RigidBody
    The joint's parent body.
child : Particle or RigidBody
    The joint's child body.
coordinates : Matrix
    Matrix of the joint's generalized coordinates.
speeds : Matrix
    Matrix of the joint's generalized speeds.
parent_point : Point
    Attachment point where the joint is fixed to the parent body.
child_point : Point
    Attachment point where the joint is fixed to the child body.
parent_axis : Vector
    The axis fixed in the parent frame that represents the joint.
child_axis : Vector
    The axis fixed in the child frame that represents the joint.
parent_interframe : ReferenceFrame
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated.
child_interframe : ReferenceFrame
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated.
kdes : Matrix
    Kinematical differential equations of the joint.

Notes
=====

When providing a vector as the intermediate frame, a new intermediate frame
is created which aligns its X axis with the provided vector. This is done
with a single fixed rotation about a rotation axis. This rotation axis is
determined by taking the cross product of the ``body.x`` axis with the
provided vector. In the case where the provided vector is in the ``-body.x``
direction, the rotation is done about the ``body.y`` axis.

Nc                 n   [        U[        5      (       d  [        S5      eXl        [        U[        5      (       d  [        S5      eX l        [        U[        5      (       d  [        S5      eX0l        U
c  Ub  [        SSSSS9  Uc  U
nU	c  Un	[        U R
                  S	5      (       a  U R
                  R                  U l
        OP[        U[        5      (       a  Xl
        O4[        U R                   S
U R
                  R                   S35      U l
        [        U R                  S	5      (       a  U R                  R                  U l        OP[        U	[        5      (       a  Xl        O4[        U R                   S
U R                  R                   S35      U l        U R                  U R
                  XR                  5      U l        U R                  U R                  XR                  5      U l        U R#                  XR                  5      U l        U R#                  XR                  5      U l        Uc  Ub  [        SSSSS9  Uc  UnUc  UnU R)                  U R
                  X`R                  5      U l        U R)                  U R                  XpR                  5      U l        U R/                  U5      U l        U R3                  U5      U l        [7        U R8                  U R:                  5        U R=                  5       U l        U RA                  5         U RC                  5         U RE                  5         g )NzSupply a valid name.zParent must be a body.zChild must be a body.z
                The parent_axis and child_axis arguments for the Joint classes
                are deprecated. Instead use parent_interframe, child_interframe.
                z1.12zdeprecated-mechanics-joint-axis   )deprecated_since_versionactive_deprecations_target
stacklevelframe__framez
                The parent_joint_pos and child_joint_pos arguments for the Joint
                classes are deprecated. Instead use parent_point and child_point.
                zdeprecated-mechanics-joint-pos)#
isinstancestr	TypeError_namer	   _parent_childr   hasattrr    _parent_framer   name_child_frame_locate_joint_frame_parent_interframe_child_interframe_axis_parent_axis_child_axis_locate_joint_pos_parent_point_child_point_generate_coordinates_coordinates_generate_speeds_speedsr
   coordinatesspeeds_generate_kdes_kdes_orient_frames_set_angular_velocity_set_linear_velocity)selfr+   parentchildr:   r;   parent_pointchild_pointparent_interframechild_interframeparent_axis
child_axisparent_joint_poschild_joint_poss                 U/var/www/auris/envauris/lib/python3.13/site-packages/sympy/physics/mechanics/joint.py__init__Joint.__init__   s   
 $$$233
&(++455%**344"j&<% *0+L !($/!'#-  4<<))!%!3!3D+^<<%6"%3yyk4<<#4#4"5V<&>"4;;(( $ 1 1D*N;;$4!$2yyk4;;#3#3"4F;%=! #'":":LL+-?-?#A!%!9!9KK)+<+<"> JJ{4F4FG::j2C2CD'?+F% *0+K #/"-!33LL,(:(:< 22KK&7&79 !66{C,,V4d..<((*
""$!!#    c                     U R                   $ N)r+   rA   s    rL   __str__Joint.__str__   s    yyrO   c                 "    U R                  5       $ rQ   )rS   rR   s    rL   __repr__Joint.__repr__   s    ||~rO   c                     U R                   $ )zName of the joint.)r&   rR   s    rL   r+   
Joint.name        zzrO   c                     U R                   $ )zParent body of Joint.)r'   rR   s    rL   rB   Joint.parent        ||rO   c                     U R                   $ )zChild body of Joint.)r(   rR   s    rL   rC   Joint.child   s     {{rO   c                     U R                   $ )z.Matrix of the joint's generalized coordinates.)r7   rR   s    rL   r:   Joint.coordinates           rO   c                     U R                   $ )z)Matrix of the joint's generalized speeds.)r9   rR   s    rL   r;   Joint.speeds   r]   rO   c                     U R                   $ )z0Kinematical differential equations of the joint.r=   rR   s    rL   kdes
Joint.kdes   rZ   rO   c                     U R                   $ )zThe axis of parent frame.)r1   rR   s    rL   rH   Joint.parent_axis   s        rO   c                     U R                   $ )zThe axis of child frame.)r2   rR   s    rL   rI   Joint.child_axis  s     rO   c                     U R                   $ )z=Attachment point where the joint is fixed to the parent body.)r4   rR   s    rL   rD   Joint.parent_point  s     !!!rO   c                     U R                   $ )z<Attachment point where the joint is fixed to the child body.)r5   rR   s    rL   rE   Joint.child_point  rb   rO   c                     U R                   $ rQ   )r.   rR   s    rL   rF   Joint.parent_interframe  s    &&&rO   c                     U R                   $ rQ   )r/   rR   s    rL   rG   Joint.child_interframe  s    %%%rO   c                     g)z7Generate Matrix of the joint's generalized coordinates.N rA   r:   s     rL   r6   Joint._generate_coordinates       	rO   c                     g)z2Generate Matrix of the joint's generalized speeds.Nrv   rA   r;   s     rL   r8   Joint._generate_speeds#  ry   rO   c                     g)zOrient frames as per the joint.Nrv   rR   s    rL   r>   Joint._orient_frames(  ry   rO   c                     g)z1Set angular velocity of the joint related frames.Nrv   rR   s    rL   r?   Joint._set_angular_velocity-  ry   rO   c                     g)z,Set velocity of related points to the joint.Nrv   rR   s    rL   r@   Joint._set_linear_velocity2  ry   rO   c                     [        X4/5      $ )z1Converts a matrix to a vector in the given frame.)r   )matrixr    s     rL   
_to_vectorJoint._to_vector7  s     '((rO   c                 *   U c  US   R                   n U $ [        U [        5      (       d  [        S5      eSnU H  n U R	                  U5        Un  O   Uc  [        S5      eU R                  U5      S:X  d  [        S5      eU $ ! [
         a     MX  f = f)z4Check whether an axis is fixed in one of the frames.Nr   zAxis must be a Vector.z5Axis cannot be expressed in one of the body's frames.zAAxis cannot be time-varying when viewed from the associated body.)xr#   r   r%   	to_matrix
ValueErrordt)axframes	ref_framer    s       rL   r0   Joint._axis<  s     :BI"f%%455	EU# "	   ' ( (uuY1$ 0 1 1	  s   B
BBc                    UR                  U 5      nUS   US   US   pTnUS:w  a?  US:w  a  US:w  a  [        XR                  5      $ US:w  a  U R                  $ U R                  $ US:w  a  U R                  $ U R                  $ )Nr         )r   r   r   yz)r    axis
componentsr   r   r   s         rL   _choose_rotation_axisJoint._choose_rotation_axisU  s}    ^^E*
Q-A
1a6Av6 ww//Avww77NAvww77NrO   c                    [        U [        5      (       a  U R                  n Uc  U R                  nUc5  U R                  SS S:X  a  U R                  SS  S3nOU R                   S3nUR                  U5      n[        X!5      nU[        S5      :X  a  US:X  a  U $ U[        :X  a  [        R                  X5      n[        U5      nUR                  XU5        UR                  U SU-  5        U$ )u  
Returns an intermediate frame, where the ``frame_axis`` defined in
``frame`` is aligned with ``axis``. By default this means that the X
axis will be aligned with ``axis``.

Parameters
==========

frame : BodyBase or ReferenceFrame
    The body or reference frame with respect to which the intermediate
    frame is oriented.
align_axis : Vector
    The vector with respect to which the intermediate frame will be
    aligned.
frame_axis : Vector
    The vector of the frame which should get aligned with ``axis``. The
    default is the X axis of the frame.
frame_name : string
    Name of the to be created intermediate frame. The default adds
    "_int_frame" to the name of ``frame``.

Example
=======

An intermediate frame, where the X axis of the parent becomes aligned
with ``parent.y + parent.z`` can be created as follows:

>>> from sympy.physics.mechanics.joint import Joint
>>> from sympy.physics.mechanics import RigidBody
>>> parent = RigidBody('parent')
>>> parent_interframe = Joint._create_aligned_interframe(
...     parent, parent.y + parent.z)
>>> parent_interframe
parent_int_frame
>>> parent.frame.dcm(parent_interframe)
Matrix([
[        0, -sqrt(2)/2, -sqrt(2)/2],
[sqrt(2)/2,        1/2,       -1/2],
[sqrt(2)/2,       -1/2,        1/2]])
>>> (parent.y + parent.z).express(parent_interframe)
sqrt(2)*parent_int_frame.x

Notes
=====

The direction cosine matrix between the given frame and intermediate
frame is formed using a simple rotation about an axis that is normal to
both ``align_axis`` and ``frame_axis``. In general, the normal axis is
formed by crossing the ``frame_axis`` with the ``align_axis``. The
exception is if the axes are parallel with opposite directions, in which
case the rotation vector is chosen using the rules in the following
table with the vectors expressed in the given frame:

.. list-table::
   :header-rows: 1

   * - ``align_axis``
     - ``frame_axis``
     - ``rotation_axis``
   * - ``-x``
     - ``x``
     - ``z``
   * - ``-y``
     - ``y``
     - ``x``
   * - ``-z``
     - ``z``
     - ``y``
   * - ``-x-y``
     - ``x+y``
     - ``z``
   * - ``-y-z``
     - ``y+z``
     - ``x``
   * - ``-x-z``
     - ``x+z``
     - ``y``
   * - ``-x-y-z``
     - ``x+y+z``
     - ``(x+y+z) × x``

Nir"   
_int_framer   )r#   r	   r    r   r+   angle_betweenr   r   r   r   r   r   orient_axisset_ang_vel)r    
align_axis
frame_axis
frame_nameanglerotation_axis	int_frames          rL   _create_aligned_interframe Joint._create_aligned_interframef  s    j eX&&KKEJzz"#(* %

3B0
;
 %

|:6
((4j5F1I%%1*LB;!77JM":.	eE:eQ%67rO   c                    / n[         R                  n[        [        U R                  5      5       HA  nUR                  U R                  U   R                  U5      * U R                  U   -   5        MC     [        U5      $ )z,Generate kinematical differential equations.)	r   _trangelenr:   appenddiffr;   r   )rA   rg   tis       rL   r<   Joint._generate_kdes  sh    s4++,-AKK))!,11!44t{{1~EF .d|rO   c                    Uc  UR                   nUc  UR                  $ [        U[        [        45      (       d  [        S5      e[        U[        5      (       a7  U R                   SUR                   S3nUR                  R                  XB5      nUR                  UR                  5      R                  U5      S:X  d  [        S5      eU$ )z'Returns the attachment point of a body.z+Attachment point must be a Point or Vector.r!   _jointr   z6Attachment point must be fixed to the associated body.)r    
masscenterr#   r   r   r%   r+   	locatenewpos_fromr   r   )rA   body	joint_pos
body_frame
point_names        rL   r3   Joint._locate_joint_pos  s    J??")eV_55IJJi(( II;a		{&9J11*HI!!$//255jAQF % & &rO   c                 |   Uc  UR                   nUc  U$ [        U[        5      (       a/  [        R	                  X2U R
                   SUR
                   S3S9nO [        U[        5      (       d  [        S5      eUR                  U5      S:X  d  [        SU SU S35      eUR                  R                  US5        U$ )	z'Returns the attachment frame of a body.r!   r   )r   z$Interframe must be a ReferenceFrame.r   zInterframe z is not fixed to body .)r    r#   r   r   r   r+   r   r%   
ang_vel_inr   r   set_vel)rA   r   
interframer   s       rL   r-   Joint._locate_joint_frame  s    Jj&))99"ii[$))J? : AJ J77BCC$$Z0A5{:,6L $vQ( ) )
A.rO   c                 L  ^ ^^^ UUUU 4S jnTS:X  a  SOSn/ nUc  / nO[        U5      (       d  U/n[        U5      S:X  d0  [        U5      T:X  d!  [        ST SU S[        U5       SU S	3	5      e[        U5       Ha  u  pU
c  UR	                  U" X-   5      5        M#  [        U
[        [        45      (       a  UR	                  U
5        MQ  [        S
U SU
 S35      e   [        [        U5      U-   TU-   5       H  n	UR	                  U" U	5      5        M     [        U5      $ )a-  Helper method for _generate_coordinates and _generate_speeds.

Parameters
==========

coordinates : iterable
    Iterable of coordinates or speeds that have been provided.
n_coords : Integer
    Number of coordinates that should be returned.
label : String, optional
    Coordinate type either 'q' (coordinates) or 'u' (speeds). The
    Default is 'q'.
offset : Integer
    Count offset when creating new dynamicsymbols. The default is 0.
number_single : Boolean
    Boolean whether if n_coords == 1, number should still be used. The
    default is False.

c                    > TS:X  a!  T(       d  [        T STR                   35      $ [        T U  STR                   35      $ )Nr   r!   )r   r+   )numberlabeln_coordsnumber_singlerA   s    rL   create_symbol2Joint._fill_coordinate_list.<locals>.create_symbol  sD    1}]%q&<==!UGF81TYYK"@AArO   qzgeneralized coordinatezgeneralized speedr   z	Expected  zs, instead got zs.zThe z" should have been a dynamicsymbol.)r   r   r   	enumerater   r#   r   r   r%   r   r   )rA   r:   r   r   offsetr   r   r+   generated_coordinatesr   coords   ` `` `     rL   _fill_coordinate_listJoint._fill_coordinate_list  sA   ,	B 	B
 ,1C<'=P "K+&&&-KK A%[)9X)Ey
!D6 #K 014&< = = "+.HA}%,,]1:-FGEL*#=>>%,,U3$tfAeW 51 !2 3 3 / s;'&0(V2CDA!((q)9: E+,,rO   )r(   r2   r,   r/   r5   r7   r=   r&   r'   r1   r*   r.   r4   r9   )
NNNNNNNNNN)NNrQ   )r   r   F)%__name__
__module____qualname____firstlineno____doc__rM   rS   rV   propertyr+   rB   rC   r:   r;   rg   rH   rI   rD   rE   rF   rG   r   r6   r8   r>   r?   r@   staticmethodr   r0   r   r   r<   r3   r-   r   __static_attributes__rv   rO   rL   r   r      s   rh FJHLEI8<S$j       ! !     ! !
    
 " " ! ! ' ' & &           ) )  0    AE.2g gR $ NO,1/-rO   r   c                   l   ^  \ rS rSrSr    SU 4S jjrS r\S 5       rS r	S r
S rS	 rS
 rSrU =r$ )r   i,  u  Pin (Revolute) Joint.

.. raw:: html
    :file: ../../../doc/src/explanation/modules/physics/mechanics/PinJoint.svg

Explanation
===========

A pin joint is defined such that the joint rotation axis is fixed in both
the child and parent and the location of the joint is relative to the mass
center of each body. The child rotates an angle, θ, from the parent about
the rotation axis and has a simple angular speed, ω, relative to the
parent. The direction cosine matrix between the child interframe and
parent interframe is formed using a simple rotation about the joint axis.
The page on the joints framework gives a more detailed explanation of the
intermediate frames.

Parameters
==========

name : string
    A unique name for the joint.
parent : Particle or RigidBody
    The parent body of joint.
child : Particle or RigidBody
    The child body of joint.
coordinates : dynamicsymbol, optional
    Generalized coordinates of the joint.
speeds : dynamicsymbol, optional
    Generalized speeds of joint.
parent_point : Point or Vector, optional
    Attachment point where the joint is fixed to the parent body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the parent's mass
    center.
child_point : Point or Vector, optional
    Attachment point where the joint is fixed to the child body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the child's mass
    center.
parent_axis : Vector, optional
    .. deprecated:: 1.12
        Axis fixed in the parent body which aligns with an axis fixed in the
        child body. The default is the x axis of parent's reference frame.
        For more information on this deprecation, see
        :ref:`deprecated-mechanics-joint-axis`.
child_axis : Vector, optional
    .. deprecated:: 1.12
        Axis fixed in the child body which aligns with an axis fixed in the
        parent body. The default is the x axis of child's reference frame.
        For more information on this deprecation, see
        :ref:`deprecated-mechanics-joint-axis`.
parent_interframe : ReferenceFrame, optional
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the parent's own frame.
child_interframe : ReferenceFrame, optional
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the child's own frame.
joint_axis : Vector
    The axis about which the rotation occurs. Note that the components
    of this axis are the same in the parent_interframe and child_interframe.
parent_joint_pos : Point or Vector, optional
    .. deprecated:: 1.12
        This argument is replaced by parent_point and will be removed in a
        future version.
        See :ref:`deprecated-mechanics-joint-pos` for more information.
child_joint_pos : Point or Vector, optional
    .. deprecated:: 1.12
        This argument is replaced by child_point and will be removed in a
        future version.
        See :ref:`deprecated-mechanics-joint-pos` for more information.

Attributes
==========

name : string
    The joint's name.
parent : Particle or RigidBody
    The joint's parent body.
child : Particle or RigidBody
    The joint's child body.
coordinates : Matrix
    Matrix of the joint's generalized coordinates. The default value is
    ``dynamicsymbols(f'q_{joint.name}')``.
speeds : Matrix
    Matrix of the joint's generalized speeds. The default value is
    ``dynamicsymbols(f'u_{joint.name}')``.
parent_point : Point
    Attachment point where the joint is fixed to the parent body.
child_point : Point
    Attachment point where the joint is fixed to the child body.
parent_axis : Vector
    The axis fixed in the parent frame that represents the joint.
child_axis : Vector
    The axis fixed in the child frame that represents the joint.
parent_interframe : ReferenceFrame
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated.
child_interframe : ReferenceFrame
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated.
joint_axis : Vector
    The axis about which the rotation occurs. Note that the components of
    this axis are the same in the parent_interframe and child_interframe.
kdes : Matrix
    Kinematical differential equations of the joint.

Examples
=========

A single pin joint is created from two bodies and has the following basic
attributes:

>>> from sympy.physics.mechanics import RigidBody, PinJoint
>>> parent = RigidBody('P')
>>> parent
P
>>> child = RigidBody('C')
>>> child
C
>>> joint = PinJoint('PC', parent, child)
>>> joint
PinJoint: PC  parent: P  child: C
>>> joint.name
'PC'
>>> joint.parent
P
>>> joint.child
C
>>> joint.parent_point
P_masscenter
>>> joint.child_point
C_masscenter
>>> joint.parent_axis
P_frame.x
>>> joint.child_axis
C_frame.x
>>> joint.coordinates
Matrix([[q_PC(t)]])
>>> joint.speeds
Matrix([[u_PC(t)]])
>>> child.frame.ang_vel_in(parent.frame)
u_PC(t)*P_frame.x
>>> child.frame.dcm(parent.frame)
Matrix([
[1,             0,            0],
[0,  cos(q_PC(t)), sin(q_PC(t))],
[0, -sin(q_PC(t)), cos(q_PC(t))]])
>>> joint.child_point.pos_from(joint.parent_point)
0

To further demonstrate the use of the pin joint, the kinematics of simple
double pendulum that rotates about the Z axis of each connected body can be
created as follows.

>>> from sympy import symbols, trigsimp
>>> from sympy.physics.mechanics import RigidBody, PinJoint
>>> l1, l2 = symbols('l1 l2')

First create bodies to represent the fixed ceiling and one to represent
each pendulum bob.

>>> ceiling = RigidBody('C')
>>> upper_bob = RigidBody('U')
>>> lower_bob = RigidBody('L')

The first joint will connect the upper bob to the ceiling by a distance of
``l1`` and the joint axis will be about the Z axis for each body.

>>> ceiling_joint = PinJoint('P1', ceiling, upper_bob,
... child_point=-l1*upper_bob.frame.x,
... joint_axis=ceiling.frame.z)

The second joint will connect the lower bob to the upper bob by a distance
of ``l2`` and the joint axis will also be about the Z axis for each body.

>>> pendulum_joint = PinJoint('P2', upper_bob, lower_bob,
... child_point=-l2*lower_bob.frame.x,
... joint_axis=upper_bob.frame.z)

Once the joints are established the kinematics of the connected bodies can
be accessed. First the direction cosine matrices of pendulum link relative
to the ceiling are found:

>>> upper_bob.frame.dcm(ceiling.frame)
Matrix([
[ cos(q_P1(t)), sin(q_P1(t)), 0],
[-sin(q_P1(t)), cos(q_P1(t)), 0],
[            0,            0, 1]])
>>> trigsimp(lower_bob.frame.dcm(ceiling.frame))
Matrix([
[ cos(q_P1(t) + q_P2(t)), sin(q_P1(t) + q_P2(t)), 0],
[-sin(q_P1(t) + q_P2(t)), cos(q_P1(t) + q_P2(t)), 0],
[                      0,                      0, 1]])

The position of the lower bob's masscenter is found with:

>>> lower_bob.masscenter.pos_from(ceiling.masscenter)
l1*U_frame.x + l2*L_frame.x

The angular velocities of the two pendulum links can be computed with
respect to the ceiling.

>>> upper_bob.frame.ang_vel_in(ceiling.frame)
u_P1(t)*C_frame.z
>>> lower_bob.frame.ang_vel_in(ceiling.frame)
u_P1(t)*C_frame.z + u_P2(t)*U_frame.z

And finally, the linear velocities of the two pendulum bobs can be computed
with respect to the ceiling.

>>> upper_bob.masscenter.vel(ceiling.frame)
l1*u_P1(t)*U_frame.y
>>> lower_bob.masscenter.vel(ceiling.frame)
l1*u_P1(t)*U_frame.y + l2*(u_P1(t) + u_P2(t))*L_frame.y

c                 >   > Xl         [        TU ]	  XX4XVXxU	XUU5        g rQ   _joint_axissuperrM   rA   r+   rB   rC   r:   r;   rD   rE   rF   rG   rH   rI   
joint_axisrJ   rK   	__class__s                  rL   rM   PinJoint.__init__  -    
 &u6$9I$2B(	*rO   c                 T    SU R                    SU R                   SU R                   3$ )Nz
PinJoint: 
  parent: 	  child: r+   rB   rC   rR   s    rL   rS   PinJoint.__str__  s/    TYYKz$++ ?**' 	(rO   c                     U R                   $ )z>Axis about which the child rotates with respect to the parent.r   rR   s    rL   r   PinJoint.joint_axis       rO   c                 (    U R                  USS5      $ Nr   r   r   rA   
coordinates     rL   r6   PinJoint._generate_coordinates      ))*a==rO   c                 (    U R                  USS5      $ Nr   ur   rA   speeds     rL   r8   PinJoint._generate_speeds"      ))%C88rO   c                     U R                  U R                  U R                  5      U l        U R                  R                  U R                  U R                  U R                  S   5        g Nr   )r0   r   rF   r   rG   r   r:   rR   s    rL   r>   PinJoint._orient_frames%  sP    ::doot7M7MN))""DOOT5E5Ea5H	JrO   c                     U R                   R                  U R                  U R                  S   U R                  R                  5       -  5        g r   )rG   r   rF   r;   r   	normalizerR   s    rL   r?   PinJoint._set_angular_velocity*  sC    ))$*@*@$++C**,C- 	.rO   c                 r   U R                   R                  U R                  S5        U R                  R                  U R                  S5        U R                   R                  U R
                  S5        U R                  R                  R                  U R                  U R                  U R
                  5        g r   	rE   set_posrD   r   r*   r,   rC   r   v2pt_theoryrR   s    rL   r@   PinJoint._set_linear_velocity.  s      !2!2A6!!$"4"4a8  !2!2A6

))$*;*;*.*<*<d>O>O	QrO   r   NNNNNNNNNNNr   r   r   r   r   rM   rS   r   r   r6   r8   r>   r?   r@   r   __classcell__r   s   @rL   r   r   ,  sY    \| FJHLEIIM	*(    >9J
.Q QrO   r   c                   l   ^  \ rS rSrSr    SU 4S jjrS r\S 5       rS r	S r
S rS	 rS
 rSrU =r$ )r   i6  a  Prismatic (Sliding) Joint.

.. image:: PrismaticJoint.svg

Explanation
===========

It is defined such that the child body translates with respect to the parent
body along the body-fixed joint axis. The location of the joint is defined
by two points, one in each body, which coincide when the generalized
coordinate is zero. The direction cosine matrix between the
parent_interframe and child_interframe is the identity matrix. Therefore,
the direction cosine matrix between the parent and child frames is fully
defined by the definition of the intermediate frames. The page on the joints
framework gives a more detailed explanation of the intermediate frames.

Parameters
==========

name : string
    A unique name for the joint.
parent : Particle or RigidBody
    The parent body of joint.
child : Particle or RigidBody
    The child body of joint.
coordinates : dynamicsymbol, optional
    Generalized coordinates of the joint. The default value is
    ``dynamicsymbols(f'q_{joint.name}')``.
speeds : dynamicsymbol, optional
    Generalized speeds of joint. The default value is
    ``dynamicsymbols(f'u_{joint.name}')``.
parent_point : Point or Vector, optional
    Attachment point where the joint is fixed to the parent body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the parent's mass
    center.
child_point : Point or Vector, optional
    Attachment point where the joint is fixed to the child body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the child's mass
    center.
parent_axis : Vector, optional
    .. deprecated:: 1.12
        Axis fixed in the parent body which aligns with an axis fixed in the
        child body. The default is the x axis of parent's reference frame.
        For more information on this deprecation, see
        :ref:`deprecated-mechanics-joint-axis`.
child_axis : Vector, optional
    .. deprecated:: 1.12
        Axis fixed in the child body which aligns with an axis fixed in the
        parent body. The default is the x axis of child's reference frame.
        For more information on this deprecation, see
        :ref:`deprecated-mechanics-joint-axis`.
parent_interframe : ReferenceFrame, optional
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the parent's own frame.
child_interframe : ReferenceFrame, optional
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the child's own frame.
joint_axis : Vector
    The axis along which the translation occurs. Note that the components
    of this axis are the same in the parent_interframe and child_interframe.
parent_joint_pos : Point or Vector, optional
    .. deprecated:: 1.12
        This argument is replaced by parent_point and will be removed in a
        future version.
        See :ref:`deprecated-mechanics-joint-pos` for more information.
child_joint_pos : Point or Vector, optional
    .. deprecated:: 1.12
        This argument is replaced by child_point and will be removed in a
        future version.
        See :ref:`deprecated-mechanics-joint-pos` for more information.

Attributes
==========

name : string
    The joint's name.
parent : Particle or RigidBody
    The joint's parent body.
child : Particle or RigidBody
    The joint's child body.
coordinates : Matrix
    Matrix of the joint's generalized coordinates.
speeds : Matrix
    Matrix of the joint's generalized speeds.
parent_point : Point
    Attachment point where the joint is fixed to the parent body.
child_point : Point
    Attachment point where the joint is fixed to the child body.
parent_axis : Vector
    The axis fixed in the parent frame that represents the joint.
child_axis : Vector
    The axis fixed in the child frame that represents the joint.
parent_interframe : ReferenceFrame
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated.
child_interframe : ReferenceFrame
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated.
kdes : Matrix
    Kinematical differential equations of the joint.

Examples
=========

A single prismatic joint is created from two bodies and has the following
basic attributes:

>>> from sympy.physics.mechanics import RigidBody, PrismaticJoint
>>> parent = RigidBody('P')
>>> parent
P
>>> child = RigidBody('C')
>>> child
C
>>> joint = PrismaticJoint('PC', parent, child)
>>> joint
PrismaticJoint: PC  parent: P  child: C
>>> joint.name
'PC'
>>> joint.parent
P
>>> joint.child
C
>>> joint.parent_point
P_masscenter
>>> joint.child_point
C_masscenter
>>> joint.parent_axis
P_frame.x
>>> joint.child_axis
C_frame.x
>>> joint.coordinates
Matrix([[q_PC(t)]])
>>> joint.speeds
Matrix([[u_PC(t)]])
>>> child.frame.ang_vel_in(parent.frame)
0
>>> child.frame.dcm(parent.frame)
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
>>> joint.child_point.pos_from(joint.parent_point)
q_PC(t)*P_frame.x

To further demonstrate the use of the prismatic joint, the kinematics of two
masses sliding, one moving relative to a fixed body and the other relative
to the moving body. about the X axis of each connected body can be created
as follows.

>>> from sympy.physics.mechanics import PrismaticJoint, RigidBody

First create bodies to represent the fixed ceiling and one to represent
a particle.

>>> wall = RigidBody('W')
>>> Part1 = RigidBody('P1')
>>> Part2 = RigidBody('P2')

The first joint will connect the particle to the ceiling and the
joint axis will be about the X axis for each body.

>>> J1 = PrismaticJoint('J1', wall, Part1)

The second joint will connect the second particle to the first particle
and the joint axis will also be about the X axis for each body.

>>> J2 = PrismaticJoint('J2', Part1, Part2)

Once the joint is established the kinematics of the connected bodies can
be accessed. First the direction cosine matrices of Part relative
to the ceiling are found:

>>> Part1.frame.dcm(wall.frame)
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])

>>> Part2.frame.dcm(wall.frame)
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])

The position of the particles' masscenter is found with:

>>> Part1.masscenter.pos_from(wall.masscenter)
q_J1(t)*W_frame.x

>>> Part2.masscenter.pos_from(wall.masscenter)
q_J1(t)*W_frame.x + q_J2(t)*P1_frame.x

The angular velocities of the two particle links can be computed with
respect to the ceiling.

>>> Part1.frame.ang_vel_in(wall.frame)
0

>>> Part2.frame.ang_vel_in(wall.frame)
0

And finally, the linear velocities of the two particles can be computed
with respect to the ceiling.

>>> Part1.masscenter.vel(wall.frame)
u_J1(t)*W_frame.x

>>> Part2.masscenter.vel(wall.frame)
u_J1(t)*W_frame.x + Derivative(q_J2(t), t)*P1_frame.x

c                 >   > Xl         [        TU ]	  XX4XVXxU	XUU5        g rQ   r   r   s                  rL   rM   PrismaticJoint.__init__  r   rO   c                 T    SU R                    SU R                   SU R                   3$ )NzPrismaticJoint: r   r   r   rR   s    rL   rS   PrismaticJoint.__str__  0    "499+Z} E**' 	(rO   c                     U R                   $ )zAAxis along which the child translates with respect to the parent.r   rR   s    rL   r   PrismaticJoint.joint_axis!  r   rO   c                 (    U R                  USS5      $ r   r   r   s     rL   r6   $PrismaticJoint._generate_coordinates&  r   rO   c                 (    U R                  USS5      $ r   r   r   s     rL   r8   PrismaticJoint._generate_speeds)  r   rO   c                     U R                  U R                  U R                  5      U l        U R                  R                  U R                  U R                  S5        g r   )r0   r   rF   r   rG   r   rR   s    rL   r>   PrismaticJoint._orient_frames,  sD    ::doot7M7MN))""DOOQ	8rO   c                 P    U R                   R                  U R                  S5        g r   rG   r   rF   rR   s    rL   r?   $PrismaticJoint._set_angular_velocity1      ))$*@*@!DrO   c                 (   U R                   R                  5       nU R                  R                  U R                  U R
                  S   U-  5        U R                  R                  U R                  S5        U R                  R                  U R                  S5        U R                  R                  U R                  U R                  S   U-  5        U R                  R                  R                  U R                  U R                  S   U-  5        g r   )r   r   rE   r   rD   r:   r   r*   r,   r;   rC   r   )rA   r   s     rL   r@   #PrismaticJoint._set_linear_velocity4  s    ((*  !2!2D4D4DQ4G$4NO!!$"4"4a8  !2!2A6  !3!3T[[^d5JK

%%d&8&8$++a.4:OPrO   r   r  r  r  s   @rL   r   r   6  sY    Yv FJHLEIIM	*(    >98
EQ QrO   r   c                      ^  \ rS rSrSr     SU 4S jjrS r\S 5       r\S 5       r	\S 5       r
\S 5       r\S	 5       rS
 rS rS rS rS rSrU =r$ )r   i=  a  Cylindrical Joint.

.. image:: CylindricalJoint.svg
    :align: center
    :width: 600

Explanation
===========

A cylindrical joint is defined such that the child body both rotates about
and translates along the body-fixed joint axis with respect to the parent
body. The joint axis is both the rotation axis and translation axis. The
location of the joint is defined by two points, one in each body, which
coincide when the generalized coordinate corresponding to the translation is
zero. The direction cosine matrix between the child interframe and parent
interframe is formed using a simple rotation about the joint axis. The page
on the joints framework gives a more detailed explanation of the
intermediate frames.

Parameters
==========

name : string
    A unique name for the joint.
parent : Particle or RigidBody
    The parent body of joint.
child : Particle or RigidBody
    The child body of joint.
rotation_coordinate : dynamicsymbol, optional
    Generalized coordinate corresponding to the rotation angle. The default
    value is ``dynamicsymbols(f'q0_{joint.name}')``.
translation_coordinate : dynamicsymbol, optional
    Generalized coordinate corresponding to the translation distance. The
    default value is ``dynamicsymbols(f'q1_{joint.name}')``.
rotation_speed : dynamicsymbol, optional
    Generalized speed corresponding to the angular velocity. The default
    value is ``dynamicsymbols(f'u0_{joint.name}')``.
translation_speed : dynamicsymbol, optional
    Generalized speed corresponding to the translation velocity. The default
    value is ``dynamicsymbols(f'u1_{joint.name}')``.
parent_point : Point or Vector, optional
    Attachment point where the joint is fixed to the parent body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the parent's mass
    center.
child_point : Point or Vector, optional
    Attachment point where the joint is fixed to the child body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the child's mass
    center.
parent_interframe : ReferenceFrame, optional
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the parent's own frame.
child_interframe : ReferenceFrame, optional
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the child's own frame.
joint_axis : Vector, optional
    The rotation as well as translation axis. Note that the components of
    this axis are the same in the parent_interframe and child_interframe.

Attributes
==========

name : string
    The joint's name.
parent : Particle or RigidBody
    The joint's parent body.
child : Particle or RigidBody
    The joint's child body.
rotation_coordinate : dynamicsymbol
    Generalized coordinate corresponding to the rotation angle.
translation_coordinate : dynamicsymbol
    Generalized coordinate corresponding to the translation distance.
rotation_speed : dynamicsymbol
    Generalized speed corresponding to the angular velocity.
translation_speed : dynamicsymbol
    Generalized speed corresponding to the translation velocity.
coordinates : Matrix
    Matrix of the joint's generalized coordinates.
speeds : Matrix
    Matrix of the joint's generalized speeds.
parent_point : Point
    Attachment point where the joint is fixed to the parent body.
child_point : Point
    Attachment point where the joint is fixed to the child body.
parent_interframe : ReferenceFrame
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated.
child_interframe : ReferenceFrame
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated.
kdes : Matrix
    Kinematical differential equations of the joint.
joint_axis : Vector
    The axis of rotation and translation.

Examples
=========

A single cylindrical joint is created between two bodies and has the
following basic attributes:

>>> from sympy.physics.mechanics import RigidBody, CylindricalJoint
>>> parent = RigidBody('P')
>>> parent
P
>>> child = RigidBody('C')
>>> child
C
>>> joint = CylindricalJoint('PC', parent, child)
>>> joint
CylindricalJoint: PC  parent: P  child: C
>>> joint.name
'PC'
>>> joint.parent
P
>>> joint.child
C
>>> joint.parent_point
P_masscenter
>>> joint.child_point
C_masscenter
>>> joint.parent_axis
P_frame.x
>>> joint.child_axis
C_frame.x
>>> joint.coordinates
Matrix([
[q0_PC(t)],
[q1_PC(t)]])
>>> joint.speeds
Matrix([
[u0_PC(t)],
[u1_PC(t)]])
>>> child.frame.ang_vel_in(parent.frame)
u0_PC(t)*P_frame.x
>>> child.frame.dcm(parent.frame)
Matrix([
[1,              0,             0],
[0,  cos(q0_PC(t)), sin(q0_PC(t))],
[0, -sin(q0_PC(t)), cos(q0_PC(t))]])
>>> joint.child_point.pos_from(joint.parent_point)
q1_PC(t)*P_frame.x
>>> child.masscenter.vel(parent.frame)
u1_PC(t)*P_frame.x

To further demonstrate the use of the cylindrical joint, the kinematics of
two cylindrical joints perpendicular to each other can be created as follows.

>>> from sympy import symbols
>>> from sympy.physics.mechanics import RigidBody, CylindricalJoint
>>> r, l, w = symbols('r l w')

First create bodies to represent the fixed floor with a fixed pole on it.
The second body represents a freely moving tube around that pole. The third
body represents a solid flag freely translating along and rotating around
the Y axis of the tube.

>>> floor = RigidBody('floor')
>>> tube = RigidBody('tube')
>>> flag = RigidBody('flag')

The first joint will connect the first tube to the floor with it translating
along and rotating around the Z axis of both bodies.

>>> floor_joint = CylindricalJoint('C1', floor, tube, joint_axis=floor.z)

The second joint will connect the tube perpendicular to the flag along the Y
axis of both the tube and the flag, with the joint located at a distance
``r`` from the tube's center of mass and a combination of the distances
``l`` and ``w`` from the flag's center of mass.

>>> flag_joint = CylindricalJoint('C2', tube, flag,
...                               parent_point=r * tube.y,
...                               child_point=-w * flag.y + l * flag.z,
...                               joint_axis=tube.y)

Once the joints are established the kinematics of the connected bodies can
be accessed. First the direction cosine matrices of both the body and the
flag relative to the floor are found:

>>> tube.frame.dcm(floor.frame)
Matrix([
[ cos(q0_C1(t)), sin(q0_C1(t)), 0],
[-sin(q0_C1(t)), cos(q0_C1(t)), 0],
[             0,             0, 1]])
>>> flag.frame.dcm(floor.frame)
Matrix([
[cos(q0_C1(t))*cos(q0_C2(t)), sin(q0_C1(t))*cos(q0_C2(t)), -sin(q0_C2(t))],
[             -sin(q0_C1(t)),               cos(q0_C1(t)),              0],
[sin(q0_C2(t))*cos(q0_C1(t)), sin(q0_C1(t))*sin(q0_C2(t)),  cos(q0_C2(t))]])

The position of the flag's center of mass is found with:

>>> flag.masscenter.pos_from(floor.masscenter)
q1_C1(t)*floor_frame.z + (r + q1_C2(t))*tube_frame.y + w*flag_frame.y - l*flag_frame.z

The angular velocities of the two tubes can be computed with respect to the
floor.

>>> tube.frame.ang_vel_in(floor.frame)
u0_C1(t)*floor_frame.z
>>> flag.frame.ang_vel_in(floor.frame)
u0_C1(t)*floor_frame.z + u0_C2(t)*tube_frame.y

Finally, the linear velocities of the two tube centers of mass can be
computed with respect to the floor, while expressed in the tube's frame.

>>> tube.masscenter.vel(floor.frame).to_matrix(tube.frame)
Matrix([
[       0],
[       0],
[u1_C1(t)]])
>>> flag.masscenter.vel(floor.frame).to_matrix(tube.frame).simplify()
Matrix([
[-l*u0_C2(t)*cos(q0_C2(t)) - r*u0_C1(t) - w*u0_C1(t) - q1_C2(t)*u0_C1(t)],
[                    -l*u0_C1(t)*sin(q0_C2(t)) + Derivative(q1_C2(t), t)],
[                                    l*u0_C2(t)*sin(q0_C2(t)) + u1_C1(t)]])

c                 B   > Xl         XE4nXg4n[        TU ]	  XX=UXU
US9	  g NrF   rG   r   )rA   r+   rB   rC   rotation_coordinatetranslation_coordinaterotation_speedtranslation_speedrD   rE   rF   rG   r   r:   r;   r   s                  rL   rM   CylindricalJoint.__init__  s<    
 &*C 4u6%+<*: 	 	<rO   c                 T    SU R                    SU R                   SU R                   3$ )NzCylindricalJoint: r   r   r   rR   s    rL   rS   CylindricalJoint.__str__,  s0    $TYYKz$++ G**' 	(rO   c                     U R                   $ )z?Axis about and along which the rotation and translation occurs.r   rR   s    rL   r   CylindricalJoint.joint_axis0  r   rO   c                      U R                   S   $ z;Generalized coordinate corresponding to the rotation angle.r   r:   rR   s    rL   r  $CylindricalJoint.rotation_coordinate5       ""rO   c                      U R                   S   $ )zAGeneralized coordinate corresponding to the translation distance.r   r*  rR   s    rL   r   'CylindricalJoint.translation_coordinate:  r,  rO   c                      U R                   S   $ z8Generalized speed corresponding to the angular velocity.r   r;   rR   s    rL   r!  CylindricalJoint.rotation_speed?       {{1~rO   c                      U R                   S   $ )z<Generalized speed corresponding to the translation velocity.r   r1  rR   s    rL   r"  "CylindricalJoint.translation_speedD  r3  rO   c                 (    U R                  USS5      $ )Nr   r   r   rw   s     rL   r6   &CylindricalJoint._generate_coordinatesI      ))+q#>>rO   c                 (    U R                  USS5      $ )Nr   r   r   r{   s     rL   r8   !CylindricalJoint._generate_speedsL  s    ))&!S99rO   c                     U R                  U R                  U R                  5      U l        U R                  R                  U R                  U R                  U R                  5        g rQ   )r0   r   rF   r   rG   r   r  rR   s    rL   r>   CylindricalJoint._orient_framesO  sK    ::doot7M7MN))""DOOT5M5M	OrO   c                     U R                   R                  U R                  U R                  U R                  R                  5       -  5        g rQ   )rG   r   rF   r!  r   r   rR   s    rL   r?   &CylindricalJoint._set_angular_velocityT  s:    ))""$//";";"==	?rO   c                 R   U R                   R                  U R                  U R                  U R                  R                  5       -  5        U R                  R                  U R                  S5        U R                   R                  U R                  S5        U R                   R                  U R                  U R                  U R                  R                  5       -  5        U R                  R                  R                  U R                   U R                  U R                  5        g r   )rE   r   rD   r   r   r   r   r*   r,   r"  rC   r   r  rG   rR   s    rL   r@   %CylindricalJoint._set_linear_velocityY  s      ''$//*C*C*EE	G 	!!$"4"4a8  !2!2A6  ""T__%>%>%@@	B 	

))$*:*:D<N<N*.*?*?	ArO   r   )	NNNNNNNNN)r   r   r   r   r   rM   rS   r   r   r  r   r!  r"  r6   r8   r>   r?   r@   r   r  r  s   @rL   r   r   =  s    _B AE=AHL:> 	<(     # # # #    ?:O
?

A 
ArO   r   c                      ^  \ rS rSrSr    SU 4S jjrS r\S 5       r\S 5       r	\S 5       r
\S 5       r\S	 5       r\S
 5       rS rS rS rS rS rSrU =r$ )r   if  a'  Planar Joint.

.. raw:: html
    :file: ../../../doc/src/modules/physics/mechanics/api/PlanarJoint.svg

Explanation
===========

A planar joint is defined such that the child body translates over a fixed
plane of the parent body as well as rotate about the rotation axis, which
is perpendicular to that plane. The origin of this plane is the
``parent_point`` and the plane is spanned by two nonparallel planar vectors.
The location of the ``child_point`` is based on the planar vectors
($\vec{v}_1$, $\vec{v}_2$) and generalized coordinates ($q_1$, $q_2$),
i.e. $\vec{r} = q_1 \hat{v}_1 + q_2 \hat{v}_2$. The direction cosine
matrix between the ``child_interframe`` and ``parent_interframe`` is formed
using a simple rotation ($q_0$) about the rotation axis.

In order to simplify the definition of the ``PlanarJoint``, the
``rotation_axis`` and ``planar_vectors`` are set to be the unit vectors of
the ``parent_interframe`` according to the table below. This ensures that
you can only define these vectors by creating a separate frame and supplying
that as the interframe. If you however would only like to supply the normals
of the plane with respect to the parent and child bodies, then you can also
supply those to the ``parent_interframe`` and ``child_interframe``
arguments. An example of both of these cases is in the examples section
below and the page on the joints framework provides a more detailed
explanation of the intermediate frames.

.. list-table::

    * - ``rotation_axis``
      - ``parent_interframe.x``
    * - ``planar_vectors[0]``
      - ``parent_interframe.y``
    * - ``planar_vectors[1]``
      - ``parent_interframe.z``

Parameters
==========

name : string
    A unique name for the joint.
parent : Particle or RigidBody
    The parent body of joint.
child : Particle or RigidBody
    The child body of joint.
rotation_coordinate : dynamicsymbol, optional
    Generalized coordinate corresponding to the rotation angle. The default
    value is ``dynamicsymbols(f'q0_{joint.name}')``.
planar_coordinates : iterable of dynamicsymbols, optional
    Two generalized coordinates used for the planar translation. The default
    value is ``dynamicsymbols(f'q1_{joint.name} q2_{joint.name}')``.
rotation_speed : dynamicsymbol, optional
    Generalized speed corresponding to the angular velocity. The default
    value is ``dynamicsymbols(f'u0_{joint.name}')``.
planar_speeds : dynamicsymbols, optional
    Two generalized speeds used for the planar translation velocity. The
    default value is ``dynamicsymbols(f'u1_{joint.name} u2_{joint.name}')``.
parent_point : Point or Vector, optional
    Attachment point where the joint is fixed to the parent body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the parent's mass
    center.
child_point : Point or Vector, optional
    Attachment point where the joint is fixed to the child body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the child's mass
    center.
parent_interframe : ReferenceFrame, optional
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the parent's own frame.
child_interframe : ReferenceFrame, optional
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the child's own frame.

Attributes
==========

name : string
    The joint's name.
parent : Particle or RigidBody
    The joint's parent body.
child : Particle or RigidBody
    The joint's child body.
rotation_coordinate : dynamicsymbol
    Generalized coordinate corresponding to the rotation angle.
planar_coordinates : Matrix
    Two generalized coordinates used for the planar translation.
rotation_speed : dynamicsymbol
    Generalized speed corresponding to the angular velocity.
planar_speeds : Matrix
    Two generalized speeds used for the planar translation velocity.
coordinates : Matrix
    Matrix of the joint's generalized coordinates.
speeds : Matrix
    Matrix of the joint's generalized speeds.
parent_point : Point
    Attachment point where the joint is fixed to the parent body.
child_point : Point
    Attachment point where the joint is fixed to the child body.
parent_interframe : ReferenceFrame
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated.
child_interframe : ReferenceFrame
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated.
kdes : Matrix
    Kinematical differential equations of the joint.
rotation_axis : Vector
    The axis about which the rotation occurs.
planar_vectors : list
    The vectors that describe the planar translation directions.

Examples
=========

A single planar joint is created between two bodies and has the following
basic attributes:

>>> from sympy.physics.mechanics import RigidBody, PlanarJoint
>>> parent = RigidBody('P')
>>> parent
P
>>> child = RigidBody('C')
>>> child
C
>>> joint = PlanarJoint('PC', parent, child)
>>> joint
PlanarJoint: PC  parent: P  child: C
>>> joint.name
'PC'
>>> joint.parent
P
>>> joint.child
C
>>> joint.parent_point
P_masscenter
>>> joint.child_point
C_masscenter
>>> joint.rotation_axis
P_frame.x
>>> joint.planar_vectors
[P_frame.y, P_frame.z]
>>> joint.rotation_coordinate
q0_PC(t)
>>> joint.planar_coordinates
Matrix([
[q1_PC(t)],
[q2_PC(t)]])
>>> joint.coordinates
Matrix([
[q0_PC(t)],
[q1_PC(t)],
[q2_PC(t)]])
>>> joint.rotation_speed
u0_PC(t)
>>> joint.planar_speeds
Matrix([
[u1_PC(t)],
[u2_PC(t)]])
>>> joint.speeds
Matrix([
[u0_PC(t)],
[u1_PC(t)],
[u2_PC(t)]])
>>> child.frame.ang_vel_in(parent.frame)
u0_PC(t)*P_frame.x
>>> child.frame.dcm(parent.frame)
Matrix([
[1,              0,             0],
[0,  cos(q0_PC(t)), sin(q0_PC(t))],
[0, -sin(q0_PC(t)), cos(q0_PC(t))]])
>>> joint.child_point.pos_from(joint.parent_point)
q1_PC(t)*P_frame.y + q2_PC(t)*P_frame.z
>>> child.masscenter.vel(parent.frame)
u1_PC(t)*P_frame.y + u2_PC(t)*P_frame.z

To further demonstrate the use of the planar joint, the kinematics of a
block sliding on a slope, can be created as follows.

>>> from sympy import symbols
>>> from sympy.physics.mechanics import PlanarJoint, RigidBody, ReferenceFrame
>>> a, d, h = symbols('a d h')

First create bodies to represent the slope and the block.

>>> ground = RigidBody('G')
>>> block = RigidBody('B')

To define the slope you can either define the plane by specifying the
``planar_vectors`` or/and the ``rotation_axis``. However it is advisable to
create a rotated intermediate frame, so that the ``parent_vectors`` and
``rotation_axis`` will be the unit vectors of this intermediate frame.

>>> slope = ReferenceFrame('A')
>>> slope.orient_axis(ground.frame, ground.y, a)

The planar joint can be created using these bodies and intermediate frame.
We can specify the origin of the slope to be ``d`` above the slope's center
of mass and the block's center of mass to be a distance ``h`` above the
slope's surface. Note that we can specify the normal of the plane using the
rotation axis argument.

>>> joint = PlanarJoint('PC', ground, block, parent_point=d * ground.x,
...                     child_point=-h * block.x, parent_interframe=slope)

Once the joint is established the kinematics of the bodies can be accessed.
First the ``rotation_axis``, which is normal to the plane and the
``plane_vectors``, can be found.

>>> joint.rotation_axis
A.x
>>> joint.planar_vectors
[A.y, A.z]

The direction cosine matrix of the block with respect to the ground can be
found with:

>>> block.frame.dcm(ground.frame)
Matrix([
[              cos(a),              0,              -sin(a)],
[sin(a)*sin(q0_PC(t)),  cos(q0_PC(t)), sin(q0_PC(t))*cos(a)],
[sin(a)*cos(q0_PC(t)), -sin(q0_PC(t)), cos(a)*cos(q0_PC(t))]])

The angular velocity of the block can be computed with respect to the
ground.

>>> block.frame.ang_vel_in(ground.frame)
u0_PC(t)*A.x

The position of the block's center of mass can be found with:

>>> block.masscenter.pos_from(ground.masscenter)
d*G_frame.x + h*B_frame.x + q1_PC(t)*A.y + q2_PC(t)*A.z

Finally, the linear velocity of the block's center of mass can be
computed with respect to the ground.

>>> block.masscenter.vel(ground.frame)
u1_PC(t)*A.y + u2_PC(t)*A.z

In some cases it could be your preference to only define the normals of the
plane with respect to both bodies. This can most easily be done by supplying
vectors to the ``interframe`` arguments. What will happen in this case is
that an interframe will be created with its ``x`` axis aligned with the
provided vector. For a further explanation of how this is done see the notes
of the ``Joint`` class. In the code below, the above example (with the block
on the slope) is recreated by supplying vectors to the interframe arguments.
Note that the previously described option is however more computationally
efficient, because the algorithm now has to compute the rotation angle
between the provided vector and the 'x' axis.

>>> from sympy import symbols, cos, sin
>>> from sympy.physics.mechanics import PlanarJoint, RigidBody
>>> a, d, h = symbols('a d h')
>>> ground = RigidBody('G')
>>> block = RigidBody('B')
>>> joint = PlanarJoint(
...     'PC', ground, block, parent_point=d * ground.x,
...     child_point=-h * block.x, child_interframe=block.x,
...     parent_interframe=cos(a) * ground.x + sin(a) * ground.z)
>>> block.frame.dcm(ground.frame).simplify()
Matrix([
[               cos(a),              0,               sin(a)],
[-sin(a)*sin(q0_PC(t)),  cos(q0_PC(t)), sin(q0_PC(t))*cos(a)],
[-sin(a)*cos(q0_PC(t)), -sin(q0_PC(t)), cos(a)*cos(q0_PC(t))]])

c                 6   > XE4nXg4n[         TU ]  XX<UXU
US9	  g r  )r   rM   )rA   r+   rB   rC   r  planar_coordinatesr!  planar_speedsrD   rE   rF   rG   r:   r;   r   s                 rL   rM   PlanarJoint.__init__y  s6     +? 0u6%+<*: 	 	<rO   c                 T    SU R                    SU R                   SU R                   3$ )NzPlanarJoint: r   r   r   rR   s    rL   rS   PlanarJoint.__str__  s0    		{*T[[M B**' 	(rO   c                      U R                   S   $ r)  r*  rR   s    rL   r  PlanarJoint.rotation_coordinate  r,  rO   c                 (    U R                   SS2S4   $ )z<Two generalized coordinates used for the planar translation.r   Nr   r*  rR   s    rL   rC  PlanarJoint.planar_coordinates  s     A&&rO   c                      U R                   S   $ r0  r1  rR   s    rL   r!  PlanarJoint.rotation_speed  r3  rO   c                 (    U R                   SS2S4   $ )z@Two generalized speeds used for the planar translation velocity.r   Nr   r1  rR   s    rL   rD  PlanarJoint.planar_speeds  s     {{12q5!!rO   c                 .    U R                   R                  $ )z)The axis about which the rotation occurs.)rF   r   rR   s    rL   r   PlanarJoint.rotation_axis  s     %%'''rO   c                 Z    U R                   R                  U R                   R                  /$ )z<The vectors that describe the planar translation directions.)rF   r   r   rR   s    rL   planar_vectorsPlanarJoint.planar_vectors  s'     &&(($*@*@*B*BCCrO   c                 |    U R                  US   SSSS9nU R                  US   SSS5      nUR                  U5      $ )Nr   r   r   Tr   r   r   col_join)rA   r:   r!  rD  s       rL   r6   !PlanarJoint._generate_coordinates  sP    33KNAsBF 4 H22;q>1c1M&&}55rO   c                 |    U R                  US   SSSS9nU R                  US   SSS5      nUR                  U5      $ )Nr   r   r   TrV  r   rW  )rA   r;   r!  rD  s       rL   r8   PlanarJoint._generate_speeds  sP    33F1Iq#BF 4 H226!9aaH&&}55rO   c                 z    U R                   R                  U R                  U R                  U R                  5        g rQ   )rG   r   rF   r   r  rR   s    rL   r>   PlanarJoint._orient_frames  s0    ))""D$6$6$$	&rO   c                 ~    U R                   R                  U R                  U R                  U R                  -  5        g rQ   )rG   r   rF   r!  r   rR   s    rL   r?   !PlanarJoint._set_angular_velocity  s3    ))""$"4"44	6rO   c                    U R                   R                  U R                  U R                  S   U R                  S   -  U R                  S   U R                  S   -  -   5        U R                  R                  U R                  S5        U R                   R                  U R                  S5        U R                   R                  U R                  U R                  S   U R                  S   -  U R                  S   U R                  S   -  -   5        U R                  R                  R                  U R                   U R                  U R                  5        g )Nr   r   )rE   r   rD   rC  rS  r   rF   rG   r*   rD  rC   r   r  r,   rR   s    rL   r@    PlanarJoint._set_linear_velocity  s,     ##A&)<)<Q)??##A&)<)<Q)??@	A 	!!$"8"8!<  !6!6:   2 21 58K8KA8N Nq!D$7$7$::!;	< 	

))$*:*:D<N<N*.*;*;	=rO   rv   )NNNNNNNN)r   r   r   r   r   rM   rS   r   r  rC  r!  rD  r   rS  r6   r8   r>   r?   r@   r   r  r  s   @rL   r   r   f  s    Pd AE9=DH:><( # # ' '   " " ( ( D D66&
6
= =rO   r   c                   \   ^  \ rS rSrSr    SU 4S jjrS rS rS rS r	S r
S	 rS
rU =r$ )r   i  a  Spherical (Ball-and-Socket) Joint.

.. image:: SphericalJoint.svg
    :align: center
    :width: 600

Explanation
===========

A spherical joint is defined such that the child body is free to rotate in
any direction, without allowing a translation of the ``child_point``. As can
also be seen in the image, the ``parent_point`` and ``child_point`` are
fixed on top of each other, i.e. the ``joint_point``. This rotation is
defined using the :func:`parent_interframe.orient(child_interframe,
rot_type, amounts, rot_order)
<sympy.physics.vector.frame.ReferenceFrame.orient>` method. The default
rotation consists of three relative rotations, i.e. body-fixed rotations.
Based on the direction cosine matrix following from these rotations, the
angular velocity is computed based on the generalized coordinates and
generalized speeds.

Parameters
==========

name : string
    A unique name for the joint.
parent : Particle or RigidBody
    The parent body of joint.
child : Particle or RigidBody
    The child body of joint.
coordinates: iterable of dynamicsymbols, optional
    Generalized coordinates of the joint.
speeds : iterable of dynamicsymbols, optional
    Generalized speeds of joint.
parent_point : Point or Vector, optional
    Attachment point where the joint is fixed to the parent body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the parent's mass
    center.
child_point : Point or Vector, optional
    Attachment point where the joint is fixed to the child body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the child's mass
    center.
parent_interframe : ReferenceFrame, optional
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the parent's own frame.
child_interframe : ReferenceFrame, optional
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the child's own frame.
rot_type : str, optional
    The method used to generate the direction cosine matrix. Supported
    methods are:

    - ``'Body'``: three successive rotations about new intermediate axes,
      also called "Euler and Tait-Bryan angles"
    - ``'Space'``: three successive rotations about the parent frames' unit
      vectors

    The default method is ``'Body'``.
amounts :
    Expressions defining the rotation angles or direction cosine matrix.
    These must match the ``rot_type``. See examples below for details. The
    input types are:

    - ``'Body'``: 3-tuple of expressions, symbols, or functions
    - ``'Space'``: 3-tuple of expressions, symbols, or functions

    The default amounts are the given ``coordinates``.
rot_order : str or int, optional
    If applicable, the order of the successive of rotations. The string
    ``'123'`` and integer ``123`` are equivalent, for example. Required for
    ``'Body'`` and ``'Space'``. The default value is ``123``.

Attributes
==========

name : string
    The joint's name.
parent : Particle or RigidBody
    The joint's parent body.
child : Particle or RigidBody
    The joint's child body.
coordinates : Matrix
    Matrix of the joint's generalized coordinates.
speeds : Matrix
    Matrix of the joint's generalized speeds.
parent_point : Point
    Attachment point where the joint is fixed to the parent body.
child_point : Point
    Attachment point where the joint is fixed to the child body.
parent_interframe : ReferenceFrame
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated.
child_interframe : ReferenceFrame
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated.
kdes : Matrix
    Kinematical differential equations of the joint.

Examples
=========

A single spherical joint is created from two bodies and has the following
basic attributes:

>>> from sympy.physics.mechanics import RigidBody, SphericalJoint
>>> parent = RigidBody('P')
>>> parent
P
>>> child = RigidBody('C')
>>> child
C
>>> joint = SphericalJoint('PC', parent, child)
>>> joint
SphericalJoint: PC  parent: P  child: C
>>> joint.name
'PC'
>>> joint.parent
P
>>> joint.child
C
>>> joint.parent_point
P_masscenter
>>> joint.child_point
C_masscenter
>>> joint.parent_interframe
P_frame
>>> joint.child_interframe
C_frame
>>> joint.coordinates
Matrix([
[q0_PC(t)],
[q1_PC(t)],
[q2_PC(t)]])
>>> joint.speeds
Matrix([
[u0_PC(t)],
[u1_PC(t)],
[u2_PC(t)]])
>>> child.frame.ang_vel_in(parent.frame).to_matrix(child.frame)
Matrix([
[ u0_PC(t)*cos(q1_PC(t))*cos(q2_PC(t)) + u1_PC(t)*sin(q2_PC(t))],
[-u0_PC(t)*sin(q2_PC(t))*cos(q1_PC(t)) + u1_PC(t)*cos(q2_PC(t))],
[                             u0_PC(t)*sin(q1_PC(t)) + u2_PC(t)]])
>>> child.frame.x.to_matrix(parent.frame)
Matrix([
[                                            cos(q1_PC(t))*cos(q2_PC(t))],
[sin(q0_PC(t))*sin(q1_PC(t))*cos(q2_PC(t)) + sin(q2_PC(t))*cos(q0_PC(t))],
[sin(q0_PC(t))*sin(q2_PC(t)) - sin(q1_PC(t))*cos(q0_PC(t))*cos(q2_PC(t))]])
>>> joint.child_point.pos_from(joint.parent_point)
0

To further demonstrate the use of the spherical joint, the kinematics of a
spherical joint with a ZXZ rotation can be created as follows.

>>> from sympy import symbols
>>> from sympy.physics.mechanics import RigidBody, SphericalJoint
>>> l1 = symbols('l1')

First create bodies to represent the fixed floor and a pendulum bob.

>>> floor = RigidBody('F')
>>> bob = RigidBody('B')

The joint will connect the bob to the floor, with the joint located at a
distance of ``l1`` from the child's center of mass and the rotation set to a
body-fixed ZXZ rotation.

>>> joint = SphericalJoint('S', floor, bob, child_point=l1 * bob.y,
...                        rot_type='body', rot_order='ZXZ')

Now that the joint is established, the kinematics of the connected body can
be accessed.

The position of the bob's masscenter is found with:

>>> bob.masscenter.pos_from(floor.masscenter)
- l1*B_frame.y

The angular velocities of the pendulum link can be computed with respect to
the floor.

>>> bob.frame.ang_vel_in(floor.frame).to_matrix(
...     floor.frame).simplify()
Matrix([
[u1_S(t)*cos(q0_S(t)) + u2_S(t)*sin(q0_S(t))*sin(q1_S(t))],
[u1_S(t)*sin(q0_S(t)) - u2_S(t)*sin(q1_S(t))*cos(q0_S(t))],
[                          u0_S(t) + u2_S(t)*cos(q1_S(t))]])

Finally, the linear velocity of the bob's center of mass can be computed.

>>> bob.masscenter.vel(floor.frame).to_matrix(bob.frame)
Matrix([
[                           l1*(u0_S(t)*cos(q1_S(t)) + u2_S(t))],
[                                                             0],
[-l1*(u0_S(t)*sin(q1_S(t))*sin(q2_S(t)) + u1_S(t)*cos(q2_S(t)))]])

c                 N   > Xl         Xl        Xl        [        TU ]  XX4UXgUU	S9	  g r  )	_rot_type_amounts
_rot_orderr   rM   )rA   r+   rB   rC   r:   r;   rD   rE   rF   rG   rot_typeamounts	rot_orderr   s                rL   rM   SphericalJoint.__init__  s5     "#u6%+<*: 	 	<rO   c                 T    SU R                    SU R                   SU R                   3$ )NzSphericalJoint: r   r   r   rR   s    rL   rS   SphericalJoint.__str__  r  rO   c                 (    U R                  USS5      $ )N   r   r   rw   s     rL   r6   $SphericalJoint._generate_coordinates  r8  rO   c                 N    U R                  U[        U R                  5      S5      $ )Nr   )r   r   r:   r{   s     rL   r8   SphericalJoint._generate_speeds  s"    ))&#d6F6F2GMMrO   c                 :   SnU R                   R                  5       U;  a  [        SU R                    SU 35      eU R                  c  U R                  OU R                  nU R
                  R                  U R                  U R                   X R                  5        g )N)BODYSPACEzRotation type "z6" is not implemented. Implemented rotation types are: )	rd  upperNotImplementedErrorre  r:   rG   orientrF   rf  )rA   supported_rot_typesrh  s      rL   r>   SphericalJoint._orient_frames  s    />>!)<<%!$..!1 233F2GIJ J '+mm&;$""$$T%;%;T^^%,oo	?rO   c           	      j   [         R                  nU R                  R                  U R                  5      R                  [        U R                  U R                  5       VVs0 s H  u  p#UR                  U5      U_M     snn5      nU R                  R                  U R                  U5        g s  snnf rQ   )r   r   rG   r   rF   xreplacezipr:   r;   r   r   )rA   r   r   r   vels        rL   r?   $SphericalJoint._set_angular_velocity  s    ##..t/E/EFOO&)$*:*:DKK&HI&HdaQVVAY\&HI
 	))$*@*@#F Js   "B/
c                 r   U R                   R                  U R                  S5        U R                  R                  U R                  S5        U R                   R                  U R
                  S5        U R                  R                  R                  U R                  U R                  U R
                  5        g r   r   rR   s    rL   r@   #SphericalJoint._set_linear_velocity  s      !2!2A6!!$"4"4a8  !2!2A6

))$*;*;T=O=O*.*;*;	=rO   )re  rf  rd  )	NNNNNNrs  N{   r   r   r   r   r   rM   rS   r6   r8   r>   r?   r@   r   r  r  s   @rL   r   r     sD    JV FJHLAE
<(?N?G= =rO   r   c                   X   ^  \ rS rSrSr  SU 4S jjrS rS rS rS r	S r
S	 rS
rU =r$ )r   i  a  Weld Joint.

.. raw:: html
    :file: ../../../doc/src/modules/physics/mechanics/api/WeldJoint.svg

Explanation
===========

A weld joint is defined such that there is no relative motion between the
child and parent bodies. The direction cosine matrix between the attachment
frame (``parent_interframe`` and ``child_interframe``) is the identity
matrix and the attachment points (``parent_point`` and ``child_point``) are
coincident. The page on the joints framework gives a more detailed
explanation of the intermediate frames.

Parameters
==========

name : string
    A unique name for the joint.
parent : Particle or RigidBody
    The parent body of joint.
child : Particle or RigidBody
    The child body of joint.
parent_point : Point or Vector, optional
    Attachment point where the joint is fixed to the parent body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the parent's mass
    center.
child_point : Point or Vector, optional
    Attachment point where the joint is fixed to the child body. If a
    vector is provided, then the attachment point is computed by adding the
    vector to the body's mass center. The default value is the child's mass
    center.
parent_interframe : ReferenceFrame, optional
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the parent's own frame.
child_interframe : ReferenceFrame, optional
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated. If a Vector is provided then an interframe
    is created which aligns its X axis with the given vector. The default
    value is the child's own frame.

Attributes
==========

name : string
    The joint's name.
parent : Particle or RigidBody
    The joint's parent body.
child : Particle or RigidBody
    The joint's child body.
coordinates : Matrix
    Matrix of the joint's generalized coordinates. The default value is
    ``dynamicsymbols(f'q_{joint.name}')``.
speeds : Matrix
    Matrix of the joint's generalized speeds. The default value is
    ``dynamicsymbols(f'u_{joint.name}')``.
parent_point : Point
    Attachment point where the joint is fixed to the parent body.
child_point : Point
    Attachment point where the joint is fixed to the child body.
parent_interframe : ReferenceFrame
    Intermediate frame of the parent body with respect to which the joint
    transformation is formulated.
child_interframe : ReferenceFrame
    Intermediate frame of the child body with respect to which the joint
    transformation is formulated.
kdes : Matrix
    Kinematical differential equations of the joint.

Examples
=========

A single weld joint is created from two bodies and has the following basic
attributes:

>>> from sympy.physics.mechanics import RigidBody, WeldJoint
>>> parent = RigidBody('P')
>>> parent
P
>>> child = RigidBody('C')
>>> child
C
>>> joint = WeldJoint('PC', parent, child)
>>> joint
WeldJoint: PC  parent: P  child: C
>>> joint.name
'PC'
>>> joint.parent
P
>>> joint.child
C
>>> joint.parent_point
P_masscenter
>>> joint.child_point
C_masscenter
>>> joint.coordinates
Matrix(0, 0, [])
>>> joint.speeds
Matrix(0, 0, [])
>>> child.frame.ang_vel_in(parent.frame)
0
>>> child.frame.dcm(parent.frame)
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
>>> joint.child_point.pos_from(joint.parent_point)
0

To further demonstrate the use of the weld joint, two relatively-fixed
bodies rotated by a quarter turn about the Y axis can be created as follows:

>>> from sympy import symbols, pi
>>> from sympy.physics.mechanics import ReferenceFrame, RigidBody, WeldJoint
>>> l1, l2 = symbols('l1 l2')

First create the bodies to represent the parent and rotated child body.

>>> parent = RigidBody('P')
>>> child = RigidBody('C')

Next the intermediate frame specifying the fixed rotation with respect to
the parent can be created.

>>> rotated_frame = ReferenceFrame('Pr')
>>> rotated_frame.orient_axis(parent.frame, parent.y, pi / 2)

The weld between the parent body and child body is located at a distance
``l1`` from the parent's center of mass in the X direction and ``l2`` from
the child's center of mass in the child's negative X direction.

>>> weld = WeldJoint('weld', parent, child, parent_point=l1 * parent.x,
...                  child_point=-l2 * child.x,
...                  parent_interframe=rotated_frame)

Now that the joint has been established, the kinematics of the bodies can be
accessed. The direction cosine matrix of the child body with respect to the
parent can be found:

>>> child.frame.dcm(parent.frame)
Matrix([
[0, 0, -1],
[0, 1,  0],
[1, 0,  0]])

As can also been seen from the direction cosine matrix, the parent X axis is
aligned with the child's Z axis:
>>> parent.x == child.z
True

The position of the child's center of mass with respect to the parent's
center of mass can be found with:

>>> child.masscenter.pos_from(parent.masscenter)
l1*P_frame.x + l2*C_frame.x

The angular velocity of the child with respect to the parent is 0 as one
would expect.

>>> child.frame.ang_vel_in(parent.frame)
0

c                 d   > [         TU ]  XU/ / UXVUS9	  [        SS/ 5      R                  U l        g )Nr  r   r   )r   rM   r   Tr=   )	rA   r+   rB   rC   rD   rE   rF   rG   r   s	           rL   rM   WeldJoint.__init__p  s=    ub"l$*: 	 	< Aq"%''
rO   c                 T    SU R                    SU R                   SU R                   3$ )NzWeldJoint: r   r   r   rR   s    rL   rS   WeldJoint.__str__w  s0    dii[
4;;- @**' 	(rO   c                     [        5       $ rQ   r   r   s     rL   r6   WeldJoint._generate_coordinates{  	    xrO   c                     [        5       $ rQ   r  r   s     rL   r8   WeldJoint._generate_speeds~  r  rO   c                 z    U R                   R                  U R                  U R                  R                  S5        g r   )rG   r   rF   r   rR   s    rL   r>   WeldJoint._orient_frames  s0    ))$*@*@*.*@*@*B*BA	GrO   c                 P    U R                   R                  U R                  S5        g r   r  rR   s    rL   r?   WeldJoint._set_angular_velocity  r  rO   c                 H   U R                   R                  U R                  S5        U R                  R                  U R                  S5        U R                   R                  U R
                  S5        U R                  R                  R                  U R                  S5        g r   )rE   r   rD   r   r*   r,   rC   r   rR   s    rL   r@   WeldJoint._set_linear_velocity  sv      !2!2A6!!$"4"4a8  !2!2A6

%%d&8&8!<rO   rf   )NNNNr  r  s   @rL   r   r     s>    fP LP:>((GE= =rO   r   N)abcr   r   sympyr   r   r   sympy.core.functionr   !sympy.physics.mechanics.body_baser	   !sympy.physics.mechanics.functionsr
   sympy.physics.vectorr   r   r   r   r   sympy.utilities.iterablesr   sympy.utilities.exceptionsr   __all__r   r   r   r   r   r   r   rv   rO   rL   <module>r     s    $ ( ( , 6 C2 2 . @9W-C W-tGQu GQTDQU DQNfAu fAR	c=% c=Lx=U x=vE= E=rO   