#include <stdlib.h>
#include <math.h>
#include "vector.h"

Vector operator+(const Vector &a, const	Vector &b)
{
 Vector	sum(a.x+b.x,a.y+b.y);
 return	(sum);
}

Vector operator*(double a, const Vector	&b)
{
 Vector	prod(a*b.x,a*b.y);
 return	(prod);
}
Vector operator/(const Vector &a, double b)
{
 Vector	quotient(a.x/b,a.y/b);
 return	(quotient);
}

Vector operator-(const Vector &a, const	Vector &b)
{
 Vector	difference(a.x-b.x,a.y-b.y);
 return	(difference);
}

Vector::Vector(double i, double j)
{
 x=i;
 y=j;
}

Vector::Vector(const Vector &value)
{
 x=value.x;
 y=value.y;
}

Vector::~Vector()
{
}

double mag(const Vector &r)
{
 double	mag=sqrt(r.x*r.x+r.y*r.y);
 return	mag;
}

void Vector::set(double i, double j)
{
 x=i;
 y=j;
}

void swap(Vector &a, Vector &b){
	Vector t;
	t=a;
	a=b;
	b=t;
}


Vector Vrand(){
	return(Vector((rand()%100-rand()%100)*0.0025,(rand()%100-rand()%100)*0.0025));
}

Vector Prand(){
	return (Vector(rand()%XMAX,rand()%YMAX));
}
