
    \h:                       S 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
  SSKJr  SSKJr  SSK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JrJrJr  SSKJrJ r   SSK!J"r"  SSK#J$r$J%r%  SSK&J'r'J(r(  SSK)J*r*  SSK+J,r,  SSK-J.r.  SSK/J0r0  SSK1J2r2  SSK3J4r4  SSK5J6r6J7r7  SSK8r8\9" S5       V s/ s H  n \" S5      PM     sn u  r:r; " S S\ 5      r< " S S\<5      r= " S  S!\<5      r> " S" S#\<5      r? " S$ S%\<5      r@ " S& S'\@\=5      rA " S( S)\@\>5      rB " S* S+\@\?5      rC " S, S-\<5      rD " S. S/\D\=5      rE " S0 S1\D\>5      rF " S2 S3\D\?5      rGgs  sn f )4zLine-like geometrical entities.

Contains
========
LinearEntity
Line
Ray
Segment
LinearEntity2D
Line2D
Ray2D
Segment2D
LinearEntity3D
Line3D
Ray3D
Segment3D

    )Tuple)N)Expr)RationalooFloat)Eq)S)ordered)_symbolDummyuniquely_named_symbol)sympify)	Piecewise)	_pi_coeffacostanatan2   )GeometryEntityGeometrySet)GeometryError)PointPoint3D)findintersection)And)Matrix)Intersectionsimplify)solve)linear_coeffs)Undecidable
filldedentN   
line_dummyc                       \ rS rSrSrSS jrS rS r\S 5       r	S r
S	 rSS
 jr\S 5       rS r\S 5       rS rS rS rS r\S 5       r\S 5       r\S 5       rS rS rS r\S 5       rS rSS jrS rSrg)LinearEntity2   a.  A base class for all linear entities (Line, Ray and Segment)
in n-dimensional Euclidean space.

Attributes
==========

ambient_dimension
direction
length
p1
p2
points

Notes
=====

This is an abstract class and is not meant to be instantiated.

See Also
========

sympy.geometry.entity.GeometryEntity

Nc                     [         R                  " X5      u  pX:X  a  [        SU R                  -  5      e[	        U5      [	        U5      :w  a  [        SU R                  -  5      e[
        R                  " XU40 UD6$ )N&%s.__new__ requires two unique Points.z2%s.__new__ requires two Points of equal dimension.)r   _normalize_dimension
ValueError__name__lenr   __new__clsp1p2kwargss       K/var/www/auris/envauris/lib/python3.13/site-packages/sympy/geometry/line.pyr1   LinearEntity.__new__K   s{    ++B38 83<<GI Ir7c"gDs||SU U %%cr<V<<    c                 V    U R                  U5      nUb  U$ [        SU < SU< S35      e)zuReturn a definitive answer or else raise an error if it cannot
be determined that other is on the boundaries of self.zCannot decide whether 'z' contains '')containsr$   )selfotherresults      r7   __contains__LinearEntity.__contains__X   s4     u%M>BEJL Lr9   c                     U R                   U:X  a  gXR                   -
  nU R                  nUR                  U5      S:  a  gg)zTest whether the point `other` lies in the positive span of `self`.
A point x is 'in front' of a point y if x.dot(y) >= 0.  Return
-1 if `other` is behind `self.p1`, 0 if `other` is `self.p1` and
and 1 if `other` is in front of `self.p1`.r   r   )r4   	directiondot)r=   r>   rel_posds       r7   
_span_testLinearEntity._span_testc   s=    
 77e''/NN55>Ar9   c                 ,    [        U R                  5      $ )a  A property method that returns the dimension of LinearEntity
object.

Parameters
==========

p1 : LinearEntity

Returns
=======

dimension : integer

Examples
========

>>> from sympy import Point, Line
>>> p1, p2 = Point(0, 0), Point(1, 1)
>>> l1 = Line(p1, p2)
>>> l1.ambient_dimension
2

