Common matrix operations
In this section, you will learn how to implement some common matrix operations. These operations will be used in later chapters of this book to display animated models. Specifically, this section will cover how to compare, add, scale, and multiply matrices as well as how to transform vectors and points using matrices.
Comparing matrices
Comparing matrices is a component-wise operation. Two matrices are the same only if all their components are the same. To compare two matrices, loop through and compare all of their components. Since you are comparing floating point numbers, an epsilon should be used.
Create a new file, mat4.cpp
. Implement the matrix equality and inequality operators in this file. The equality operator should check whether two matrices are the same; the inequality operator returns the opposite of the equality operator. Don't forget to add the function declarations to mat4.h
:
bool operator==(const mat4& a, const mat4&...