Advertisement
bojidar_blagoev

Untitled

Sep 8th, 2014
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.geom.Path2D;
  2. import java.awt.geom.Point2D;
  3. import java.util.Scanner;
  4.  
  5. public class PointsInsideHouse {
  6.     public static void main(String[] args) {
  7.        
  8.         @SuppressWarnings("resource")
  9.         Scanner input = new Scanner(System.in);
  10.        
  11.         double x = input.nextDouble();
  12.         double y = input.nextDouble();
  13.  
  14.         Path2D path = new Path2D.Double();
  15.  
  16.         Double corX[] = { 17.51 ,12.51, 12.51, 17.51, 17.51, 20.01, 20.01, 22.53, 22.53 };
  17.         Double corY[] = { 3.51, 8.51,  13.51, 13.51, 8.511,  8.51,  13.51, 13.53, 8.53 };
  18.         path.moveTo(corX[0], corY[0]);
  19.         for(int i = 1; i < corX.length; ++i) {
  20.            path.lineTo(corX[i], corY[i]);
  21.         }
  22.         path.closePath();
  23.  
  24.                 Point2D.Double p = new Point2D.Double(x, y);
  25.             boolean check = path.contains(p);
  26.             if (check) {
  27.             System.out.println("Inside");
  28.         }else{
  29.         System.out.println("Outside");
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement