Appendix D
C++ Math
Video games cannot be created without at least a basic understanding of math, especially geometry.
This appendix covers the basic math classes provided with the samples on this book’s web site at http://www.apress.com/9781430258308.
Vectors
A vector is used for two purposes: to represent displacement and direction.
Vectors in games can come in three different varieties: two-dimensional (2D), 3D, and 4D homogenous vectors. This book only makes use of 3D and 4D vectors.
Listing D-1 shows the class declaration for the 3D Vector3 class.
Listing D-1. The Vector3 Class Declaration
class Vector3{public: float m_x; float m_y; float m_z; Vector3(); Vector3(const float x, const float y, const float ...
Get Beginning Android C++ Game Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.