Magnitude

The magnitude or length of a vector is written as the letter of the vector surrounded by two bars, Magnitude. The magnitude of a vector is the square root of the dot product of the vector with itself:

Magnitude

In addition to implementing the magnitude function, we're also going to implement a magnitude squared function. The formula is the same, but it avoids the expensive square root operation:

Magnitude

In games we often compare the magnitude of a vector to known numbers; ...

Get Game Physics Cookbook 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.