/* * vector.h * * Vector math. * */ typedef struct { float x, y, z; } vector; #define UNPACK_VECTOR(v) v.x, v.y, v.z vector make_vector(float x, float y, float z); // Vector arithmetic. vector vec_add(vector a, vector b); vector vec_sub(vector a, vector b); float vec_dot(vector a, vector b); vector vec_cross(vector a, vector b); vector vec_mult(vector a, float b); vector vec_div(vector a, float b); // Reverses the direction. vector vec_neg(vector a); // Magnitude. float vec_mag(vector a); // Scale vector so magnitude == 1. vector normalize(vector a); extern const vector zero_vector;