Creating Vectors

The most useful concept we will need in order to manipulate sprites effectively is a vector. A vector is a mathematical construct that represents two things at once—a point as well as a direction. A vector is not merely a point, nor is it merely a direction; otherwise, we would use one term or the other to describe it. However, we can use a vector to represent simple points, or positions, for game entities such as sprites and meshes.

A vector with its own built-in functionality will be incredibly helpful to a Sprite class. We will be able to give a sprite properties, such as position, direction, and velocity, as well as calculate the trajectory to a target, the normal angle of a polygon, and other helpful functions (some of which we may not need but which are available nonetheless). We will use the Vector3 class (listed in the following section) to do the “heavy lifting” for the upcoming Sprite class.

Advice

I found the following URL to be a helpful reference for the math behind computer graphics concepts such as points, lines, vectors, and matrices: http://programmedlessons.org/VectorLessons/vectorIndex.html.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset