Appendix
This appendix contains definitions for the vector and matrix classes necessary to compile the code fragments in Chapters 1 and 2. I have included only those functions actually used in the examples. A complete implementation would require quite a few more operations.
Vector3
class Vector3
{
float v[3];
public:
//Constructor
Vector3();
//Element access
float& operator[](int i);
float operator[] (int i) const;
//Assignment operators
Vector3&: operator-= (const Vector3&);
Vector3& operator*=(const float&);
};
//Vector sum and scalar product
const Vector3 operator- (const Vector3&, const Vector3&);
const Vector3 operator*(const float&, const Vector3&);
Matrix33
class Matrix33
{
Vector3 rows[3]; // vector of rows
public:
//Constructor
Matrix33();
Matrix33 (float ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access