OpenSiv3D
OpenSiv3D copied to clipboard
Polygonとそれを構成している点の内包・交差判定
Polygonのソースファイルを拝見しましたところ、boostの処理を使用しているようなので厳しいのかもしれませんが、Polygonを構成している点が含まれていない、交差していないと判定されることでハマる場面があったので一応Issue投げておきます。
# include <Siv3D.hpp> // OpenSiv3D v0.6.3
void Main()
{
Scene::SetBackground(ColorF { 0.8, 0.9, 1.0 });
Polygon polygon { {100, 100}, {150, 100}, {200, 200}, {150, 200} };
Print << polygon.contains(Point { 100, 100 }); // true
Print << polygon.contains(Point { 150, 100 }); // true
Print << polygon.contains(Point { 200, 200 }); // false
Print << polygon.contains(Point { 150, 200 }); // false
Print << polygon.intersects(Point { 100, 100 }); // true
Print << polygon.intersects(Point { 150, 100 }); // true
Print << polygon.intersects(Point { 200, 200 }); // false
Print << polygon.intersects(Point { 150, 200 }); // false
while (System::Update()) {}
}
ご報告ありがとうございます。 確かに一貫性が感じられない結果だと思います。 今後 Polygon の実装をリフレッシュするときの検討事項とします。