#include "point3D.h"

point3D::point3D(float a, float b, float c)
{
	point[0] = a;
	point[1] = b;
	point[2] = c;
}
point3D::point3D()
{
}
point3D point3D::operator+(point3D p2)
{
	point3D temp(point[0]+p2[0],point[1]+p2[1],point[2]+p2[2]);
	return temp;
}
point3D point3D::operator-(point3D p2)
{
	point3D temp(point[0]-p2[0],point[1]-p2[1],point[2]-p2[2]);
	return temp;
}
point3D point3D::operator*(float s)
{
	// How to overload operators:
	// http://www.cplusplus.com/doc/tutorial/classes2.html
	point3D temp;
	temp.setValues(point[0]*s,point[1]*s, point[2]*s);
	return (temp);
}
point3D point3D::operator/(float s)
{
	point3D temp(point[0],point[1],point[2]);
	// Initialize value of temp to point.
	// If divide by zero error, return unchanged point. 
	if( s != 0)
	{
		temp.setValues(point[0]/s,point[1]/s, point[2]/s);
		return (temp);
	}
	return temp;
}
float point3D::operator [] (int pos)
{
	// TODO: Find out how to differentiate between:
	// x[0] = 4;
	// and float y = x[0];
	return (point[pos]);
}
void point3D::setValues(float a, float b, float c)
{
	point[0] = a;
	point[1] = b;
	point[2] = c;
}

