2013-09-05 22:54:45 -07:00
|
|
|
/* basics.h
|
|
|
|
*
|
|
|
|
* Declaration of basic types: Vector.
|
|
|
|
*
|
|
|
|
* Eryn Wells <eryn@erynwells.me>
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __BASICS_H
|
|
|
|
#define __BASICS_H
|
|
|
|
|
2013-09-06 23:03:08 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2013-09-05 22:54:45 -07:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
float x, y, z;
|
|
|
|
} Vector3;
|
|
|
|
|
|
|
|
|
|
|
|
extern const Vector3 ZeroVector3;
|
|
|
|
|
|
|
|
|
|
|
|
Vector3 vector_init(float x, float y, float z);
|
|
|
|
Vector3 vector_mult_scalar(Vector3 v, float f);
|
|
|
|
Vector3 vector_mult_vector(Vector3 v, Vector3 f);
|
2013-09-07 18:26:05 -07:00
|
|
|
Vector3 vector_sub_vector(Vector3 m, Vector3 s);
|
2013-09-06 15:31:38 -07:00
|
|
|
float vector_length2(Vector3 v);
|
|
|
|
float vector_length(Vector3 v);
|
2013-09-07 18:26:05 -07:00
|
|
|
float vector_dot(Vector3 v, Vector3 f);
|
|
|
|
|
2013-09-06 15:31:38 -07:00
|
|
|
Vector3 vector_normalize(Vector3 v);
|
2013-09-05 22:54:45 -07:00
|
|
|
|
|
|
|
|
2013-09-06 19:01:02 -07:00
|
|
|
typedef struct {
|
|
|
|
float x, y;
|
|
|
|
float w, h;
|
|
|
|
} Rect;
|
|
|
|
|
|
|
|
Rect rect_init(float x, float y, float h, float w);
|
|
|
|
|
|
|
|
|
2013-09-06 21:15:56 -07:00
|
|
|
typedef struct {
|
|
|
|
Vector3 location;
|
|
|
|
Vector3 direction;
|
|
|
|
} Ray;
|
|
|
|
|
|
|
|
Ray ray_init(Vector3 location, Vector3 direction);
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2013-09-06 23:03:08 -07:00
|
|
|
uint8_t red, green, blue, alpha;
|
2013-09-06 21:15:56 -07:00
|
|
|
} Color;
|
|
|
|
|
|
|
|
|
2013-09-05 22:54:45 -07:00
|
|
|
#endif
|