You code should be such that the following main.c
file works unaltered:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include "vector.h"
#include "matrix.h"
#include "pixel.h"
#include "list.h"
#include "material.h"
#include "object.h"
#include "model.h"
int main()
{
vec_t v1 = {1.0, 0.0, 1.0};
vec_t v2 = {1.0, 1.0, 1.0};
vec_t v7 = {2.0, 1.0, 0.5};
vec_t v3;
vec_t v4;
vec_t v5;
mtx_t m1;
mtx_t m2;
// convert initial vectors to unit vecs and print
vec_unit(v1, v1);
vec_unit(v2, v2);
vec_print(stderr, "v1 ", v1);
vec_print(stderr, "v2 ", v2);
fprintf(stderr, "\n");
vec_cross(v2, v7, v7);
fprintf(stderr, "\n Cross product\n");
vec_print(stderr, "v7 ", v7);
// reflect -v7 off plane whose normal is v2
vec_unit(v7, v7);
vec_reflect(v2, v7, v7);
fprintf(stderr, "\n Reflected vector\n");
vec_print(stderr,"v7 ", v7);
// project v1 onto plane whose normal is v2
vec_project(v2, v1, v5);
vec_unit(v5, v5);
fprintf(stderr, "\n Projected vector\n");
vec_print(stderr, "v5 ", v5);
fprintf(stderr, "\n");
// now create a matrix that will rotate v2 into the z-axis
// v1 into the x = 0 plane with positive y component
vec_cross(v1, v2, m1[0]);
vec_unit(m1[0], m1[0]); // DON"T FORGET ME
vec_copy(v2, m1[2]);
vec_cross(m1[2], m1[0], m1[1]);
fprintf(stderr," Rotation Matrix \n");
vec_print(stderr, "r0 ", m1[0]);
vec_print(stderr, "r1 ", m1[1]);
vec_print(stderr, "r2 ", m1[2]);
fprintf(stderr, "\n");
// verify that it worked
vec_xform(m1, v1, v3);
vec_xform(m1, v2, v4);
fprintf(stderr, " Transformed v1 v2\n");
vec_print(stderr, "v3 ", v3);
vec_print(stderr, "v4 ", v4);
fprintf(stderr, "\n");
// build the inverse of the rotation
mat_xpose(m1, m2);
fprintf(stderr," Transpose Matrix \n");
vec_print(stderr, "r0 ", m2[0]);
vec_print(stderr, "r1 ", m2[1]);
vec_print(stderr, "r2 ", m2[2]);
fprintf(stderr,"\n");
// and verify that it all worked
vec_xform(m2, v3, v3);
vec_xform(m2, v4, v4);
fprintf(stderr, " Inverse transform\n");
vec_print(stderr, "v3 ", v3);
vec_print(stderr, "v4 ", v4);
fprintf(stderr, "\n");
return(0);
}