# What is a direction vector and why should it be normalized?

I've been trying to get the hang of vectors and I read Wolfire's blog about linear algebra and I seem to understand most stuff except when it comes to storing a direction as a vector and using it by multiplying the velocity by it. I know it has to be normalized (have a length of 1), but why does it have to be 1 specifically and how would I use it?

Also how would I represent it in 2D [x,y] coordinates. For example if I wanted a direction such as North-East?

A 2D vector has two values (x and y), and it basically says how far you go from the point of origin in the x- and in the y-direction. For example, a vector of (3,4) goes 3 units in x direction and 4 units in the y direction, resulting in an angled line with a length of 5 (3² + 4² = 9+16 = 25, root of that is 5). So the vector basically gives you two pieces of information:

1) Direction and

2) length

If you now want to calculate where an object moves, you take direction * speed, but you have to normalise the vector to the length of 1 so it doesn't skew your results. If you used the above vector as is, it would multiply your speed by 5 (its length), so your object would move five times as fast as intended. If you have a normalised vector with a length of 1, the 1 is neutral in multiplications and doesn't cause you any trouble.

I'm sure there are more technical explanations, but that's the gist of it.

• Regarding the North-East-Question: This is a question of definition. If you say North is up/+y and East is right/+x, the vector (3,4) would point North-East, while the vector (3,-4) would point South-East. Both would have the (positive) length of 5 (squaring deletes the minus). – J_F_B_M Sep 1 '14 at 21:33
• Thanks. As I mentioned in my comment to Philip's answer, I must have missed the part about North-East. – Christian Sep 1 '14 at 21:39
• @Christian Thanks for the answer and explaining clearly – user51213 Sep 2 '14 at 16:51

First of all, it depends on your coordinate system. But if we look onto your world from the top and assume that North/South is the y-axis (+y = North) and West/East is the x-axis (+x = East), you could represent the direction "North-East" as the (un-normalized) vector [1, 1] or the (normalized] vector: Example visualization in WolframAlpha.

It's just a standard and it makes things easier for everyone.

Why does it have to be 1 specifically?

It doesn't. It's just a standard. If you want so in your game, you can make all your vectors of length 2. I wouldn't call it normalized though because normalization has a mathematical definition of its own.

As long as you have all your vectors in the game standard (all of them of unit length N, doesn't matter what N is, but 1 is pretty standard), you could still do the direction*speed technique.

All that said, I don't know anyone who uses other unit lengths other than 1. I just want you to know that it doesn't have to be so, it's just much easier for everyone.

How would I use it?

A normalized vector would signify direction. That makes it convenient to mash up with speed.

For every frame, instead of doing position = newPosition or position = position + movementVector, you could generalize everything with position = position + direction*speed.

• In other words, what number is there that is easier to multiply by than 1 (well, apart from zero because that'd be quite useless in this context)? ;) – tangrs Sep 2 '14 at 4:57
• Exactly. It's simply the most convenient thing to do : normalize vectors to unit 1 length. – Zaenille Sep 2 '14 at 5:00
• This is slightly incorrect, and perhaps misleading. If you do not normalize, the math with still go through, but the results will distorted. Note Christian's answer, where he explains why normalization is important. Maybe the effect ends up being what you want for your game, but this is not solid mathematics. It's about being the multiplicative identity, not just being "easy". Multiplication by 2 is quite easy, but being off by a factor of 2 would still skew your output. – RavensKrag Sep 2 '14 at 10:23