Vec3 *vec3_alloc()Return a pointer to a new (zero) Vec3
Vec3 *vec3_make(Vec3 u)Return a pointer to a copy of u.
void vec3_free(Vec3 *v)For completeness, just calls rfree.
The above functions are generally used to create lists of vectors, there is seldom any other reason to use alloc-ed vectors.
Vec3 vec3(double x, double y, double z)Returns vector with components (x, y, z).
Vec3 vec3_zero() Returns zero vector.
Vec3 vec3_ex() Vec3 vec3_ey() Vec3 vec3_ez()Return unit vectors in x, y or z directions.
Macro vec3_x(Vec3 v) Macro vec3_y(Vec3 v) Macro vec3_z(Vec3 v)Macros to get x, y, z components of vector (can be used on both sides of assignment statements).
double vec3_get_x(double v) double vec3_get_x(double v) double vec3_get_x(double v)Function versions of above macros useful for passing as arguments to functions.
void vec3_comps(Vec3 v, float *x, float *y, float *z)Recover x, y and z components from a vector v all at once.
Vec3 vec3_sum(Vec3 v, Vec3 w) Vec3 vec3_sum3(Vec3 u, Vec3 v, Vec3 w) Vec3 vec3_sum4(Vec3 u, Vec3 v, Vec3 w, Vec3 x)Returns sum of two three or four vectors.
Vec3 vec3_minus(Vec3 v)Returns negative of v.
Vec3 vec3_diff(Vec3 v, Vec3 w)Returns difference v-w of two vectors.
Vec3 vec3_times(double k, Vec3 v)Returns product of a scalar and a vector kv.
double vec3_dot(Vec3 v, Vec3 w)Returns dot (scalar) product of two vectors.
Vec3 vec3_cross(Vec3 v, Vec3 w)Returns cross (vector) product of two vectors.
Vec3 vec3_unitcross(Vec3 v, Vec3 w)Returns unit vector in direction of cross product of two vectors.
double vec3_mod(Vec3 v)Returns modulus (length) of a vector.
double vec3_sqrmod(Vec3 v)Returns squared modulus of a vector.
Vec3 vec3_unit(Vec3 v)Returns unit vector in direction of a vector.
double vec3_modunit(Vec3 v, Vec3 *e)Returns modulus of a vector and sets *e to unit vector in direction of vector, useful for checking if v is zero before using *e.
double vec3_dist(Vec3 v, Vec3 w)Returns distance between two 3D points.
double vec3_sqrdist(Vec3 v, Vec3 w)Returns squared distance between two 3D points.
double vec3_angle(Vec3 v, Vec3 w)Returns angle between two vectors.
Vec3 vec3_perp(Vec3 v)Returns a vector (there are many!) perpendicular to v.
void vec3_basis(Vec3 aim, Vec3 down, Vec3 *ex, Vec3 *ey, Vec3 *ez)Sets up a unit basis with z-axis along aim and y-axis in plane of vectors aim and down (we usually think of z-axes as line of sight and y-axes point down, as in images). If this fails (aim = down) a sensible y-axis is chosen (this can lead to discontinuous changes in basis as down changes, this is unavoidable).
Vec3 vec3_read(File *fp)Return next vector read in from ascii file, on error warns and returns zero vector.
void vec3_print(File *fp, Vec3 v)Writes out vector to ascii file.
void vec3_pprint(File *fp, char *msg, Vec3 v)Prints message and vector to ascii file.
void vec3_format(Vec3 v)Writes out vector to Tina format destination (stdout or main textsw).