Posted: Fri Sep 26

Due: Wednesday 10/1 10:00am

Woah

Backend Improvement: Matrixification

Implement the following features, but you cannot trivialize the problem by using a structure that already exists in the language you choose:

  • General Matrix stuff
    • creation of an identity matrix
    • displaying a matrix in a reasonable manner
    • matrix multiplication
  • Graphics matrix stuff
    • add a point to an edge matrix
    • add an edge to an edge matrix (should call your add point routine)
    • go through an edge matrix and draw the lines stored in the matrix (should call your draw line routine)
  • READ THROUGH ALL THE SOURCE FILES. Detailed instructions are provided as comments.
  • C SDL2 Note:
    • In order to use the sdl_display function defined in display.c, you need the following things:
      • Install libsdl2-dev and libsdl2-image-dev. Both are available as $ apt install packages on linux (including wsl), or on mac via homebrew.
      • In your makefile, include the following lines at the top (these are variable definitions).
        • SDL_CFLAGS := $(shell sdl2-config --cflags)
        • SDL_LFLAGS := $(shell sdl2-config --libs)
      • When compiling display.c into display.o, use: gcc $(SDL_CFLAGS) -c display.c
      • When making the full executable, include the following after the name of the compiled program: -lm $(SDL_LFLAGS) -lSDL2_image

Here is an example of output, including a correct matrix multiplication:

Testing add_edge. Adding (1, 2, 3), (4, 5, 6) m2 =
1.00 4.00
2.00 5.00
3.00 6.00
1.00 1.00

Testing ident. m1 =
1.00 0.00 0.00 0.00
0.00 1.00 0.00 0.00
0.00 0.00 1.00 0.00
0.00 0.00 0.00 1.00

Testing Matrix mult. m1 * m2 =
1.00 4.00
2.00 5.00
3.00 6.00
1.00 1.00

Testing Matrix mult. m1 =
1.00 4.00 7.00 10.00
2.00 5.00 8.00 11.00
3.00 6.00 9.00 12.00
1.00 1.00 1.00 1.00

Testing Matrix mult. m1 * m2 =
40.00 76.00
47.00 92.00
54.00 108.00
7.00 16.00