Anonymous user
Find the intersection of two lines: Difference between revisions
→{{header|Python}}: Describe approaches (proced/func) and mark library w header
m (→{{header|Python}}: Reorganize examples--native, internal lib, external lib) |
(→{{header|Python}}: Describe approaches (proced/func) and mark library w header) |
||
Line 1,356:
=={{header|Python}}==
Find the intersection procedurally, with no imports.
<lang python>def line_intersect(Ax1, Ay1, Ax2, Ay2, Bx1, By1, Bx2, By2):
""" returns a (x, y) tuple or None if there is no intersection """
Line 1,380:
{{Out}}
<pre>(5.0, 5.0)</pre>
{{Works with|Python|3.7}}
Find the intersection using a functional approach, by importing [https://docs.python.org/3/library/functools.html functools.reduce]
<lang python>'''The intersection of two lines.'''
Line 1,497:
{{out}}
<pre>(5.0, 5.0)</pre>
{{libheader|Shapely}}
<lang python>from shapely.geometry import LineString
|