Assignment contents:
For this assignment, although my previous homework provided a solid foundation, I still refactored my Matrix4x4 / Vector4 math system to make it cleaner and more complete for this mini-renderer. This includes matrix multiplication, matrix–vector multiplication, transpose, and the w-component convention to distinguish points vs. directions. On top of that, I built the full pipeline for TRS, View, Projection, and the mapping from Clip/NDC space to pixel coordinates. To validate the implementation, I created two tests (Test and Test_Advanced) and then visualized the final result.
Test (Direct verification using the assignment parameters)
In the first test, I strictly used the parameters provided by the assignment to construct and print:-
World (TRS): W = T * R * S, with rotation composed as R = Rz * Ry * Rx
-
View: V = R^T * T(-C) (the inverse of the camera’s world transform)
-
Projection: both the Orthographic and Perspective projection matrices
-
Final: MVP = P * V * W
Then, for the 8 vertices of the unit cube, I applied the full chain:
clip = MVP * local_point
ndc = clip / w
screen/pixel mapping
and printed each vertex’s local / clip / ndc / pixel values for inspection.
Test_Advanced (A more standard approach with a Camera class)
After the first test worked, I implemented an additional Camera class to better match a standard graphics pipeline structure. This class encapsulates camera parameters and generates the corresponding matrices (especially V and P, along with resolution/frustum-related setup). In Test_Advanced, I regenerated V and P through the Camera class and combined them with the same W to form:MVP = P * V * W
I then repeated the same vertex transformation and pixel mapping process to ensure both approaches produced consistent results.
Visualization (matplotlib is only used for drawing)
To present the final result, I used matplotlib to draw the points and edges after they were projected into pixel space (scatter/plot for points and line segments, plus axis limits and grid display). Matplotlib is only used for rendering the lines/points— all computations (matrix construction, vertex transforms, perspective divide, and NDC-to-pixel mapping) are performed entirely by my own code. Matplotlib does not participate in any of the math; it simply visualizes the pixel coordinates I computed.P4V:
I wrote the code in PyCharm. In the PyCharm project, I set up a virtual environment and installed the required libraries.