Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we need a Unit Vector (in other words, why do we need to normalize vectors)?

Tags:

c++

c

math

I am reading a book on game AI.

One of the terms that is being used is to normalize a vector which is to turn a vector into a unit. To do so you must divide each dimension x, y and z by its magnitude.

We must turn vector into a unit before we do anything with it. Why?

And could anyone give some scenarios where we must use a unit vector?

Thanks!

like image 748
numerical25 Avatar asked Feb 21 '10 03:02

numerical25


People also ask

Why do we need to normalize a vector?

The reason for normalization of vector is to find the exact magnitude of the vector and it's projection over another vector. which means dot product is projection of a over b times a. So we divide it by a to normalize to find the exact length of the projection which is (b. cos(theta)).

What does it mean to normalize the vector?

To normalize a vector, therefore, is to take a vector of any length and, keeping it pointing in the same direction, change its length to 1, turning it into what is called a unit vector. Since it describes a vector's direction without regard to its length, it's useful to have the unit vector readily accessible.

Why do you find the unit vector?

Unit vectors specify the direction of a vector. Unit vectors can exist in both two and three-dimensional planes. Every vector can be represented with its unit vector in the form of its components. The unit vectors of a vector are directed along the axes.


1 Answers

You don't have to normalize vectors, but it makes a lot of equations a little simpler when you do. It could also make API's smaller: any form of standardization has the potential to reduce the number of functions necessary.

Here's a simple example. Suppose you want to find the angle between two vectors u and v. If they are unit vectors, the angle is just arccos(uv). If they're not unit vectors, the angle is arccos(uv/(|u| |v|)). In that case, you end up computing the norms of u and v anyway.

like image 157
John D. Cook Avatar answered Oct 07 '22 16:10

John D. Cook