Segments Intersection · Nhóm: Hình học
Giao hai đoạn thẳng (Segments Intersection), nhóm Hình học.
def segments_intersect(A, B, C, D):
d1 = orient(A, B, C)
d2 = orient(A, B, D)
# C, D on same side of AB?
d3 = orient(C, D, A)
d4 = orient(C, D, B)
if d1 * d2 < 0 and d3 * d4 < 0:
return intersection_point(A, B, C, D)
return None
Mở trang để xem mô phỏng từng bước và xuất slide bài giảng.