/*
  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 __Vector2f_H__
#define __Vector2f_H__
#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>

typedef struct Vector2f Vector2f;

struct Vector2f {
	float x;
	float y;
};

#define VECTOR2f_ZERO  ((Vector2f) {0.0f, 0.0f})
#define VECTOR2f_LEFT  ((Vector2f) {-1.0f,  0.0f})
#define VECTOR2f_RIGHT ((Vector2f) { 1.0f,  0.0f})
#define VECTOR2f_DOWN  ((Vector2f) { 0.0f, -1.0f})
#define VECTOR2f_UP    ((Vector2f) { 0.0f,  1.0f})

#define VECTOR2f(x, y) ((Vector2f) {x, y})

bool Vector2f_normalize(Vector2f * vector);
Vector2f Vector2f_normalized(Vector2f vector);

float Vector2f_magnitude(Vector2f vector);
float Vector2f_magnitudeSquared(Vector2f vector);

bool Vector2f_scaleTo(Vector2f * vector, float magnitude);
Vector2f Vector2f_scaledTo(Vector2f vector, float magnitude);

float Vector2f_distance(Vector2f vector1, Vector2f vector2);
float Vector2f_distanceSquared(Vector2f vector1, Vector2f vector2);

Vector2f Vector2f_add(Vector2f vector1, Vector2f vector2);
Vector2f Vector2f_subtract(Vector2f vector1, Vector2f vector2);
Vector2f Vector2f_multiplyScalar(Vector2f vector, float scalar);
Vector2f Vector2f_divideScalar(Vector2f vector, float scalar);

Vector2f Vector2f_interpolate(Vector2f left, Vector2f right, float value);

Vector2f Vector2f_reflect(Vector2f vector, Vector2f normal);
Vector2f Vector2f_project(Vector2f vector, Vector2f normal);
Vector2f Vector2f_rotate(Vector2f vector, float radians);

float Vector2f_dot(Vector2f vector1, Vector2f vector2);
float Vector2f_cross(Vector2f vector1, Vector2f vector2);

#ifdef __cplusplus
}
#endif
#endif
