OpenSiv3D icon indicating copy to clipboard operation
OpenSiv3D copied to clipboard

Polygonとそれを構成している点の内包・交差判定

Open ghost opened this issue 3 years ago • 1 comments

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()) {}
}

ghost avatar Feb 18 '22 17:02 ghost

ご報告ありがとうございます。 確かに一貫性が感じられない結果だと思います。 今後 Polygon の実装をリフレッシュするときの検討事項とします。

Reputeless avatar Feb 18 '22 23:02 Reputeless