Game Development Reference

In-Depth Information

parallelizingvectorhardware)becauseoptimizedinterfacesaretypicallymoreverboseand

would distract us from our goal.

Note: The Direct3D example code provides conversion operators between the vector

classes and the optimized XMVECTOR, it foregoes the optimization in favor of a more

readableandstraightforwardinterface,atthesametimethiscompatibilityallowsoptimized

operations to be used in high performance situations and the vector classes used for local

storage.

1.2.1.1 Vector Addition

Vector addition is the straightforward operation of adding all the components of one vector

to the components of another.

Geometrically, the result can be visualized by placing the second vector at the end point of

the first, then drawing a vector between the starting point of the first vector to the ending

point of the second.

Figure 3 - Vector addition

The code to add two vectors together is equally straightforward, it is useful to implement

the addition operators in the vector class.