We are going to rewrite the entire contents of the Trans form. py class to work with matrices. Delete all the lines of code in your Transform. py class and add the following code:
import pygame
import math
import numpy as np
class Transform:
def__init_(self) :
self.MVM $=$ np.identity $(4)$
def get_MVM(self) :
return self.MVM
To begin, the initialization method has had the original variables removed and self .MVM has been added to store the modelview matrix. It is initially set to an empty identity matrix. When we zero a matrix in computer graphics, it's not set to all values of zero; otherwise, any other matrix multiplied with it will result in another matrix full of zeros.
Following this, a new method for returning the modelview matrix has been added.