#include "pch.hpp"

#include "EZVector.hpp"

EZVector::EZVector()
{
	m[0] = m[1] = m[2] = 0.0f;
}

EZVector::EZVector(EZVector * v)
{
	m[0] = v->m[0];
	m[1] = v->m[1];
	m[2] = v->m[2];
}


EZVector::EZVector(float x, float y, float z)
{
	m[0] = x;
	m[1] = y;
	m[2] = z;
}

void EZVector::Add(EZVector * toAdd)
{
	m[0] += toAdd->m[0];
	m[1] += toAdd->m[1];
	m[2] += toAdd->m[2];
}

void EZVector::Normalize(EZVector * result)
{
	float magnitude = (float) 
		sqrt(
			pow(m[0],2) + 
			pow(m[1],2) + 
			pow(m[2],2));

	result->m[0] = m[0] / magnitude;
	result->m[1] = m[1] / magnitude;
	result->m[2] = m[2] / magnitude;
}

float EZVector::Dot(EZVector * v1, EZVector * v2)
{
	return (v1->m[0] * v2->m[0]) + (v1->m[1] * v2->m[1]) + (v1->m[2] * v2->m[2]);
}

void EZVector::Cross(EZVector * in1, EZVector * in2, EZVector * out)
{
	out->m[0] = (in1->m[1] * in2->m[2]) - (in1->m[2]*in2->m[1]);
	out->m[1] = (in1->m[2] * in2->m[0]) - (in1->m[0]*in2->m[2]);
	out->m[2] = (in1->m[0] * in2->m[1]) - (in1->m[1]*in2->m[0]);
}

EZVector::~EZVector()
{
}