##### Introduction to Vectors

Vector math is fundamental is 3D graphics, physics, animation and anything requiring motion in graphics. When moving from other programming environments, or if you are new to programming in general, a clear understanding of the basic principles of how we program motion through vector mathematics is absolutely essential to being able to successfullly develop for virtual reality environments.

##### It’s all triangles now

A Euclidean Vector is defined as an entity that has both a direction and a magnitude. Symbolically a vector is pictured as an arrow with the point of the arrow indicating the direction and the magnitude is signified by the length of the arrow itself. An accurate vector describes an objects relative position in space, and through the computational flexiblity vectors provide, we can describe the relative position as being in motion with a direction and magnitude. A vector might best be understood as simply an instruction that tells you where to move.

This magnitude and direction of a vector can be found from the Pythagorean Theorem. If you have an x coordinate over a y coordinate in a column array, the magnitude is equal to the square root of x squared + y squared.

A nice 5 minute video and exercise to brush up on your knowledge of triangles **can be found here.**

While this is merely our first mention of triangles, key concepts in trigonometry are critical to understanding many aspects of motion and 3D computer graphics. Virtually even frame of every graphic is at its core a series of triangles.

The starting point of a vector is simply the position vector. To enable a vector to describe movement, we must perform arithmetic functions.

Adding vectors is fairly straightforward. To add two vectors you simply add their components in pairs.

To multiply a vector by a scalar, you simply multiply each component by the scalar. **Here is a solid 10 minute video and exercise** to give you some practice multiplying vectors.

##### Applications to Programming

With respect to programming, some languages have innate support for vector calculations. Most 3D engines usually include functions for calculating the magnitude and norm of a vector.

##### Applications for the real and simulated world

In “real life”, vectors and scalars have many day to day meanings. Here are a few common terms that are best quantified as a vector component:

- Distance
- Displacement
- Speed
- Velocity
- Mass
- Weight

More specifically, many of these components are thought of interchangeably, like speed and velocity. However, when programming motion and Netwon’s 3 Laws, specificity is crucial. For example, the velocity of an object is a vector, its speed is the magnitude of the vector.

Once you become familiar with the basics of vectors, it is important to build an fluency in matrix oriented math to allow you to perform rotations and transformations. The video below walks you through that, in the context of building a 3D game. Like a vector, a matrix is best thought of as an instruction. While a vector is an instruction that produces motion and movement in a certain direction. When a matrix is supplied with a vector, you produce a new vector, so that a matrix is an instruction for how to interpret the vector. At its core, a matrix is a transformation of space.

With a basic familiarity of these concepts to build from, and the user friendly nature of modern game engines, a developer can begin to understand the programming approach to producing large scale virtual environments enabled with motion.