package com.getyourlocation.app.serviceserver.business.entity;

import com.getyourlocation.app.serviceserver.util.Algorithm;


/**
 * Point in rectangular coordinate.
 */
public class Point {
    public double x;
    public double y;

    public Point() {
        this(0, 0);
    }

    public Point(double x, double y) {
        this(x, y, false);
    }

    /**
     * Initialize a Point. If @param polar is true, the two arguments
     * are the radius and angle (in degrees) in polar coordinate.
     * Otherwise they are the x-coordinate and y-coordinate in rectangular
     * coordinate.
     */
    public Point(double arg1, double arg2, boolean polar) {
        if (polar) {
            this.x = arg1 * Math.cos(Math.toRadians(arg2));
            this.y = arg1 * Math.sin(Math.toRadians(arg2));
        } else {
            this.x = arg1;
            this.y = arg2;
        }
    }

    /**
     * Add offset to two coordinates.
     */
    public void addOffset(double offset) {
        x += offset;
        y += offset;
    }

    /**
     * Return the distance between two points.
     */
    public static double dist(Point p1, Point p2) {
        double dx = p1.x - p2.x;
        double dy = p1.y - p2.y;
        return Math.sqrt(dx * dx + dy * dy);
    }

    /**
     * Generate a point with random coordinates.
     */
    public static Point rand(double min, double max) {
        return new Point(Algorithm.randDouble(min, max), Algorithm.randDouble(min, max));
    }

    @Override
    public String toString() {
        return "(" + x + ", " + y + ")";
    }
}

@@ -647,32 +647,141 @@
 oolean polar) %7B%0A
+        if (Double.isNaN(arg1) %7C%7C Double.isNaN(arg2)) %7B%0A            this.x = this.y = 0;%0A        %7D else%7B%0A    
         if (pola
@@ -777,32 +777,36 @@
    if (polar) %7B%0A
+    
             this
@@ -841,32 +841,36 @@
 Radians(arg2));%0A
+    
             this
@@ -917,24 +917,28 @@
 ));%0A        
+    
 %7D else %7B%0A   
@@ -934,16 +934,20 @@
  else %7B%0A
+    
         
@@ -969,32 +969,36 @@
 g1;%0A            
+ 
+   
 this.y = arg2;%0A 
@@ -996,16 +996,30 @@
 = arg2;%0A
+            %7D%0A
         

Set Point to (0,0) when x or y is NAN