Asymptotically optimal algorithm to compute if a line intersects a convex polygon

前端 未结 5 916
北荒
北荒 2021-02-01 05:25

An O(n) algorithm to detect if a line intersects a convex polygon consists in checking if any edge of the polygon intersects the line, and look if the number of intersections is

5条回答
  •  隐瞒了意图╮
    2021-02-01 06:12

    Bounding boxes may prove useful.

    Recall that a convex part of an affine space is the intersection of all its envelope hyperplanes: you could get an approximation of your polygon (read a "bounding convex polygon") by considering only the intersection of a subset of the envelope hyperplanes, test for intersection of your line with this approximation, and refine if necessary.

    All this works better if you expect a low number of intersections.

提交回复
热议问题