これにより、任意のポリゴンについて、交差するすべてのセグメントが検出されます。
ポリゴンをエッジAB、BC、CDなどの順序付けられたコレクションと見なします。ここで、各エッジの最初のポイントから2番目のポイントへの「方向」は「時計回り」です。つまり、ポイントAを見ると、時計回りに移動するとポイントBが次のポイントになります。
この方法は、平面と交差するポリゴンのエッジを見つけてから、時計回りに移動して、平面の元の側面に戻る次のセグメントを見つけることです。これらのセグメントが平面と交差する2つのポイントは、交差するセグメントの端点を形成します。これは、すべてのポリゴンのエッジがチェックされるまで繰り返されます。
ポリゴンが凹面の場合、必ずしもすべてのセグメントがポリゴン内にあるとは限らないことに注意してください。
let P be any point on the polygon.
TOP:
while (P has not been checked)
mark P as having been checked.
let f be the point following P, clockwise.
if (P and f are on opposite sides of the plane) then
Continuing from f clockwise, find the next point Y that is on
the same side of the plane as P.
Let z be the point counter-clockwise from Y.
(note - Sometimes z and f are the same point.)
let S1 be the point where P,f intersects the plane
let S2 be the point where Y,z intersects the plane
if (segment (S1,S2) is inside the polygon)
add (S1,S2) to a 'valid' list.
let P = Y
else
let P = f
endif
else
let P = f
endif
endwhile
このアルゴリズムはあなたがそれに対して支払ったものの価値があります。:-)