#ifndef SVECTOR_CLASS_0487692716745970
#define SVECTOR_CLASS_0487692716745970

#include <math.h>

#define PI2 3.1456 / 180

struct sVector
{
	float x, y, z;
	
  sVector()
  {
    x = 0;
    y = 0;
    z = 0;
  }
	
	sVector(float x, float y, float z)
	{
    this->x = x;
    this->y = y;
    this->z = z;
  }

	sVector CrossProduct(sVector *vector)
	{
		sVector result;
		result.x = this->y * vector->z - this->z * vector->y;
		result.y = this->z * vector->x - this->x * vector->z;
		result.z = this->x * vector->y - this->y * vector->x;
		return result;
	}

	float DotProduct(sVector *vector)
	{
		float result;
		result = this->x * vector->x +
			this->y * vector->y + this->z * vector->z;
		return result;
	}

	float Angle(sVector *vector)
	{
		return acos(this->DotProduct(vector)/
			(this->Magnitude() * vector->Magnitude()));
	}

	float Magnitude()
	{
		return sqrt(this->x * this->x 
			+ this->y * this->y + this->z * this->z); 
	}

	sVector Difference(sVector *vector)
	{
		sVector result;
		result.x = this->x - vector->x;
		result.y = this->y - vector->y;
		result.z = this->z - vector->z;
		return result;
	}

	sVector Sum(sVector *vector)
	{
		sVector result;
		result.x = this->x + vector->x;
		result.y = this->y + vector->y;
		result.z = this->z + vector->z;
		return result;
	}

	void Scale(float factor)
	{
		this->x *= factor;
		this->y *= factor;
		this->z *= factor;
	}

	void Normalize()
	{
		float magnitude = this->Magnitude();
		this->x = this->x * (1/magnitude);
		this->y = this->y * (1/magnitude);
		this->z = this->z * (1/magnitude);
	}

	float Distance(sVector *vector)
	{
		sVector sum = this->Sum(vector);
		return sqrt(sum.x * sum.x + sum.y * sum.y + sum.z * sum.z);
	}
};

#endif
