package automatvgi.tools;


public class Point {
	private double x,y;
	
	public Point(){
		//empty
	}
	
	public Point(double x,double y){
		this.x=x; this.y=y;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(x);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(y);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Point other = (Point) obj;
		if (Double.doubleToLongBits(x) != Double.doubleToLongBits(other.x))
			return false;
		if (Double.doubleToLongBits(y) != Double.doubleToLongBits(other.y))
			return false;
		return true;
	}

	public Point(Point p){
		this.x=p.x; this.y=p.y;
	}
	
	
	
	public Point addTo(Vector v){
		Point p=new Point(x,y);
		p.x+=v.getX(); p.y+=v.getY();		
		return p;
	}

	public Point subTo(Vector v){
		Point p=new Point(x,y);
		p.x-=v.getX(); p.y-=v.getY();		
		return p;
	}
	
	
	public Point convert(Point o, Point i){
		Point p=new Point(0,0);
		double dx=i.x-o.x, dy=i.y-o.y;
		p.x=x*dx-y*dy+o.x;
		p.y=x*dy+y*dx+o.y;
		return p;
	}

	public double getX() {
		return x;
	}

	public double getY() {
		return y;
	}
	public void setX(double x) {
		this.x = x;
	}

	public void setY(double y) {
		this.y = y;
	}

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