001    package aima.search.map;
002    
003    /**
004     * Simplified version of <code>java.awt.geom.Point2D</code>. We do not
005     * want dependencies to presentation layer packages here.
006     * @author R. Lunde
007     */
008    public class Point2D {
009            private double x;
010            private double y;
011            
012            public Point2D(double x, double y) {
013                    this.x = x;
014                    this.y = y;
015            }
016    
017            public double getX() {
018                    return x;
019            }
020    
021            public double getY() {
022                    return y;
023            }
024            
025            /**
026             * Returns the Euclidean distance between a specified point
027             * and this point.
028             */
029            public double distance(Point2D pt) {
030                    double result = (pt.getX() - x) * (pt.getX() - x);
031                    result += (pt.getY() - y) * (pt.getY() - y);
032                    return Math.sqrt(result);
033            }
034    }