/*
  Copyright (c) 2014 Alex Diener
  
  This software is provided 'as-is', without any express or implied
  warranty. In no event will the authors be held liable for any damages
  arising from the use of this software.
  
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
  
  Alex Diener adiener@sacredsoftware.net
*/

#ifndef __Vector3f_H__
#define __Vector3f_H__
#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>

typedef struct Vector3f Vector3f;

struct Vector3f {
	float x;
	float y;
	float z;
};

#define VECTOR3f_ZERO  ((Vector3f) {0.0f, 0.0f, 0.0f})
#define VECTOR3f_LEFT  ((Vector3f) {-1.0f,  0.0f, 0.0f})
#define VECTOR3f_RIGHT ((Vector3f) { 1.0f,  0.0f, 0.0f})
#define VECTOR3f_DOWN  ((Vector3f) { 0.0f, -1.0f, 0.0f})
#define VECTOR3f_UP    ((Vector3f) { 0.0f,  1.0f, 0.0f})
#define VECTOR3f_BACK  ((Vector3f) { 0.0f,  0.0f, -1.0f})
#define VECTOR3f_FRONT ((Vector3f) { 0.0f,  0.0f,  1.0f})

#define VECTOR3f(x, y, z) ((Vector3f) {x, y, z})

bool Vector3f_normalize(Vector3f * vector);
Vector3f Vector3f_normalized(Vector3f vector);

float Vector3f_magnitude(Vector3f vector);
float Vector3f_magnitudeSquared(Vector3f vector);

bool Vector3f_scaleTo(Vector3f * vector, float magnitude);
Vector3f Vector3f_scaledTo(Vector3f vector, float magnitude);

float Vector3f_distance(Vector3f vector1, Vector3f vector2);
float Vector3f_distanceSquared(Vector3f vector1, Vector3f vector2);

Vector3f Vector3f_add(Vector3f vector1, Vector3f vector2);
Vector3f Vector3f_subtract(Vector3f vector1, Vector3f vector2);
Vector3f Vector3f_multiplyScalar(Vector3f vector, float scalar);
Vector3f Vector3f_divideScalar(Vector3f vector, float scalar);

Vector3f Vector3f_interpolate(Vector3f left, Vector3f right, float value);

Vector3f Vector3f_reflect(Vector3f vector, Vector3f normal);
Vector3f Vector3f_project(Vector3f vector, Vector3f normal);

float Vector3f_dot(Vector3f vector1, Vector3f vector2);
Vector3f Vector3f_cross(Vector3f vector1, Vector3f vector2);

#ifdef __cplusplus
}
#endif
#endif
