ポリゴンクラスを使用して、与えられたポイントのポイントが三角形の内側にあるかどうかを調べましたが、三角形の外側にあるかどうかを判断する方法はわかりません。ここまでは私のコードです。ポイントが三角形の上にあるかどうかのテスト
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int c =0;
Polygon p = new Polygon();
p.addPoint(s.nextInt(), s.nextInt());
p.addPoint(s.nextInt(), s.nextInt());
p.addPoint(s.nextInt(), s.nextInt());
int y = 3;
while(y-->0)
{
if(p.contains(s.nextDouble(),s.nextDouble()))
c++;
}
System.out.print(c);
}
私はデルタ値を使用します。ある種の閾値。 'dist <0.0001d' –