# Vector normalization question

When normalized, a vector keeps the same direction but its length is 1.0.

Can someone explain to me what normalization does and how/why it's used? A vector is a point. But it has direction and a length ?

Alright let’s say that we want to find the normalized version of (2, 4, 0)

First just to clear up any confussion: the magnitude (or length!) is:

``````//The square root of: x * x + y * y + z * z
``````

Now when we normalize something, that magnitude needs to be 1. Alright now for the actual explanation.

So first of all let’s find out how we find the direction. imagine we have a vector called: 0, 4, 0. you have this cordinate system here:

So bassicly we’re taking our vector and comparing it to the absoloute 0, 0, 0, place of our coordinate.
And in our case, compared to our vector of 0, 4, 0 the direction only goes upwards. That’s why the direction then ends up being 0, 1, 0

0, 4, 0 direction = 0, 1, 0;

Now if it was 0, 2, 0, this would happen:

Aright let’s take a vector that has these values: 4, 4, 0;
if we had a vector with 4, 4, 0
then this would happen:

In this case you’d be able to have any values at x, and y, AND if those values were excatly the same it would give: 1, 1, 0

4, 4, 0 direction = 1, 1, 0

finally let’s take our 2, 4, 0 vector.

2, 4, 0 direction = 1, 2, 0;

But what does this have to do with normalization? well let’s take the 3 direction vectors we had before:

4, 4, 0 direction = 1, 1, 0;

0, 4, 0 direction = 0, 1, 0;

2, 4, 0 direction = 1, 2, 0;

When we want the normalization we want the magnitude of these values. So let’s find the magnitude here:

``````//1, 1, 0 magnitude = square root of: 1 * 1 + 1 * 1 = 1.41;
//0, 1, 0 magnitude = square root of: 1 * 1 =            1;
//1, 2, 0 magnitude = square root of: 1 * 1 + 2 * 2 = 2.23;
``````

0, 1, 0 doesn’t need to be normalized cause it’s magnitude is 1! perfect!

1, 1, 0 however needs to be normalized. And sadly the only way to do this is just let a computer divide it by what makes it go down to 1. Not something we would easily be able to calculate. Same goes for 1, 2, 0

And that is that! I know this comment is from 2011, but this answer was mostly made to help people like me who really strucled with it, even after reading these other answers, and the unity documentation.
or it’s just 1 hour of my life wasted
have a good day

A vector is either a point, or a direction. See the Ray struct, for example. It's two Vector3s, and the first Vector3 is the origin and the second Vector3 is the direction. If it's a direction, then it has a length. Vector3(0, 0, 5) is a direction of 5 units along the z axis, so it has a length of 5. If you normalize that, it's Vector3(0, 0, 1). You would do this when you only want the direction and don't care about the length.

A use for normalize:

``````// bullet is speed 5, aimed at timmy:
float3 v = ((timmy.transform.position - transform.position).Normalized)*5;
bullet.velocity = v;

``````

The Normalized converts the gap between timmy and myself to length 1, and the *5 gives the bullet a speed of 5.

`bullet.LookAt("timmy"); bullet.rigidbody.velocity = bullet.forward*5;` is the more common way (in Unity) of doing it. Normalized is often used for the oddball "I have the right direction, but it's the wrong length" problems, or when you can't use LookAt.

A vector exists in a vector space, which has an origin. So every "point" is a line from the origin to that point.

The vector [1, 1, 1] is a line from [0, 0, 0] to [1, 1, 1].

Normalizing a vector preserves the direction, but moves the point to exactly one unit from the origin.

a normalized vector is the slope of the line on which the vector lies (of course this is only useful if the vector represents a line more commonly referred to as a direction)

knowing the slope of a line is useful a lot so it’s a common operation.

here is the most simple way to explain for new people! and with the simplest math!

if you have two different positions represented in three numbers (vector3).

and if you simply subtract one vector3 from the other. The difference you get can simply be added back to any other vector3 position to move it the same distance and direction.

that part is so simple unity doesnt even have a function for it.

so now with this new magical number from a simple subtraction of two points. you can hold it to calculate out a distance or a rotation or a direction in space. and one thing you other guys forgot to mention is that if you do this simple subtraction used more than once over time can also be used to calculate speed between to points! so this simple subtraction is a very important concept for all here to understand!

normalizing this number is a calculation similar to dividing the three vector numbers down evenly until the points where only 1 square away in the same direction. normalizing is actually an algorithm that uses square roots as described in the answers above. normalizing is helpful if you wanted to move an object slowly every frame in that direction at a consistent speed.