Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.geom.Path2D;
- import java.awt.geom.Point2D;
- import java.util.Scanner;
- public class PointsInsideHouse {
- public static void main(String[] args) {
- @SuppressWarnings("resource")
- Scanner input = new Scanner(System.in);
- double x = input.nextDouble();
- double y = input.nextDouble();
- Path2D path = new Path2D.Double();
- Double corX[] = { 17.51 ,12.51, 12.51, 17.51, 17.51, 20.01, 20.01, 22.53, 22.53 };
- Double corY[] = { 3.51, 8.51, 13.51, 13.51, 8.511, 8.51, 13.51, 13.53, 8.53 };
- path.moveTo(corX[0], corY[0]);
- for(int i = 1; i < corX.length; ++i) {
- path.lineTo(corX[i], corY[i]);
- }
- path.closePath();
- Point2D.Double p = new Point2D.Double(x, y);
- boolean check = path.contains(p);
- if (check) {
- System.out.println("Inside");
- }else{
- System.out.println("Outside");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement