- C++ Game Development By Example
- Siddharth Shekar
- 170字
- 2021-06-24 14:26:15
Vector magnitude
The magnitude of the vector is equal to the length of the vector itself,. But how do we calculate it mathematically? .
The magnitude of a vector is given by the Pythagorean theorem, which specifies that in a right triangle , the square of length of a diagonal is equal to the sum of the squares of the adjacent sides. So when we look at the right triangle as follows, c2 = x2 + y2.
This can be extended to three dimensions with c2 = x2 + y2 + z2.
Magnitudes of vectors are indicated by double vertical bars, so the magnitude of a
vector is denoted by . The magnitude is always greater than or equal to zero.
So, if vector A = (X, Y, Z) then the magnitude is given by the following equation:
If = (3, -5, 7), Then:
= 9.110
The vector is therefore 9.11 units long