#sympyで線分と線分の交点
from sympy import *
sg1,sg2 = Segment( Point(0,0), Point(1,1)),Segment( Point(0,1), Point(1,0))
ls = intersection(sg1,sg2)
print(ls)
ls = intersection(sg1,sg2)[0]
print(ls,ls.x,ls.y)
sg1,sg2 = Segment( Point(0,0), Point(0.3,0.3)), Segment( Point(0,1), Point(1,0))
ls = intersection(sg1,sg2)
print(ls)
#
# [Point2D(1/2, 1/2)]
# Point2D(1/2, 1/2) 1/2 1/2
# []
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme