O'Reilly logo

Beginning Android C++ Game Development by Bruce Sutherland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required