Python 如何获取线系的所有交点的列表

Python 如何获取线系的所有交点的列表,python,Python,我有一个方程组 x=1,y=1,x+y=1,x+y=2。 如何获得由上述方程式形成的多边形的顶点。使用: 屈服 eqns: (x - 1, y - 1) --> soln: {x: 1, y: 1} eqns: (x - 1, x + y - 1) --> soln: {x: 1, y: 0} eqns: (x - 1, x + y - 2) --> soln: {x: 1, y: 1} eqns: (y - 1, x + y - 1) --> soln: {x: 0,

我有一个方程组 x=1,y=1,x+y=1,x+y=2。 如何获得由上述方程式形成的多边形的顶点。

使用:

屈服

eqns: (x - 1, y - 1) --> soln: {x: 1, y: 1}
eqns: (x - 1, x + y - 1) --> soln: {x: 1, y: 0}
eqns: (x - 1, x + y - 2) --> soln: {x: 1, y: 1}
eqns: (y - 1, x + y - 1) --> soln: {x: 0, y: 1}
eqns: (y - 1, x + y - 2) --> soln: {x: 1, y: 1}
eqns: (x + y - 1, x + y - 2) --> soln: []
soln: [(1.0, 1.0)]
soln: [(1.0, 0.0)]
soln: [(1.0, 1.0)]
soln: [(0.0, 1.0)]
soln: [(1.0, 1.0)]

如果在定义多边形边的直线上有点,而不是方程, 然后,您可以使用查找线的交点:

import itertools as IT
import shapely.geometry as SG


lines = [SG.LineString([(1,-10),(1,10)]),
         SG.LineString([(-10, 1),(10, 1)]),
         SG.LineString([(-10, 11),(10, -9)]),
         SG.LineString([(-10, 12),(10, -8)])]
for line1, line2 in IT.combinations(lines, 2):
    soln = line1.intersection(line2)
    if isinstance(soln, SG.point.Point):
        print('soln: {}'.format(list(soln.coords)))
屈服

eqns: (x - 1, y - 1) --> soln: {x: 1, y: 1}
eqns: (x - 1, x + y - 1) --> soln: {x: 1, y: 0}
eqns: (x - 1, x + y - 2) --> soln: {x: 1, y: 1}
eqns: (y - 1, x + y - 1) --> soln: {x: 0, y: 1}
eqns: (y - 1, x + y - 2) --> soln: {x: 1, y: 1}
eqns: (x + y - 1, x + y - 2) --> soln: []
soln: [(1.0, 1.0)]
soln: [(1.0, 0.0)]
soln: [(1.0, 1.0)]
soln: [(0.0, 1.0)]
soln: [(1.0, 1.0)]