我有两条相交的线段,并知道它们的端点。如何在Python中计算交点?
# Given these endpoints
#line 1
A = [X, Y]
B = [X, Y]
#line 2
C = [X, Y]
D = [X, Y]
# Compute this:
point_of_intersection = [X, Y]
我有两条相交的线段,并知道它们的端点。如何在Python中计算交点?
# Given these endpoints
#line 1
A = [X, Y]
B = [X, Y]
#line 2
C = [X, Y]
D = [X, Y]
# Compute this:
point_of_intersection = [X, Y]
>>> from euclid import Line2, Point2
>>> l1 = Line2(Point2(1.0, 2.0), Point2(3.0, 4.0))
>>> l2 = Line2(Point2(3.0, 4.0), Point2(-5.0, 6.0))
>>> l1.intersect(l2)
Point2(3.00, 4.00)