package automatvgi.tools;


public class Vector {
	private double x,y;
	
	public double getX() {
		return x;
	}

	public double getY() {
		return y;
	}

	public Vector(Point p, Point q){
		x=q.getX()-p.getX(); y=q.getY()-p.getY();
	}

	public Vector(double x, double y){
		this.x=x; this.y=y;
	}
		
	public Vector(Vector v){
		this.x=v.x; this.y=v.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;
		Vector other = (Vector) obj;
		if (Double.doubleToLongBits(x) != Double.doubleToLongBits(other.x))
			return false;
		if (Double.doubleToLongBits(y) != Double.doubleToLongBits(other.y))
			return false;
		return true;
	}

	public void add(Vector v){
		x+=v.x; y+=v.y;
	}
		
	public void rot(double alpha){
		double nx=x*Math.cos(alpha)+y*Math.sin(alpha);
		y=-x*Math.sin(alpha)+y*Math.cos(alpha);
		x=nx;
	}
	
	public void scal(double alpha){
		x*=alpha;
		y*=alpha;
	}
	
	public double norm(){
		return Math.hypot(x, y);
	}
	
	
	
	
}