>>> from sympy import Point, Line
>>> p1, p2 = Point(0, 0, 0), Point(1, 1, 1)
>>> l1 = Line(p1, p2)
>>> l1.ambient_dimension
3

)r0   r4   r=   s    r7   ambient_dimensionLinearEntity.ambient_dimensionq   s    > 477|r9   c                     [        U [        5      (       d   [        U[        5      (       d  [        S5      eU R                  UR                  p2[	        UR                  U5      [        U5      [        U5      -  -  5      $ )a  Return the non-reflex angle formed by rays emanating from
the origin with directions the same as the direction vectors
of the linear entities.

Parameters
==========

l1 : LinearEntity
l2 : LinearEntity

Returns
=======

angle : angle in radians

Notes
=====

From the dot product of vectors v1 and v2 it is known that:

    ``dot(v1, v2) = |v1|*|v2|*cos(A)``

where A is the angle formed between the two vectors. We can
get the directional vectors of the two lines and readily
find the angle between the two using the above formula.

See Also
========

is_perpendicular, Ray2D.closing_angle

Examples
========

>>> from sympy import Line
>>> e = Line((0, 0), (1, 0))
>>> ne = Line((0, 0), (1, 1))
>>> sw = Line((1, 1), (0, 0))
>>> ne.angle_between(e)
pi/4
>>> sw.angle_between(e)
3*pi/4

To obtain the non-obtuse angle at the intersection of lines, use
the ``smallest_angle_between`` method:

>>> sw.smallest_angle_between(e)
pi/4

>>> from sympy import Point3D, Line3D
>>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(-1, 2, 0)
>>> l1, l2 = Line3D(p1, p2), Line3D(p2, p3)
>>> l1.angle_between(l2)
acos(-sqrt(2)/3)
>>> l1.smallest_angle_between(l2)
acos(sqrt(2)/3)
#Must pass only LinearEntity objects)
isinstancer)   	TypeErrorrD   r   rE   absl1l2v1v2s       r7   angle_betweenLinearEntity.angle_between   s]    t "l++Jr<4P4PABBr||BBFF2JBB011r9   c                    [        U [        5      (       d   [        U[        5      (       d  [        S5      eU R                  UR                  p2[	        [        UR                  U5      5      [        U5      [        U5      -  -  5      $ )a  Return the smallest angle formed at the intersection of the
lines containing the linear entities.

Parameters
==========

l1 : LinearEntity
l2 : LinearEntity

Returns
=======

angle : angle in radians

Examples
========

>>> from sympy import Point, Line
>>> p1, p2, p3 = Point(0, 0), Point(0, 4), Point(2, -2)
>>> l1, l2 = Line(p1, p2), Line(p1, p3)
>>> l1.smallest_angle_between(l2)
pi/4

See Also
========

angle_between, is_perpendicular, Ray2D.closing_angle
rO   )rP   r)   rQ   rD   r   rR   rE   rS   s       r7   smallest_angle_between#LinearEntity.smallest_angle_between   s`    : "l++Jr<4P4PABBr||BCr
OSWSW_566r9   c                     [        USS9nUR                  S U R                   5       ;   a!  [        [	        SUR                  -  5      5      eU R
                  U R                  U R
                  -
  U-  -   $ )a;  A parameterized point on the Line.

Parameters
==========

parameter : str, optional
    The name of the parameter which will be used for the parametric
    point. The default value is 't'. When this parameter is 0, the
    first point used to define the line will be returned, and when
    it is 1 the second point will be returned.

Returns
=======

point : Point

Raises
======

ValueError
    When ``parameter`` already appears in the Line's definition.

See Also
========

sympy.geometry.point.Point

Examples
========

>>> from sympy import Point, Line
>>> p1, p2 = Point(1, 0), Point(5, 3)
>>> l1 = Line(p1, p2)
>>> l1.arbitrary_point()
Point2D(4*t + 1, 3*t)
>>> from sympy import Point3D, Line3D
>>> p1, p2 = Point3D(1, 0, 0), Point3D(5, 3, 1)
>>> l1 = Line3D(p1, p2)
>>> l1.arbitrary_point()
Point3D(4*t + 1, 3*t, t)

Trealc              3   8   #    U  H  oR                   v   M     g 7fN)name).0fs     r7   	<genexpr>/LinearEntity.arbitrary_point.<locals>.<genexpr>!  s     8&7ff&7s   zx
                Symbol %s already appears in object
                and cannot be used as a parameter.
                )r   rb   free_symbolsr.   r%   r4   r5   r=   	parameterts      r7   arbitrary_pointLinearEntity.arbitrary_point   ss    V ID)668d&7&788Z ) ff)    ww$''DGG+Q...r9   c                  V    [        U 6 nUR                  (       a  [        U5      S:X  a  gg)a  Is a sequence of linear entities concurrent?

Two or more linear entities are concurrent if they all
intersect at a single point.

Parameters
==========

lines
    A sequence of linear entities.

Returns
=======

True : if the set of linear entities intersect in one point
False : otherwise.

See Also
========

sympy.geometry.util.intersection

Examples
========

>>> from sympy import Point, Line
>>> p1, p2 = Point(0, 0), Point(3, 5)
>>> p3, p4 = Point(-2, -2), Point(0, 2)
>>> l1, l2, l3 = Line(p1, p2), Line(p1, p3), Line(p1, p4)
>>> Line.are_concurrent(l1, l2, l3)
True
>>> l4 = Line(p2, p3)
>>> Line.are_concurrent(l2, l3, l4)
False
>>> from sympy import Point3D, Line3D
>>> p1, p2 = Point3D(0, 0, 0), Point3D(3, 5, 2)
>>> p3, p4 = Point3D(-2, -2, -2), Point3D(0, 2, 1)
>>> l1, l2, l3 = Line3D(p1, p2), Line3D(p1, p3), Line3D(p1, p4)
>>> Line3D.are_concurrent(l1, l2, l3)
True
>>> l4 = Line3D(p2, p3)
>>> Line3D.are_concurrent(l2, l3, l4)
False

r   TF)r   is_FiniteSetr0   )linescommon_pointss     r7   are_concurrentLinearEntity.are_concurrent*  s*    ^ %e,%%#m*<*Ar9   c                     [        5       e)zSubclasses should implement this method and should return
True if other is on the boundaries of self;
False if not on the boundaries of self;
None if a determination cannot be made.)NotImplementedErrorr=   r>   s     r7   r<   LinearEntity.contains^  s    
 "##r9   c                 4    U R                   U R                  -
  $ )a  The direction vector of the LinearEntity.

Returns
=======

p : a Point; the ray from the origin to this point is the
    direction of `self`

Examples
========

>>> from sympy import Line
>>> a, b = (1, 1), (1, 3)
>>> Line(a, b).direction
Point2D(0, 2)
>>> Line(b, a).direction
Point2D(0, -2)

This can be reported so the distance from the origin is 1:

>>> Line(b, a).direction.unit
Point2D(0, -1)

See Also
========

sympy.geometry.point.Point.unit

)r5   r4   rK   s    r7   rD   LinearEntity.directione  s    > ww  r9   c                    S nS nS n[        U[        5      (       d  [        XR                  S9nUR                  (       a  U R                  U5      (       a  U/$ / $ [        U[        5      (       Ga  [        R                  " U R                  U R                  UR                  UR                  5      n[        R                  " U6 nUS:X  a  [        U [        5      (       a  U/$ [        U[        5      (       a  U /$ [        U [        5      (       a  [        U[        5      (       a  U" X5      $ [        U [        5      (       a  [        U[        5      (       a  U" X5      $ [        U [        5      (       a  [        U[        5      (       a  U" X5      $ [        U [        5      (       a  [        U[        5      (       a  U" X5      $ GO0US:X  Ga'  [        USS 6 n[        USS 6 nUR                  R                  UR                  5      (       a  / $ [!        UR                  UR                  * /5      R#                  5       n	[!        UR                  UR                  -
  /5      R#                  5       n
U	R%                  SU
5      R'                  SS	9u  p[)        U5      S:w  a  [+        S
R-                  X5      5      eUS   nUR                  U-  U R                  -   n[        U [        5      (       a  [        U[        5      (       a  U/$ [        U [        5      (       d  U R                  U5      (       a  UR                  U5      (       a  U/$ U R/                  [0        5      (       d  UR/                  [0        5      (       d  / $ [3        U R5                  [6        5      UR5                  [8        5      -
  [6        [8        SS9S   nS nU" U[6           U 5      (       a  U" U[8           U5      (       a  U/$ / $ / $ UR;                  U 5      $ )a
  The intersection with another geometrical entity.

Parameters
==========

o : Point or LinearEntity

Returns
=======

intersection : list of geometrical entities

See Also
========

sympy.geometry.point.Point

Examples
========

>>> from sympy import Point, Line, Segment
>>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(7, 7)
>>> l1 = Line(p1, p2)
>>> l1.intersection(p3)
[Point2D(7, 7)]
>>> p4, p5 = Point(5, 0), Point(0, 3)
>>> l2 = Line(p4, p5)
>>> l1.intersection(l2)
[Point2D(15/8, 15/8)]
>>> p6, p7 = Point(0, 5), Point(2, 6)
>>> s1 = Segment(p6, p7)
>>> l1.intersection(s1)
[]
>>> from sympy import Point3D, Line3D, Segment3D
>>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(7, 7, 7)
>>> l1 = Line3D(p1, p2)
>>> l1.intersection(p3)
[Point3D(7, 7, 7)]
>>> l1 = Line3D(Point3D(4,19,12), Point3D(5,25,17))
>>> l2 = Line3D(Point3D(-3, -15, -19), direction_ratio=[2,8,8])
>>> l1.intersection(l2)
[Point3D(1, 1, -3)]
>>> p6, p7 = Point3D(0, 5, 2), Point3D(2, 6, 3)
>>> s1 = Segment3D(p6, p7)
>>> l1.intersection(s1)
[]

c                 L   U R                   R                  UR                   5      S:  a%  U R                  UR                  5      S:  a  U/$ U /$ U R                  UR                  5      nUS:  a  / $ US:X  a  UR                  /$ [	        U R                  UR                  5      /$ Nr   )rD   rE   rH   r4   Segment)ray1ray2sts      r7   intersect_parallel_rays:LinearEntity.intersection.<locals>.intersect_parallel_rays  s    ~~!!$..1A5 "&!9Q!>vJTFJ __TWW-6I1W GG9$122r9   c                 6   U R                  UR                  5      U R                  UR                  5      p2US:  a  US:  a  / $ US:  a	  US:  a  U/$ US:  a!  [        U R                  UR                  5      /$ [        U R                  UR                  5      /$ r{   )rH   r4   r5   r|   )raysegst1st2s       r7   "intersect_parallel_ray_and_segmentELinearEntity.intersection.<locals>.intersect_parallel_ray_and_segment  s    ~~cff-s~~cff/EQw37	cQhu/00/00r9   c                    U R                  U5      (       a  U/$ UR                  U 5      (       a  U /$ U R                  R                  UR                  5      S:  a   [        UR                  UR
                  5      nU R                  UR
                  5      S:  a  XpUR                  U R                  5      S:  a  / $ [        UR
                  U R                  5      /$ r{   )r<   rD   rE   r|   r5   r4   rH   )seg1seg2s     r7   intersect_parallel_segments>LinearEntity.intersection.<locals>.intersect_parallel_segments  s    }}T""v}}T""v ~~!!$..1A5tww0tww'!+!dtww'!+	DGGTWW-..r9   dimr   r&   NTr    z+Failed when solving Mx=b when M={} and b={})r   r&   )dictr   c                     [        U[        5      (       a  g[        U[        5      (       a  U R                  $ [        U[        5      (       a"  U R                  =(       a    SU -
  R                  $ [        S5      e)NTr   zunexpected line type)rP   LineRayis_nonnegativer|   r.   )pls     r7   ok%LinearEntity.intersection.<locals>.ok'  s_    !!T**#!!S)) ///!!W-- //JQU4J4JJ$%;<<r9   )rP   r   r   rL   is_Pointr<   r)   r-   r4   r5   affine_rankr   r   r|   rD   is_scalar_multipler   	transpose
col_insertrrefr0   r   formatatomsr   r"   rk   rj   ur   )r=   r>   r   r   r   ptsrankrT   rU   mvm_rrefpivotscoeffline_intersectiontur   s                    r7   r   LinearEntity.intersection  sK   b	3		1	/  %00%%;%;<E>>}}U##w	|,, ,,TWWdgguxxRC$$c*DqydD))!7NeT** 6MdC((Zs-C-C24??dC((Zw-G-G=dJJdG,,E31G1G=eJJdG,,E71K1K6tCC3r7^3qr7^
 <<222<<@@I BLL2<<-89CCEBEEBEEM?+557 "#a!3!8!8$!8!Gv;!#'(U(\(\]^(bcct$&LL$6$@! dD))j.E.E-..d++]]#455'899-..zz%((U1C1C I
 4//2U5J5J15MMqt%%&(
= beT??r"Q%'7'7-..	 	!!$''r9   c                     [        U [        5      (       d   [        U[        5      (       d  [        S5      eU R                  R	                  UR                  5      $ )a  Are two linear entities parallel?

Parameters
==========

l1 : LinearEntity
l2 : LinearEntity

Returns
=======

True : if l1 and l2 are parallel,
False : otherwise.

See Also
========

coefficients

Examples
========

>>> from sympy import Point, Line
>>> p1, p2 = Point(0, 0), Point(1, 1)
>>> p3, p4 = Point(3, 4), Point(6, 7)
>>> l1, l2 = Line(p1, p2), Line(p3, p4)
>>> Line.is_parallel(l1, l2)
True
>>> p5 = Point(6, 6)
>>> l3 = Line(p3, p5)
>>> Line.is_parallel(l1, l3)
False
>>> from sympy import Point3D, Line3D
>>> p1, p2 = Point3D(0, 0, 0), Point3D(3, 4, 5)
>>> p3, p4 = Point3D(2, 1, 1), Point3D(8, 9, 11)
>>> l1, l2 = Line3D(p1, p2), Line3D(p3, p4)
>>> Line3D.is_parallel(l1, l2)
True
>>> p5 = Point3D(6, 6, 6)
>>> l3 = Line3D(p3, p5)
>>> Line3D.is_parallel(l1, l3)
False

rO   )rP   r)   rQ   rD   r   rT   rU   s     r7   is_parallelLinearEntity.is_parallel;  sC    Z "l++Jr<4P4PABB||..r||<<r9   c                     [        U [        5      (       d   [        U[        5      (       d  [        S5      e[        R                  R                  U R                  R                  UR                  5      5      $ )a  Are two linear entities perpendicular?

Parameters
==========

l1 : LinearEntity
l2 : LinearEntity

Returns
=======

True : if l1 and l2 are perpendicular,
False : otherwise.

See Also
========

coefficients

Examples
========

>>> from sympy import Point, Line
>>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(-1, 1)
>>> l1, l2 = Line(p1, p2), Line(p1, p3)
>>> l1.is_perpendicular(l2)
True
>>> p4 = Point(5, 3)
>>> l3 = Line(p1, p4)
>>> l1.is_perpendicular(l3)
False
>>> from sympy import Point3D, Line3D
>>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(-1, 2, 0)
>>> l1, l2 = Line3D(p1, p2), Line3D(p2, p3)
>>> l1.is_perpendicular(l2)
False
>>> p4 = Point3D(5, 3, 7)
>>> l3 = Line3D(p1, p4)
>>> l1.is_perpendicular(l3)
False

rO   )rP   r)   rQ   r
   ZeroequalsrD   rE   r   s     r7   is_perpendicularLinearEntity.is_perpendicularm  sP    V "l++Jr<4P4PABBvv}}R\\--bll;<<r9   c                 d    [        U R                  U R                  5      nUR                  U5      $ )z
Return True if self and other are contained in the same line.

Examples
========

>>> from sympy import Point, Line
>>> p1, p2, p3 = Point(0, 1), Point(3, 4), Point(2, 3)
>>> l1 = Line(p1, p2)
>>> l2 = Line(p1, p3)
>>> l1.is_similar(l2)
True
)r   r4   r5   r<   )r=   r>   r   s      r7   
is_similarLinearEntity.is_similar  s'     $''"zz%  r9   c                 "    [         R                  $ )z
The length of the line.

Examples
========

>>> from sympy import Point, Line
>>> p1, p2 = Point(0, 0), Point(3, 5)
>>> l1 = Line(p1, p2)
>>> l1.length
oo
)r
   InfinityrK   s    r7   lengthLinearEntity.length  s     zzr9   c                      U R                   S   $ )zThe first defining point of a linear entity.

See Also
========

sympy.geometry.point.Point

Examples
========

>>> from sympy import Point, Line
>>> p1, p2 = Point(0, 0), Point(5, 3)
>>> l = Line(p1, p2)
>>> l.p1
Point2D(0, 0)

r   argsrK   s    r7   r4   LinearEntity.p1      & yy|r9   c                      U R                   S   $ )zThe second defining point of a linear entity.

See Also
========

sympy.geometry.point.Point

Examples
========

>>> from sympy import Point, Line
>>> p1, p2 = Point(0, 0), Point(5, 3)
>>> l = Line(p1, p2)
>>> l.p2
Point2D(5, 3)

r   r   rK   s    r7   r5   LinearEntity.p2  r   r9   c                 X    [        XR                  S9n[        XU R                  -   5      $ )aW  Create a new Line parallel to this linear entity which passes
through the point `p`.

Parameters
==========

p : Point

Returns
=======

line : Line

See Also
========

is_parallel

Examples
========

>>> from sympy import Point, Line
>>> p1, p2, p3 = Point(0, 0), Point(2, 3), Point(-2, 2)
>>> l1 = Line(p1, p2)
>>> l2 = l1.parallel_line(p3)
>>> p3 in l2
True
>>> l1.is_parallel(l2)
True
>>> from sympy import Point3D, Line3D
>>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(2, 3, 4), Point3D(-2, 2, 0)
>>> l1 = Line3D(p1, p2)
>>> l2 = l1.parallel_line(p3)
>>> p3 in l2
True
>>> l1.is_parallel(l2)
True

r   )r   rL   r   rD   r=   r   s     r7   parallel_lineLinearEntity.parallel_line  s)    P !//0A4>>)**r9   c                     [        XR                  S9nX;   a  XR                  R                  -   n[	        XR                  U5      5      $ )a  Create a new Line perpendicular to this linear entity which passes
through the point `p`.

Parameters
==========

p : Point

Returns
=======

line : Line

See Also
========

sympy.geometry.line.LinearEntity.is_perpendicular, perpendicular_segment

Examples
========

>>> from sympy import Point3D, Line3D
>>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(2, 3, 4), Point3D(-2, 2, 0)
>>> L = Line3D(p1, p2)
>>> P = L.perpendicular_line(p3); P
Line3D(Point3D(-2, 2, 0), Point3D(4/29, 6/29, 8/29))
>>> L.is_perpendicular(P)
True

In 3D the, the first point used to define the line is the point
through which the perpendicular was required to pass; the
second point is (arbitrarily) contained in the given line:

>>> P.p2 in L
True
r   )r   rL   rD   orthogonal_directionr   
projectionr   s     r7   perpendicular_lineLinearEntity.perpendicular_line  s@    J !//09NN777AAq)**r9   c                     [        XR                  S9nX;   a  U$ U R                  U5      n[        [	        U R
                  U R                  5      U5      u  n[        X5      $ )a  Create a perpendicular line segment from `p` to this line.

The endpoints of the segment are ``p`` and the closest point in
the line containing self. (If self is not a line, the point might
not be in self.)

Parameters
==========

p : Point

Returns
=======

segment : Segment

Notes
=====

Returns `p` itself if `p` is on this linear entity.

See Also
========

perpendicular_line

Examples
========

>>> from sympy import Point, Line
>>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(0, 2)
>>> l1 = Line(p1, p2)
>>> s1 = l1.perpendicular_segment(p3)
>>> l1.is_perpendicular(s1)
True
>>> p3 in s1
True
>>> l1.perpendicular_segment(Point(4, 0))
Segment2D(Point2D(4, 0), Point2D(2, 2))
>>> from sympy import Point3D, Line3D
>>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(0, 2, 0)
>>> l1 = Line3D(p1, p2)
>>> s1 = l1.perpendicular_segment(p3)
>>> l1.is_perpendicular(s1)
True
>>> p3 in s1
True
>>> l1.perpendicular_segment(Point3D(4, 0, 0))
Segment3D(Point3D(4, 0, 0), Point3D(4/3, 4/3, 4/3))

r   )r   rL   r   r   r   r4   r5   r|   r=   r   r   r5   s       r7   perpendicular_segment"LinearEntity.perpendicular_segment=  sV    h !//09H##A&4115q~r9   c                 2    U R                   U R                  4$ )a.  The two points used to define this linear entity.

Returns
=======

points : tuple of Points

See Also
========

sympy.geometry.point.Point

Examples
========

>>> from sympy import Point, Line
>>> p1, p2 = Point(0, 0), Point(5, 11)
>>> l1 = Line(p1, p2)
>>> l1.points
(Point2D(0, 0), Point2D(5, 11))

)r4   r5   rK   s    r7   pointsLinearEntity.pointsz  s    0 !!r9   c                   ^  [        U[        5      (       d  [        UT R                  S9nU 4S jn[        U[        5      (       a  U" U5      $ [        U[        5      (       a  U" UR
                  5      U" UR                  5      pCX4:X  a  U$ UR                  X45      n[        T U5      nUR                  (       a  U$ UR                  (       a  [        U5      S:X  a  Uu  nU$ T R                  R                  UR                  5      S:  a  UR                  u  p4UR                  XC5      nU$ [!        SU< ST < 35      e)a~  Project a point, line, ray, or segment onto this linear entity.

Parameters
==========

other : Point or LinearEntity (Line, Ray, Segment)

Returns
=======

projection : Point or LinearEntity (Line, Ray, Segment)
    The return type matches the type of the parameter ``other``.

Raises
======

GeometryError
    When method is unable to perform projection.

Notes
=====

A projection involves taking the two points that define
the linear entity and projecting those points onto a
Line and then reforming the linear entity using these
projections.
A point P is projected onto a line L by finding the point
on L that is closest to P. This point is the intersection
of L and the line perpendicular to L that passes through P.

See Also
========

sympy.geometry.point.Point, perpendicular_line

Examples
========

>>> from sympy import Point, Line, Segment, Rational
>>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(Rational(1, 2), 0)
>>> l1 = Line(p1, p2)
>>> l1.projection(p3)
Point2D(1/4, 1/4)
>>> p4, p5 = Point(10, 0), Point(12, 1)
>>> s1 = Segment(p4, p5)
>>> l1.projection(s1)
Segment2D(Point2D(5, 5), Point2D(13/2, 13/2))
>>> p1, p2, p3 = Point(0, 0, 1), Point(1, 1, 2), Point(2, 0, 1)
>>> l1 = Line(p1, p2)
>>> l1.projection(p3)
Point3D(2/3, 2/3, 5/3)
>>> p4, p5 = Point(10, 0, 1), Point(12, 1, 3)
>>> s1 = Segment(p4, p5)
>>> l1.projection(s1)
Segment3D(Point3D(10/3, 10/3, 13/3), Point3D(5, 5, 6))

r   c                 z   > [         R                  " U TR                  -
  TR                  5      TR                  -   $ ra   )r   projectr4   rD   )r   r=   s    r7   
proj_point+LinearEntity.projection.<locals>.proj_point  s)    ==TWWdnn=GGr9   r   r   zDo not know how to project z onto )rP   r   r   rL   r)   r4   r5   	__class__r   is_emptyrn   r0   rD   rE   r   funcr   )r=   r>   r   r4   r5   	projectedas   `      r7   r   LinearEntity.projection  s   t %00%T%;%;<E	H eU##e$$|,,):ehh+?x	/I$T95I!!  %%#i.A*=~~!!)"5"56:"%NN22	7<dCE 	Er9   c                    Ub  [         R                  " U5      nO[         nU R                  [        5      n[	        U [
        5      (       a  [        UR                  SS5      5      nOY[	        U [        5      (       a  UR                  5       nO3[	        U [        5      (       a  UR                  SS5      nO[        S5      eUR                  [        [        U5      5      $ )a  A random point on a LinearEntity.

Returns
=======

point : Point

See Also
========

sympy.geometry.point.Point

Examples
========

>>> from sympy import Point, Line, Ray, Segment
>>> p1, p2 = Point(0, 0), Point(5, 3)
>>> line = Line(p1, p2)
>>> r = line.random_point(seed=42)  # seed value is optional
>>> r.n(3)
Point2D(-0.72, -0.432)
>>> r in line
True
>>> Ray(p1, p2).random_point(seed=42).n(3)
Point2D(0.72, 0.432)
>>> Segment(p1, p2).random_point(seed=42).n(3)
Point2D(3.2, 1.92)

r   r   zunhandled line type)randomRandomrk   rj   rP   r   rR   gaussr|   r   rt   subsr   )r=   seedrngptr   s        r7   random_pointLinearEntity.random_point  s    < --%CC!!!$dC  CIIaO$Ag&&

Ad##		!QA%&;<<wwq(1+&&r9   c                    [        U[        5      (       d  [        SU-  5      eXp2UR                  R                  UR                  R                  :w  az  [        U[
        5      (       a  X2p2[        R                  " UR                  UR                  SS9u  pE[        R                  " UR                  UR                  SS9u  pF[        XV5      n[        X#5      nU(       d  [        S5      eUS   n[        U[        5      (       a  U /$ UR                  R                  n	UR                  R                  n
[        XU	-   U
-   5      n[        XU	-   U
-
  5      nX/$ )a  Returns the perpendicular lines which pass through the intersections
of self and other that are in the same plane.

Parameters
==========

line : Line3D

Returns
=======

list: two Line instances

Examples
========

>>> from sympy import Point3D, Line3D
>>> r1 = Line3D(Point3D(0, 0, 0), Point3D(1, 0, 0))
>>> r2 = Line3D(Point3D(0, 0, 0), Point3D(0, 1, 0))
>>> r1.bisectors(r2)
[Line3D(Point3D(0, 0, 0), Point3D(1, 1, 0)), Line3D(Point3D(0, 0, 0), Point3D(1, -1, 0))]

zExpecting LinearEntity, not %signore)on_morphzThe lines do not intersectr   )rP   r)   r   r4   rL   Line2Dr   r-   r5   r   r   rD   unit)r=   r>   rT   rU   _r4   r5   pointr   d1d2bis1bis2s                r7   	bisectorsLinearEntity.bisectors  s    0 %.. @5 HIIB 55""bee&=&=="f%%B..ruubeehOEA..ruubeehOEAbBR$  <==qB"d##v \\\\BR"%BR"%|r9    ra   rj   ) r/   
__module____qualname____firstlineno____doc__r1   r@   rH   propertyrL   rX   r[   rk   staticmethodrq   r<   rD   r   r   r   r   r   r4   r5   r   r   r   r   r   r   r   __static_attributes__r   r9   r7   r)   r)   2   s    0=	L  @>2@!7F3/j 1 1f$ ! !@s(j0=d.=`!"    (  ()+V(+T;z " "2WEr+'Z8r9   r)   c                   :    \ rS rSrSrS rS rS rS rS
S jr	Sr
g	)r   iU  a&  An infinite line in space.

A 2D line is declared with two distinct points, point and slope, or
an equation. A 3D line may be defined with a point and a direction ratio.

Parameters
==========

p1 : Point
p2 : Point
slope : SymPy expression
direction_ratio : list
equation : equation of a line

Notes
=====

`Line` will automatically subclass to `Line2D` or `Line3D` based
on the dimension of `p1`.  The `slope` argument is only relevant
for `Line2D` and the `direction_ratio` argument is only relevant
for `Line3D`.

The order of the points will define the direction of the line
which is used when calculating the angle between lines.

See Also
========

sympy.geometry.point.Point
sympy.geometry.line.Line2D
sympy.geometry.line.Line3D

Examples
========

>>> from sympy import Line, Segment, Point, Eq
>>> from sympy.abc import x, y, a, b

>>> L = Line(Point(2,3), Point(3,5))
>>> L
Line2D(Point2D(2, 3), Point2D(3, 5))
>>> L.points
(Point2D(2, 3), Point2D(3, 5))
>>> L.equation()
-2*x + y + 1
>>> L.coefficients
(-2, 1, 1)

Instantiate with keyword ``slope``:

>>> Line(Point(0, 0), slope=0)
Line2D(Point2D(0, 0), Point2D(1, 0))

Instantiate with another linear object

>>> s = Segment((0, 0), (0, 1))
>>> Line(s).equation()
x

The line corresponding to an equation in the for `ax + by + c = 0`,
can be entered:

>>> Line(3*x + y + 18)
Line2D(Point2D(0, -18), Point2D(1, -21))

If `x` or `y` has a different name, then they can be specified, too,
as a string (to match the name) or symbol:

>>> Line(Eq(3*a + b, -18), x='a', y=b)
Line2D(Point2D(0, -18), Point2D(1, -21))
c                 .  ^^ [        U5      S:X  Ga  [        US   [        [        45      (       a  [	        SU5      mU(       d  SnSnO$UR                  ST5      nUR                  ST5      nU(       a  [        S5      eUS   m[        T[        5      (       a  TR                  TR                  -
  mUU4S jnU" U5      nU" U5      n[        TX45      u  pgnU(       a  [        SU* U-  4U* U-  S9$ U(       a  [        U* U-  S4[        S9$ [        S	[        S
5      X41-
  -  5      e[        U5      S:  a  US   n	[        U5      S:  a  US   n
OS n
[        U	[        5      (       a(  U
(       a  [        S5      e[        U	R                  5      nOI[        U	5      n	[        U	5      nU
c%  [        U
[        5      (       a  U
R                   U:w  a  [        U
5      n
US:X  a  [#        X40 UD6$ US:X  a  [%        X40 UD6$ [        R&                  " X	U
40 UD6$ g )Nr   r   ?xyz"expecting only x and y as keywordsc                 B   >  [        U T5      $ ! [         a    Ts $ f = fra   )r   r.   )r  equationmissings    r7   find_or_missing%Line.__new__.<locals>.find_or_missing  s)    #8,,! #"N#s    )slopeznot found in equation: %sxyz)If p1 is a LinearEntity, p2 must be None.r&      )r0   rP   r   r	   r   popr.   lhsrhsr#   r   r   setr)   r4   r   rL   r   Line3Dr1   )r3   r   r6   r  r  r  r   bcr4   r5   r   r  r  s               @@r7   r1   Line.__new__  s   t9>ja4*==+C6GJJsG,JJsG, !EFFAwH(B''#<<(,,6#
  "A"A#Ha3GA!Q1IaRT22aRT1IR008CI<NOPP 4y1}!Wt9q=aBBb,//()TUUbee*CrBb'C~B)>)>2CWCW[^C^"2Y!8!"3F33AX!"3F33#++CRB6BB+ r9   c                    [        U[        5      (       d  [        XR                  S9n[        U[        5      (       a+  [        R                  " XR
                  U R                  5      $ [        U[        5      (       aA  [        R                  " U R
                  U R                  UR
                  UR                  5      $ g)a  
Return True if `other` is on this Line, or False otherwise.

Examples
========

>>> from sympy import Line,Point
>>> p1, p2 = Point(0, 1), Point(3, 4)
>>> l = Line(p1, p2)
>>> l.contains(p1)
True
>>> l.contains((0, 1))
True
>>> l.contains((0, 0))
False
>>> a = (0, 0, 0)
>>> b = (1, 1, 1)
>>> c = (2, 2, 2)
>>> l1 = Line(a, b)
>>> l2 = Line(b, a)
>>> l1 == l2
False
>>> l1 in l2
True

r   F)rP   r   r   rL   is_collinearr4   r5   r)   ru   s     r7   r<   Line.contains  s    6 %00%%;%;<EeU##%%eWWdgg>>e\**%%dggtww%((KKr9   c                     [        U[        5      (       d  [        XR                  S9nU R	                  U5      (       a  [
        R                  $ U R                  U5      R                  $ )a  
Finds the shortest distance between a line and a point.

Raises
======

NotImplementedError is raised if `other` is not a Point

Examples
========

>>> from sympy import Point, Line
>>> p1, p2 = Point(0, 0), Point(1, 1)
>>> s = Line(p1, p2)
>>> s.distance(Point(-1, 1))
sqrt(2)
>>> s.distance((-1, 2))
3*sqrt(2)/2
>>> p1, p2 = Point(0, 0, 0), Point(1, 1, 1)
>>> s = Line(p1, p2)
>>> s.distance(Point(-1, 1, 1))
2*sqrt(6)/3
>>> s.distance((-1, 1, 1))
2*sqrt(6)/3

r   )	rP   r   r   rL   r<   r
   r   r   r   ru   s     r7   distanceLine.distance  sP    6 %00%%;%;<E==66M))%0777r9   c                     [        U[        5      (       d  g[        R                  " U R                  UR                  U R
                  UR
                  5      $ AReturns True if self and other are the same mathematical entitiesF)rP   r   r   r  r4   r5   ru   s     r7   r   Line.equals  s9    %&&!!$''588TWWehhGGr9   c                      [        USS9nUSS/$ )a  The plot interval for the default geometric plot of line. Gives
values that will produce a line that is +/- 5 units long (where a
unit is the distance between the two points that define the line).

Parameters
==========

parameter : str, optional
    Default value is 't'.

Returns
=======

plot_interval : list (plot interval)
    [parameter, lower_bound, upper_bound]

Examples
========

>>> from sympy import Point, Line
>>> p1, p2 = Point(0, 0), Point(5, 3)
>>> l1 = Line(p1, p2)
>>> l1.plot_interval()
[t, -5, 5]

Tr^      r   rh   s      r7   plot_intervalLine.plot_interval   s    6 ID)2qzr9   r   Nr   )r/   r   r   r   r   r1   r<   r  r   r!  r   r   r9   r7   r   r   U  s'    FN7Cr!F8BHr9   r   c                   X    \ rS rSrSrSS jrSS jrS rS rS r	SS	 jr
\S
 5       rSrg)r   i?  av  A Ray is a semi-line in the space with a source point and a direction.

Parameters
==========

p1 : Point
    The source of the Ray
p2 : Point or radian value
    This point determines the direction in which the Ray propagates.
    If given as an angle it is interpreted in radians with the positive
    direction being ccw.

Attributes
==========

source

See Also
========

sympy.geometry.line.Ray2D
sympy.geometry.line.Ray3D
sympy.geometry.point.Point
sympy.geometry.line.Line

Notes
=====

`Ray` will automatically subclass to `Ray2D` or `Ray3D` based on the
dimension of `p1`.

Examples
========

>>> from sympy import Ray, Point, pi
>>> r = Ray(Point(2, 3), Point(3, 5))
>>> r
Ray2D(Point2D(2, 3), Point2D(3, 5))
>>> r.points
(Point2D(2, 3), Point2D(3, 5))
>>> r.source
Point2D(2, 3)
>>> r.xdirection
oo
>>> r.ydirection
oo
>>> r.slope
2
>>> Ray(Point(0, 0), angle=pi/4).slope
1

Nc                     [        U5      nUb"  [         R                  " U[        U5      5      u  p[        U5      nUS:X  a  [        X40 UD6$ US:X  a  [	        X40 UD6$ [
        R                  " XU40 UD6$ Nr&   r
  )r   r-   r0   Ray2DRay3Dr)   r1   r3   r4   r5   r6   r   s        r7   r1   Ray.__new__t  sw    2Y>//E"I>FB"g!8*6**AX*6**##CR:6::r9   c                 D   [        U R                  5      [        U R                  5      4nU Vs/ s H)  nSR                  UR                  UR
                  5      PM+     nnSR                  US   SR                  USS 5      5      nSR                  SU-  Xb5      $ s  snf )	Returns SVG path element for the LinearEntity.

Parameters
==========

scale_factor : float
    Multiplication factor for the SVG stroke-width.  Default is 1.
fill_color : str, optional
    Hex string for fill color. Default is "#66cc99".
{},{}	M {} L {}r    L r   Nz<path fill-rule="evenodd" fill="{2}" stroke="#555555" stroke-width="{0}" opacity="0.6" d="{1}" marker-start="url(#markerCircle)" marker-end="url(#markerArrow)"/>       @r   r4   r5   r   r  r  joinr=   scale_factor
fill_colorvertsr   coordspaths          r7   _svgRay._svg  s     477QtwwZ(49:Eq'..acc*E:!!&)UZZqr
-CDQ &L$
3		4 ;   0Bc                 \   [        U[        5      (       d  [        XR                  S9n[        U[        5      (       a  [        R                  " U R
                  U R                  U5      (       aN  [        U R                  U R
                  -
  R                  XR
                  -
  5      [        R                  :  5      $ g[        U[        5      (       a  [        R                  " U R
                  U R                  UR
                  UR                  5      (       aY  [        U R                  U R
                  -
  R                  UR                  UR
                  -
  5      [        R                  :  5      $ g[        U[        5      (       a%  UR
                  U ;   =(       a    UR                  U ;   $ g)a  
Is other GeometryEntity contained in this Ray?

Examples
========

>>> from sympy import Ray,Point,Segment
>>> p1, p2 = Point(0, 0), Point(4, 4)
>>> r = Ray(p1, p2)
>>> r.contains(p1)
True
>>> r.contains((1, 1))
True
>>> r.contains((1, 3))
False
>>> s = Segment((1, 1), (2, 2))
>>> r.contains(s)
True
>>> s = Segment((1, 2), (2, 5))
>>> r.contains(s)
False
>>> r1 = Ray((2, 2), (3, 3))
>>> r.contains(r1)
True
>>> r1 = Ray((2, 2), (3, 5))
>>> r.contains(r1)
False
r   F)rP   r   r   rL   r  r4   r5   boolrE   r
   r   r   r|   ru   s     r7   r<   Ray.contains  s!   : %00%%;%;<EeU##!!$''477E:: TWWtww.33EGGODNOOs##!!$''477EHHehhGGTWWtww.33EHHuxx4GH166QRRw''88t#8D(88 r9   c                 p   [        U[        5      (       d  [        XR                  S9nU R	                  U5      (       a  [
        R                  $ [        U R                  U R                  5      R                  U5      nU R	                  U5      (       a  [        X-
  5      $ [        XR                  -
  5      $ )a  
Finds the shortest distance between the ray and a point.

Raises
======

NotImplementedError is raised if `other` is not a Point

Examples
========

>>> from sympy import Point, Ray
>>> p1, p2 = Point(0, 0), Point(1, 1)
>>> s = Ray(p1, p2)
>>> s.distance(Point(-1, -1))
sqrt(2)
>>> s.distance((-1, 2))
3*sqrt(2)/2
>>> p1, p2 = Point(0, 0, 0), Point(1, 1, 2)
>>> s = Ray(p1, p2)
>>> s
Ray3D(Point3D(0, 0, 0), Point3D(1, 1, 2))
>>> s.distance(Point(-1, -1, 2))
4*sqrt(3)/3
>>> s.distance((-1, -1, 2))
4*sqrt(3)/3

r   )rP   r   r   rL   r<   r
   r   r   r4   r5   r   rR   source)r=   r>   projs      r7   r  Ray.distance  s    : %00%%;%;<E==66MDGGTWW%007==u|$$u{{*++r9   c                     [        U[        5      (       d  gU R                  UR                  :H  =(       a    UR                  U ;   $ r  )rP   r   r?  r5   ru   s     r7   r   
Ray.equals  s3    %%%{{ell*?uxx4/??r9   c                      [        USS9nUSS/$ )a  The plot interval for the default geometric plot of the Ray. Gives
values that will produce a ray that is 10 units long (where a unit is
the distance between the two points that define the ray).

Parameters
==========

parameter : str, optional
    Default value is 't'.

Returns
=======

plot_interval : list
    [parameter, lower_bound, upper_bound]

Examples
========

>>> from sympy import Ray, pi
>>> r = Ray((0, 0), angle=pi/4)
>>> r.plot_interval()
[t, 0, 10]

Tr^   r   
   r   rh   s      r7   r!  Ray.plot_interval  s    4 ID)1bzr9   c                     U R                   $ )aC  The point from which the ray emanates.

See Also
========

sympy.geometry.point.Point

Examples
========

>>> from sympy import Point, Ray
>>> p1, p2 = Point(0, 0), Point(4, 1)
>>> r1 = Ray(p1, p2)
>>> r1.source
Point2D(0, 0)
>>> p1, p2 = Point(0, 0, 0), Point(4, 1, 5)
>>> r1 = Ray(p2, p1)
>>> r1.source
Point3D(4, 1, 5)

)r4   rK   s    r7   r?  
Ray.source  s    . wwr9   r   ra   g      ?z#66cc99r   )r/   r   r   r   r   r1   r8  r<   r  r   r!  r   r?  r   r   r9   r7   r   r   ?  s=    3h
;4*.`&,P@:  r9   r   c                   d    \ rS rSrSrS rS rS rS r\	S 5       r
\	S 5       rSS
 jrSS jrSrg	)r|   i*  a  A line segment in space.

Parameters
==========

p1 : Point
p2 : Point

Attributes
==========

length : number or SymPy expression
midpoint : Point

See Also
========

sympy.geometry.line.Segment2D
sympy.geometry.line.Segment3D
sympy.geometry.point.Point
sympy.geometry.line.Line

Notes
=====

If 2D or 3D points are used to define `Segment`, it will
be automatically subclassed to `Segment2D` or `Segment3D`.

Examples
========

>>> from sympy import Point, Segment
>>> Segment((1, 0), (1, 1)) # tuples are interpreted as pts
Segment2D(Point2D(1, 0), Point2D(1, 1))
>>> s = Segment(Point(4, 3), Point(1, 1))
>>> s.points
(Point2D(4, 3), Point2D(1, 1))
>>> s.slope
2/3
>>> s.length
sqrt(13)
>>> s.midpoint
Point2D(5/2, 2)
>>> Segment((1, 0, 0), (1, 1, 1)) # tuples are interpreted as pts
Segment3D(Point3D(1, 0, 0), Point3D(1, 1, 1))
>>> s = Segment(Point(4, 3, 9), Point(1, 1, 7)); s
Segment3D(Point3D(4, 3, 9), Point3D(1, 1, 7))
>>> s.points
(Point3D(4, 3, 9), Point3D(1, 1, 7))
>>> s.length
sqrt(17)
>>> s.midpoint
Point3D(5/2, 2, 8)

c                     [         R                  " [        U5      [        U5      5      u  p[        U5      nUS:X  a  [        X40 UD6$ US:X  a  [	        X40 UD6$ [
        R                  " XU40 UD6$ r%  )r   r-   r0   	Segment2D	Segment3Dr)   r1   r(  s        r7   r1   Segment.__new__b  sm    ++E"IuRyA"g!8R.v..AXR.v..##CR:6::r9   c           
      P   [        U[        5      (       d  [        XR                  S9n[        U[        5      (       Ga  [        R                  " XR
                  U R                  5      (       GaU  [        U [        5      (       a  SU R                  -  R                  S5      nUSL aR  U R
                  R                  UR                  -
  U R                  R                  UR                  -
  -  S:*  nUS;   a  U$ USL aR  U R
                  R                  UR                  -
  U R                  R                  UR                  -
  -  S:*  nUS;   a  U$ XR
                  -
  XR                  -
  pTU R                  U R
                  -
  n [        [        [        [        U5      [        U5      -   [        U5      -
  S5      5      5      $ [        U[&        5      (       a%  UR
                  U ;   =(       a    UR                  U ;   $ g! [          a    [#        SR%                  X5      5      ef = f)a  
Is the other GeometryEntity contained within this Segment?

Examples
========

>>> from sympy import Point, Segment
>>> p1, p2 = Point(0, 1), Point(3, 4)
>>> s = Segment(p1, p2)
>>> s2 = Segment(p2, p1)
>>> s.contains(s2)
True
>>> from sympy import Point3D, Segment3D
>>> p1, p2 = Point3D(0, 1, 1), Point3D(3, 4, 5)
>>> s = Segment3D(p1, p2)
>>> s2 = Segment3D(p2, p1)
>>> s.contains(s2)
True
>>> s.contains((p1 + p2)/2)
True
r   r   r   F)TFTzCannot determine if {} is in {})rP   r   r   rL   r  r4   r5   rL  r  r   r  r  r<  r!   r	   rR   rQ   r$   r   r|   )r=   r>   vertisinr   r   rG   s          r7   r<   Segment.containsl  s   , %00%%;%;<EeU##!!%$''::dI.. djjL003Du} $		EGG 3dggii%''6IJaO=0#'Kt| $		EGG 3dggii%''6IJaO=0#'K%''/BGGdgg%]  CGc"g,=A,F)J KLL eW%%88t#8D(88 ! ]%&G&N&Nu&[\\]s   >H   %H%c                     [        XR                  5      =(       a=    [        [        U R                  5      5      [        [        UR                  5      5      :H  $ )r  )rP   r   listr   r   ru   s     r7   r   Segment.equals  sA    %+ =DII1 #'

(;#<1= 	=r9   c                    [        U[        5      (       d  [        XR                  S9n[        U[        5      (       a  XR                  -
  nXR
                  -
  nU R                  R                  U5      S:  nU R                  R                  U5      S:*  nU(       a6  U(       a/  [        U R                  U R
                  5      R                  U5      $ U(       a  U(       d  [        U5      $ U(       d  U(       a  [        U5      $ [        5       e)a  
Finds the shortest distance between a line segment and a point.

Raises
======

NotImplementedError is raised if `other` is not a Point

Examples
========

>>> from sympy import Point, Segment
>>> p1, p2 = Point(0, 1), Point(3, 4)
>>> s = Segment(p1, p2)
>>> s.distance(Point(10, 15))
sqrt(170)
>>> s.distance((0, 12))
sqrt(73)
>>> from sympy import Point3D, Segment3D
>>> p1, p2 = Point3D(0, 0, 3), Point3D(1, 1, 4)
>>> s = Segment3D(p1, p2)
>>> s.distance(Point3D(10, 15, 12))
sqrt(341)
>>> s.distance((10, 15, 12))
sqrt(341)
r   r   )rP   r   r   rL   r4   r5   rD   rE   r   r  rR   rt   )r=   r>   vp1vp2dot_prod_sign_1dot_prod_sign_2s         r7   r  Segment.distance  s    6 %00%%;%;<EeU##''/C''/C"nn005:O"nn005:O?DGGTWW-66u==3x"3x!##r9   c                 X    [         R                  " U R                  U R                  5      $ )al  The length of the line segment.

See Also
========

sympy.geometry.point.Point.distance

Examples
========

>>> from sympy import Point, Segment
>>> p1, p2 = Point(0, 0), Point(4, 3)
>>> s1 = Segment(p1, p2)
>>> s1.length
5
>>> from sympy import Point3D, Segment3D
>>> p1, p2 = Point3D(0, 0, 0), Point3D(4, 3, 3)
>>> s1 = Segment3D(p1, p2)
>>> s1.length
sqrt(34)

)r   r  r4   r5   rK   s    r7   r   Segment.length      0 ~~dggtww//r9   c                 X    [         R                  " U R                  U R                  5      $ )a  The midpoint of the line segment.

See Also
========

sympy.geometry.point.Point.midpoint

Examples
========

>>> from sympy import Point, Segment
>>> p1, p2 = Point(0, 0), Point(4, 3)
>>> s1 = Segment(p1, p2)
>>> s1.midpoint
Point2D(2, 3/2)
>>> from sympy import Point3D, Segment3D
>>> p1, p2 = Point3D(0, 0, 0), Point3D(4, 3, 3)
>>> s1 = Segment3D(p1, p2)
>>> s1.midpoint
Point3D(2, 3/2, 3/2)

)r   midpointr4   r5   rK   s    r7   r`  Segment.midpoint  r^  r9   Nc                     U R                  U R                  5      nUb-  [        XR                  S9nX2;   a  [	        X0R                  5      $ U$ )a  The perpendicular bisector of this segment.

If no point is specified or the point specified is not on the
bisector then the bisector is returned as a Line. Otherwise a
Segment is returned that joins the point specified and the
intersection of the bisector and the segment.

Parameters
==========

p : Point

Returns
=======

bisector : Line or Segment

See Also
========

LinearEntity.perpendicular_segment

Examples
========

>>> from sympy import Point, Segment
>>> p1, p2, p3 = Point(0, 0), Point(6, 6), Point(5, 1)
>>> s1 = Segment(p1, p2)
>>> s1.perpendicular_bisector()
Line2D(Point2D(3, 3), Point2D(-3, 9))

>>> s1.perpendicular_bisector(p3)
Segment2D(Point2D(5, 1), Point2D(3, 3))

r   )r   r`  r   rL   r|   r   s       r7   perpendicular_bisectorSegment.perpendicular_bisector  sG    H ##DMM2=q445Bwr==11r9   c                      [        USS9nUSS/$ )a  The plot interval for the default geometric plot of the Segment gives
values that will produce the full segment in a plot.

Parameters
==========

parameter : str, optional
    Default value is 't'.

Returns
=======

plot_interval : list
    [parameter, lower_bound, upper_bound]

Examples
========

>>> from sympy import Point, Segment
>>> p1, p2 = Point(0, 0), Point(5, 3)
>>> s1 = Segment(p1, p2)
>>> s1.plot_interval()
[t, 0, 1]

Tr^   r   r   r   rh   s      r7   r!  Segment.plot_interval2  s    4 ID)1ayr9   r   ra   r   )r/   r   r   r   r   r1   r<   r   r  r   r   r`  rc  r!  r   r   r9   r7   r|   r|   *  sQ    6n;5n=
)$V 0 02 0 02)Vr9   r|   c                   >    \ rS rSrSr\S 5       rS r\S 5       rSr	g)LinearEntity2DiP  a   A base class for all linear entities (line, ray and segment)
in a 2-dimensional Euclidean space.

Attributes
==========

p1
p2
coefficients
slope
points

Notes
=====

This is an abstract class and is not meant to be instantiated.

See Also
========

sympy.geometry.entity.GeometryEntity

c                     U R                   nU Vs/ s H  o"R                  PM     nnU Vs/ s H  o"R                  PM     nn[        U5      [        U5      [	        U5      [	        U5      4$ s  snf s  snf )zgReturn a tuple (xmin, ymin, xmax, ymax) representing the bounding
rectangle for the geometric figure.

)r   r  r  minmax)r=   r5  r   xsyss        r7   boundsLinearEntity2D.boundsh  s`      !5acc5! !5acc5!BR#b'3r733 "!s
   A-A2c                 l    [        XR                  S9n[        XU R                  R                  -   5      $ )aC  Create a new Line perpendicular to this linear entity which passes
through the point `p`.

Parameters
==========

p : Point

Returns
=======

line : Line

See Also
========

sympy.geometry.line.LinearEntity.is_perpendicular, perpendicular_segment

Examples
========

>>> from sympy import Point, Line
>>> p1, p2, p3 = Point(0, 0), Point(2, 3), Point(-2, 2)
>>> L = Line(p1, p2)
>>> P = L.perpendicular_line(p3); P
Line2D(Point2D(-2, 2), Point2D(-5, 4))
>>> L.is_perpendicular(P)
True

In 2D, the first point of the perpendicular line is the
point through which was required to pass; the second
point is arbitrarily chosen. To get a line that explicitly
uses a point in the line, create a line from the perpendicular
segment from the line to the point:

>>> Line(L.perpendicular_segment(p3))
Line2D(Point2D(-2, 2), Point2D(4/13, 6/13))
r   )r   rL   r   rD   r   r   s     r7   r   !LinearEntity2D.perpendicular_lines  s1    N !//0 A4>>>>>??r9   c                     U R                   U R                  -
  R                  u  pUS:X  a  [        R                  $ [        X!-  5      $ )aP  The slope of this linear entity, or infinity if vertical.

Returns
=======

slope : number or SymPy expression

See Also
========

coefficients

Examples
========

>>> from sympy import Point, Line
>>> p1, p2 = Point(0, 0), Point(3, 5)
>>> l1 = Line(p1, p2)
>>> l1.slope
5/3

>>> p3 = Point(0, 4)
>>> l2 = Line(p1, p3)
>>> l2.slope
oo

r   )r4   r5   r   r
   r   r!   )r=   r   r   s      r7   r  LinearEntity2D.slope  s;    : ''DGG#))7::r9   r   N)
r/   r   r   r   r   r   rn  r   r  r   r   r9   r7   rh  rh  P  s6    . 4 4+@Z  r9   rh  c                   F    \ rS rSrSrS	S jrS
S jr\S 5       rSS jr	Sr
g)r   i  a  An infinite line in space 2D.

A line is declared with two distinct points or a point and slope
as defined using keyword `slope`.

Parameters
==========

p1 : Point
pt : Point
slope : SymPy expression

See Also
========

sympy.geometry.point.Point

Examples
========

>>> from sympy import Line, Segment, Point
>>> L = Line(Point(2,3), Point(3,5))
>>> L
Line2D(Point2D(2, 3), Point2D(3, 5))
>>> L.points
(Point2D(2, 3), Point2D(3, 5))
>>> L.equation()
-2*x + y + 1
>>> L.coefficients
(-2, 1, 1)

Instantiate with keyword ``slope``:

>>> Line(Point(0, 0), slope=0)
Line2D(Point2D(0, 0), Point2D(1, 0))

Instantiate with another linear object

>>> s = Segment((0, 0), (0, 1))
>>> Line(s).equation()
x
Nc                    [        U[        5      (       a1  Ub  [        S5      e[        R                  " UR
                  SS06u  pO
[        USS9nUb  Uc   [        USS9nOZUbL  UcI  [        U5      nUR                  SL a  SnSnOSnUn[        UR                  U-   UR                  U-   SS	9nO[        S
5      e[        R                  " XU40 UD6$ ! [        [        [        4 a    [        [        S5      5      ef = f)Nz,When p1 is a LinearEntity, pt should be Noner   r&   r   z
                    The 2nd argument was not a valid Point.
                    If it was a slope, enter it with keyword "slope".
                    Fr   r   )evaluatez,A 2nd Point or keyword "slope" must be used.)rP   r)   r.   r   r-   r   rt   rQ   r%   r   	is_finiter  r  rh  r1   )r3   r4   r   r  r6   r5   dxdys           r7   r1   Line2D.__new__  s   b,''~ !OPP//@a@FBrq!B>em21% 2:ENE%' rttby"$$)e<BKLL%%cr<V<<' (J?   - "  s   
C *C?c                 D   [        U R                  5      [        U R                  5      4nU Vs/ s H)  nSR                  UR                  UR
                  5      PM+     nnSR                  US   SR                  USS 5      5      nSR                  SU-  Xb5      $ s  snf )	r+  r,  r-  r   r.  r   Nz<path fill-rule="evenodd" fill="{2}" stroke="#555555" stroke-width="{0}" opacity="0.6" d="{1}" marker-start="url(#markerReverseArrow)" marker-end="url(#markerArrow)"/>r/  r0  r2  s          r7   r8  Line2D._svg  s     477QtwwZ(49:Eq'..acc*E:!!&)UZZqr
-CDW &L$
3		4 ;r:  c                    U R                   u  pUR                  UR                  :X  a,  [        R                  [        R                  UR                  * 4$ UR
                  UR
                  :X  a,  [        R                  [        R                  UR
                  * 4$ [        U R                  R
                  U R                  R
                  -
  U R                  R                  U R                  R                  -
  U R                  R                  U R                  R
                  -  U R                  R
                  U R                  R                  -  -
  4 Vs/ s H  n[        U5      PM     sn5      $ s  snf )aj  The coefficients (`a`, `b`, `c`) for `ax + by + c = 0`.

See Also
========

sympy.geometry.line.Line2D.equation

Examples
========

>>> from sympy import Point, Line
>>> from sympy.abc import x, y
>>> p1, p2 = Point(0, 0), Point(5, 3)
>>> l = Line(p1, p2)
>>> l.coefficients
(-3, 5, 0)

>>> p3 = Point(x, y)
>>> l2 = Line(p1, p3)
>>> l2.coefficients
(-y, x, 0)

)
r   r  r
   Oner   r  tupler4   r5   r!   )r=   r4   r5   is       r7   coefficientsLine2D.coefficients"  s   2 44244<EE166BDD5))TTRTT\FFAEEBDD5))wwyy47799,wwyy47799,wwyy*TWWYYtwwyy-@@BCB '(hqkBC D 	D Cs   E2c                    [        USS9n[        USS9nU R                  u  p4UR                  UR                  :X  a  XR                  -
  $ UR                  UR                  :X  a  X#R                  -
  $ U R                  u  pVnXQ-  Xb-  -   U-   $ )a  The equation of the line: ax + by + c.

Parameters
==========

x : str, optional
    The name to use for the x-axis, default value is 'x'.
y : str, optional
    The name to use for the y-axis, default value is 'y'.

Returns
=======

equation : SymPy expression

See Also
========

sympy.geometry.line.Line2D.coefficients

Examples
========

>>> from sympy import Point, Line
>>> p1, p2 = Point(1, 0), Point(5, 3)
>>> l1 = Line(p1, p2)
>>> l1.equation()
-3*x + 4*y + 3

Tr^   )r   r   r  r  r  )r=   r  r  r4   r5   r   r  r  s           r7   r  Line2D.equationE  s|    > AD!AD!44244<tt8OTTRTT\tt8O##asQSy1}r9   r   NNrI  )r  r  )r/   r   r   r   r   r1   r8  r   r  r  r   r   r9   r7   r   r     s.    )T=>4*  D  DD(r9   r   c                   H    \ rS rSrSrS	S jr\S 5       r\S 5       rS r	Sr
g)
r&  ip  a  
A Ray is a semi-line in the space with a source point and a direction.

Parameters
==========

p1 : Point
    The source of the Ray
p2 : Point or radian value
    This point determines the direction in which the Ray propagates.
    If given as an angle it is interpreted in radians with the positive
    direction being ccw.

Attributes
==========

source
xdirection
ydirection

See Also
========

sympy.geometry.point.Point, Line

Examples
========

>>> from sympy import Point, pi, Ray
>>> r = Ray(Point(2, 3), Point(3, 5))
>>> r
Ray2D(Point2D(2, 3), Point2D(3, 5))
>>> r.points
(Point2D(2, 3), Point2D(3, 5))
>>> r.source
Point2D(2, 3)
>>> r.xdirection
oo
>>> r.ydirection
oo
>>> r.slope
2
>>> Ray(Point(0, 0), angle=pi/4).slope
1

Nc                 Z   [        USS9nUb   Uc   [        USS9nX:X  a  [        S5      eGOUGb  UGc  [        U5      n[        U5      nS nUb  UR                  (       a  UR                  S:X  a@  UR                  S:X  a  U[        SS5      -   nOoUR                  S:X  a  U[        SS5      -   nOOUR                  S:X  a?  UR                  S:X  a  U[        SS5      -   nOUR                  S:X  a  U[        SS5      -   nUc  U[        R                  -  nOUS[        R                  -  -  nU(       d  SU-  [        R                  -  n[        SU:  US:  5      n[        SU4[        S[        US-  S5      4S	5      S
45      n	[        [        U5      * U4[        S[        US5      4S[        US5      4[        U5      S
45      S
45      n
U[        X5      -   nO[        S5      e[         R"                  " XU40 UD6$ ! [        [        [        4 a    [        [	        S5      5      ef = f)Nr&   r   z
                    The 2nd argument was not a valid Point; if
                    it was meant to be an angle it should be
                    given with keyword "angle".z#A Ray requires two distinct points.r   r   r
  rC   )r   TTz,A 2nd point or keyword "angle" must be used.)r   rt   rQ   r.   r%   r   r   is_Rationalqr   r
   Pir   r   r	   r   rh  r1   )r3   r4   r   angler6   r5   r  r   leftr  r  s              r7   r1   Ray2D.__new__  s   21>em521% x !FGG 2:ENE% AB}==ssax33!8!#eAqk!1BSSAX!#eArl!2B33!8!#eAqk!1BSSAX!#eBl!2B:IAQqttV$aCH1q5!a%(r4j9aAE15F	+RTX*YZAwo	1bAh-"bQRTUhZ]^_Z`bfYg0hjn/op%+%KLL%%cr<V<<K (J? 5  -3 "4 5 55s   
H   *H*c                    U R                   R                  U R                  R                  :  a  [        R                  $ U R                   R                  U R                  R                  :X  a  [        R
                  $ [        R                  $ )a  The x direction of the ray.

Positive infinity if the ray points in the positive x direction,
negative infinity if the ray points in the negative x direction,
or 0 if the ray is vertical.

See Also
========

ydirection

Examples
========

>>> from sympy import Point, Ray
>>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(0, -1)
>>> r1, r2 = Ray(p1, p2), Ray(p1, p3)
>>> r1.xdirection
oo
>>> r2.xdirection
0

r4   r  r5   r
   r   r   NegativeInfinityrK   s    r7   
xdirectionRay2D.xdirection  S    2 7799twwyy ::WWYY$''))#66M%%%r9   c                    U R                   R                  U R                  R                  :  a  [        R                  $ U R                   R                  U R                  R                  :X  a  [        R
                  $ [        R                  $ )a  The y direction of the ray.

Positive infinity if the ray points in the positive y direction,
negative infinity if the ray points in the negative y direction,
or 0 if the ray is horizontal.

See Also
========

xdirection

Examples
========

>>> from sympy import Point, Ray
>>> p1, p2, p3 = Point(0, 0), Point(-1, -1), Point(-1, 0)
>>> r1, r2 = Ray(p1, p2), Ray(p1, p3)
>>> r1.ydirection
-oo
>>> r2.ydirection
0

r4   r  r5   r
   r   r   r  rK   s    r7   
ydirectionRay2D.ydirection  r  r9   c                    [        S X4 5       5      (       d  [        S5      e[        [        [	        U R
                  R                  5      5      6 n[        [        [	        UR
                  R                  5      5      6 nX#-  S:  a<  US:  a  S[        R                  -  U-   OUnUS:  a  S[        R                  -  U-   OUnX#-
  $ )a  Return the angle by which r2 must be rotated so it faces the same
direction as r1.

Parameters
==========

r1 : Ray2D
r2 : Ray2D

Returns
=======

angle : angle in radians (ccw angle is positive)

See Also
========

LinearEntity.angle_between

Examples
========

>>> from sympy import Ray, pi
>>> r1 = Ray((0, 0), (1, 0))
>>> r2 = r1.rotate(-pi/2)
>>> angle = r1.closing_angle(r2); angle
pi/2
>>> r2.rotate(angle).direction.unit == r1.direction.unit
True
>>> r2.closing_angle(r1)
-pi/2
c              3   B   #    U  H  n[        U[        5      v   M     g 7fra   )rP   r&  )rc   rs     r7   re   &Ray2D.closing_angle.<locals>.<genexpr>,	  s     :A:a''s   z%Both arguments must be Ray2D objects.r   r&   )	allrQ   r   rT  reversedrD   r   r
   r  )r1r2a1a2s       r7   closing_angleRay2D.closing_angle	  s    B :"::: CDDD",,"3"3456D",,"3"3456519 "Q144"BB "Q144"BBwr9   r   r  )r/   r   r   r   r   r1   r   r  r  r  r   r   r9   r7   r&  r&  p  s;    -\*=X & &> & &>,r9   r&  c                   (    \ rS rSrSrS rSS jrSrg)rL  i:	  a0  A line segment in 2D space.

Parameters
==========

p1 : Point
p2 : Point

Attributes
==========

length : number or SymPy expression
midpoint : Point

See Also
========

sympy.geometry.point.Point, Line

Examples
========

>>> from sympy import Point, Segment
>>> Segment((1, 0), (1, 1)) # tuples are interpreted as pts
Segment2D(Point2D(1, 0), Point2D(1, 1))
>>> s = Segment(Point(4, 3), Point(1, 1)); s
Segment2D(Point2D(4, 3), Point2D(1, 1))
>>> s.points
(Point2D(4, 3), Point2D(1, 1))
>>> s.slope
2/3
>>> s.length
sqrt(13)
>>> s.midpoint
Point2D(5/2, 2)

c                 h    [        USS9n[        USS9nX:X  a  U$ [        R                  " XU40 UD6$ )Nr&   r   )r   rh  r1   r2   s       r7   r1   Segment2D.__new__`	  <    21218I%%cr<V<<r9   c                 D   [        U R                  5      [        U R                  5      4nU Vs/ s H)  nSR                  UR                  UR
                  5      PM+     nnSR                  US   SR                  USS 5      5      nSR                  SU-  Xb5      $ s  snf )	r+  r,  r-  r   r.  r   Nza<path fill-rule="evenodd" fill="{2}" stroke="#555555" stroke-width="{0}" opacity="0.6" d="{1}" />r/  r0  r2  s          r7   r8  Segment2D._svgi	  s     477QtwwZ(49:Eq'..acc*E:!!&)UZZqr
-CD:
&L$
3	4 ;r:  r   NrI  )r/   r   r   r   r   r1   r8  r   r   r9   r7   rL  rL  :	  s    $J=4r9   rL  c                   B    \ rS rSrSrS rSr\S 5       r\S 5       r	Sr
g)	LinearEntity3Di}	  zAn base class for all linear entities (line, ray and segment)
in a 3-dimensional Euclidean space.

Attributes
==========

p1
p2
direction_ratio
direction_cosine
points

Notes
=====

This is a base class and is not meant to be instantiated.
c                     [        USS9n[        USS9nX:X  a  [        SU R                  -  5      e[        R                  " XU40 UD6$ )Nr
  r   r,   )r   r.   r/   r   r1   r2   s       r7   r1   LinearEntity3D.__new__	  sT    RQRQ883<<GI I %%cr<V<<r9   r
  c                 @    U R                   u  pUR                  U5      $ )a  The direction ratio of a given line in 3D.

See Also
========

sympy.geometry.line.Line3D.equation

Examples
========

>>> from sympy import Point3D, Line3D
>>> p1, p2 = Point3D(0, 0, 0), Point3D(5, 3, 1)
>>> l = Line3D(p1, p2)
>>> l.direction_ratio
[5, 3, 1]
)r   direction_ratior=   r4   r5   s      r7   r  LinearEntity3D.direction_ratio	  s     $ !!"%%r9   c                 @    U R                   u  pUR                  U5      $ )aJ  The normalized direction ratio of a given line in 3D.

See Also
========

sympy.geometry.line.Line3D.equation

Examples
========

>>> from sympy import Point3D, Line3D
>>> p1, p2 = Point3D(0, 0, 0), Point3D(5, 3, 1)
>>> l = Line3D(p1, p2)
>>> l.direction_cosine
[sqrt(35)/7, 3*sqrt(35)/35, sqrt(35)/35]
>>> sum(i**2 for i in _)
1
)r   direction_cosiner  s      r7   r  LinearEntity3D.direction_cosine	  s     ( ""2&&r9   r   N)r/   r   r   r   r   r1   rL   r   r  r  r   r   r9   r7   r  r  }	  s:    "= & &( ' 'r9   r  c                   @   ^  \ rS rSrSrSS jrSS jrU 4S jrSrU =r	$ )	r  i	  a  An infinite 3D line in space.

A line is declared with two distinct points or a point and direction_ratio
as defined using keyword `direction_ratio`.

Parameters
==========

p1 : Point3D
pt : Point3D
direction_ratio : list

See Also
========

sympy.geometry.point.Point3D
sympy.geometry.line.Line
sympy.geometry.line.Line2D

Examples
========

>>> from sympy import Line3D, Point3D
>>> L = Line3D(Point3D(2, 3, 4), Point3D(3, 5, 1))
>>> L
Line3D(Point3D(2, 3, 4), Point3D(3, 5, 1))
>>> L.points
(Point3D(2, 3, 4), Point3D(3, 5, 1))
r   c                    [        U[        5      (       a  Ub  [        S5      eUR                  u  pO
[	        USS9nUb  [        U5      S:X  a  [	        USS9nO[[        U5      S:X  aA  Uc>  [        UR                  US   -   UR                  US   -   UR                  US   -   5      nO[        S5      e[        R                  " XU40 UD6$ )Nz)if p1 is a LinearEntity, pt must be None.r
  r   r   r   r&   z6A 2nd Point or keyword "direction_ratio" must be used.)rP   r  r.   r   r   r0   r   r  r  zr1   r3   r4   r   r  r6   s        r7   r1   Line3D.__new__	  s    b.))~ !LMMWWFBrq!B>c/2a7rq!B!Q&2: 22BDD?1;M4M 224B  ( ) ) %%cr<V<<r9   c           	         XUS4 Vs/ s H  n[        USS9PM     snu  pp5U R                  u  pgUR                  U5      u  pn
Uu  pnU* U-  U-   U-
  U	* U-  U-   U-
  U
* U-  U-   U-
  /n[        U5       H<  u  pOUR	                  U5      (       d  M  [        X5      S   nUR                  U5          O   [        U Vs/ s H%  oDR                  UW5      R                  5       S   PM'     sn6 $ s  snf s  snf )a~  Return the equations that define the line in 3D.

Parameters
==========

x : str, optional
    The name to use for the x-axis, default value is 'x'.
y : str, optional
    The name to use for the y-axis, default value is 'y'.
z : str, optional
    The name to use for the z-axis, default value is 'z'.

Returns
=======

equation : Tuple of simultaneous equations

Examples
========

>>> from sympy import Point3D, Line3D, solve
>>> from sympy.abc import x, y, z
>>> p1, p2 = Point3D(1, 0, 0), Point3D(5, 3, 0)
>>> l1 = Line3D(p1, p2)
>>> eq = l1.equation(x, y, z); eq
(-3*x + 4*y + 3, z)
>>> solve(eq.subs(z, 0), (x, y, z))
{x: 4*y/3 + 1}
kTr^   r   )
r   r   r  	enumeratehasr"   r  r   r   as_numer_denom)r=   r  r  r  r  r  r4   r5   r   r   d3x1y1z1eqsekks                    r7   r  Line3D.equation	  s    < 78As^D^gad+^D
a''+

s1uqy2~s1uqy2~s1uqy2~>cNDAuuQxx1[^
	 #
 #F#Qvva}335a8#FGG E Gs   C0 ,C5c                   > SSK Jn  [        U[        [        45      (       a   [        U5      n[        U[
        5      (       a  [        TU ]!  U5      $ [        U[        5      (       a  X:X  a  [        R                  $ U R                  U5      (       a  [        TU ]!  UR                  5      $ [        U R                  5      n[        UR                  5      nUR!                  U5      nU" U R                  US9nUR                  R                  U5      $ [        X5      (       a  UR                  U 5      $ U S[#        U5       S3n[%        U5      e! [         a     GN.f = f)a  
Finds the shortest distance between a line and another object.

Parameters
==========

Point3D, Line3D, Plane, tuple, list

Returns
=======

distance

Notes
=====

This method accepts only 3D entities as it's parameter

Tuples and lists are converted to Point3D and therefore must be of
length 3, 2 or 1.

NotImplementedError is raised if `other` is not an instance of one
of the specified classes: Point3D, Line3D, or Plane.

Examples
========

>>> from sympy.geometry import Line3D
>>> l1 = Line3D((0, 0, 0), (0, 0, 1))
>>> l2 = Line3D((0, 1, 0), (1, 1, 1))
>>> l1.distance(l2)
1

The computed distance may be symbolic, too:

>>> from sympy.abc import x, y
>>> l1 = Line3D((0, 0, 0), (0, 0, 1))
>>> l2 = Line3D((0, x, 0), (y, x, 1))
>>> l1.distance(l2)
Abs(x*y)/Abs(sqrt(y**2))

r   )Plane)r4   normal_vectorz
 has type z, which is unsupported)planer  rP   r  rT  r   r.   superr  r  r
   r   r   r4   r   r  crosstypert   )	r=   r>   r  self_directionother_directionnormalplane_through_selfmsgr   s	           r7   r  Line3D.distance#
  s0   X 	!eeT]++ eW%%7#E**eV$$}vv&&w'11 $D$8$89N$U%:%:;O#))/:F!&$''!H88$$%788e##>>$''z$u+.DE!#&&/  s   E 
EENr   )r  r  r  )
r/   r   r   r   r   r1   r  r  r   __classcell__)r   s   @r7   r  r  	  s     :=$)HVH' H'r9   r  c                   R    \ rS rSrSrS	S jr\S 5       r\S 5       r\S 5       r	Sr
g)
r'  in
  a  
A Ray is a semi-line in the space with a source point and a direction.

Parameters
==========

p1 : Point3D
    The source of the Ray
p2 : Point or a direction vector
direction_ratio: Determines the direction in which the Ray propagates.


Attributes
==========

source
xdirection
ydirection
zdirection

See Also
========

sympy.geometry.point.Point3D, Line3D


Examples
========

>>> from sympy import Point3D, Ray3D
>>> r = Ray3D(Point3D(2, 3, 4), Point3D(3, 5, 0))
>>> r
Ray3D(Point3D(2, 3, 4), Point3D(3, 5, 0))
>>> r.points
(Point3D(2, 3, 4), Point3D(3, 5, 0))
>>> r.source
Point3D(2, 3, 4)
>>> r.xdirection
oo
>>> r.ydirection
oo
>>> r.direction_ratio
[1, 2, -4]

Nr   c                    [        U[        5      (       a  Ub  [        S5      eUR                  u  pO
[	        USS9nUb  [        U5      S:X  a  [	        USS9nOd[        U5      S:X  aA  Uc>  [        UR                  US   -   UR                  US   -   UR                  US   -   5      nO[        [        S5      5      e[        R                  " XU40 UD6$ )Nz(If p1 is a LinearEntity, pt must be Noner
  r   r   r   r&   zT
                A 2nd Point or keyword "direction_ratio" must be used.
            )rP   r  r.   r   r   r0   r   r  r  r  r%   r1   r  s        r7   r1   Ray3D.__new__
  s    b.))~ !KLLWWFBrq!B>c/2a7rq!B!Q&2: 22BDD?1;M4M 224B Z )    %%cr<V<<r9   c                    U R                   R                  U R                  R                  :  a  [        R                  $ U R                   R                  U R                  R                  :X  a  [        R
                  $ [        R                  $ )a  The x direction of the ray.

Positive infinity if the ray points in the positive x direction,
negative infinity if the ray points in the negative x direction,
or 0 if the ray is vertical.

See Also
========

ydirection

Examples
========

>>> from sympy import Point3D, Ray3D
>>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(0, -1, 0)
>>> r1, r2 = Ray3D(p1, p2), Ray3D(p1, p3)
>>> r1.xdirection
oo
>>> r2.xdirection
0

r  rK   s    r7   r  Ray3D.xdirection
  r  r9   c                    U R                   R                  U R                  R                  :  a  [        R                  $ U R                   R                  U R                  R                  :X  a  [        R
                  $ [        R                  $ )a  The y direction of the ray.

Positive infinity if the ray points in the positive y direction,
negative infinity if the ray points in the negative y direction,
or 0 if the ray is horizontal.

See Also
========

xdirection

Examples
========

>>> from sympy import Point3D, Ray3D
>>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(-1, -1, -1), Point3D(-1, 0, 0)
>>> r1, r2 = Ray3D(p1, p2), Ray3D(p1, p3)
>>> r1.ydirection
-oo
>>> r2.ydirection
0

r  rK   s    r7   r  Ray3D.ydirection
  r  r9   c                    U R                   R                  U R                  R                  :  a  [        R                  $ U R                   R                  U R                  R                  :X  a  [        R
                  $ [        R                  $ )a  The z direction of the ray.

Positive infinity if the ray points in the positive z direction,
negative infinity if the ray points in the negative z direction,
or 0 if the ray is horizontal.

See Also
========

xdirection

Examples
========

>>> from sympy import Point3D, Ray3D
>>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(-1, -1, -1), Point3D(-1, 0, 0)
>>> r1, r2 = Ray3D(p1, p2), Ray3D(p1, p3)
>>> r1.ydirection
-oo
>>> r2.ydirection
0
>>> r2.zdirection
0

)r4   r  r5   r
   r   r   r  rK   s    r7   
zdirectionRay3D.zdirection
  sS    6 7799twwyy ::WWYY$''))#66M%%%r9   r  )r/   r   r   r   r   r1   r   r  r  r  r   r   r9   r7   r'  r'  n
  sI    ,Z=& & &> & &> & &r9   r'  c                       \ rS rSrSrS rSrg)rM  i  aY  A line segment in a 3D space.

Parameters
==========

p1 : Point3D
p2 : Point3D

Attributes
==========

length : number or SymPy expression
midpoint : Point3D

See Also
========

sympy.geometry.point.Point3D, Line3D

Examples
========

>>> from sympy import Point3D, Segment3D
>>> Segment3D((1, 0, 0), (1, 1, 1)) # tuples are interpreted as pts
Segment3D(Point3D(1, 0, 0), Point3D(1, 1, 1))
>>> s = Segment3D(Point3D(4, 3, 9), Point3D(1, 1, 7)); s
Segment3D(Point3D(4, 3, 9), Point3D(1, 1, 7))
>>> s.points
(Point3D(4, 3, 9), Point3D(1, 1, 7))
>>> s.length
sqrt(17)
>>> s.midpoint
Point3D(5/2, 2, 8)

c                 h    [        USS9n[        USS9nX:X  a  U$ [        R                  " XU40 UD6$ )Nr
  r   )r   r  r1   r2   s       r7   r1   Segment3D.__new__6  r  r9   r   N)r/   r   r   r   r   r1   r   r   r9   r7   rM  rM    s    "F=r9   rM  )Hr   sympy.core.containersr   sympy.core.evalfr   sympy.core.exprr   sympy.core.numbersr   r   r   sympy.core.relationalr	   sympy.core.singletonr
   sympy.core.sortingr   sympy.core.symbolr   r   r   sympy.core.sympifyr   $sympy.functions.elementary.piecewiser   (sympy.functions.elementary.trigonometricr   r   r   r   entityr   r   
exceptionsr   r   r   r   utilr   r   sympy.logic.boolalgr   sympy.matricesr   sympy.sets.setsr   sympy.simplify.simplifyr!   sympy.solvers.solversr"   sympy.solvers.solvesetr#   sympy.utilities.miscr$   r%   r   rangerj   r   r)   r   r   r|   rh  r   r&  rL  r  r  r'  rM  )r  s   0r7   <module>r     sC  & (    2 2 $ " & C C & : R R / % ! $ # ! ( , ' 0 8  &+1X.XlX.1`; `F!g< gTh, hVcl cL	p\ pfj^T jZGNC GT@4 @4FH'\ H'Vc'^T c'La&NC a&H+= +=GW /s   +E