#ifndef _VECTOR
#define _VECTOR

#include <iostream>
using std::ostream;
using std::istream;

#include "amra_point.h"

class Vector {
	float X;
	float Y;
	float Z;
public:
	Vector() {X=Y=Z=0.0;}
	Vector(float,float,float);
	
	Vector(const Vector&);	  		//initialisation from another
	Vector& operator=(const Vector&); 	//assignment
	
	friend Vector operator-(const Point&,const Point&);//Vector = Point-Point
	friend Vector operator+(const Point&, const Point&);//Vector = Point+Point
	friend Point operator+(const Point&, const Vector&);
	friend Vector operator+(const Vector &, const Vector&);
        
	Vector &operator+=(const Vector &v) {
            X += v.X;
            Y += v.Y;
            Z += v.Z;
            return *this;
        }
	Vector &operator-=(const Vector &v) {
            X -= v.X;
            Y -= v.Y;
            Z -= v.Z;
            return *this;
        }

	float squarednorm() const;			//returns square of norm
	float norm() const;				//returns norm
	void normalise();			//normalises 
	void normalise(float& norm);			//normalises 
	Vector invert() const;

	void rotate2D_Z(float angle);
	void rotate2D_X(float angle);

	Vector normalised() const;			//returns normalised vector
	Vector normalised(float& norm) const;
	friend Vector add(const Vector&,const Vector&);	       	//add two vectors
	friend Vector minus(const Vector&,const Vector&);	       	//subtract
	friend float operator^(const Vector&,const Vector&);   //dot product

	//friend Vector operator*(const Vector&,const Vector&); //cross product
	friend Vector operator*(const Vector&, float);//Vector = vector * scalar
	friend Vector operator*(float, const Vector&);//Vector = vector * scalar
	
	float &x() {return X;}
	float &y() {return Y;}
	float &z() {return Z;}

	float x() const {return X;}
	float y() const {return Y;}
	float z() const {return Z;}
		
	friend ostream& operator<<(ostream&,const Vector);  //writing
	friend istream& operator>>(istream&,Vector&); //reading
};

#endif
