What means normalized?

Hello. Since I’ve trying to do more complex things using scripting I would need to know more mathematical stuff. I’ve come up so developers saying ‘normalized’ CFrame/Vector3.

However I don’t know what normalized CFrame or Vector3 means, I don’t know if I missed any topic where this is being explained but I could not find one. If anyone knows what this means I would appreciate it you to explain it. Thanks

1 Like

I think this documentation on understanding cframe should get you started.

I don’t think you know what I asked for I know CFrame but not normalized CFrame/Vector3

1 Like

I’m not sure about ‘normalized’ cframe/vector3.

Normalized vectors are also called unit or directional vectors.
They’re vectors with a magnitude of 1

1 Like

A normalized vector is a vector with a magnitude of 1, and is commonly associated with properties of CFrames (LookVector, UpVector, RightVector)

It’s also commonly referred to as a directional vector

You can get the normal of any Vector by getting its .Unit:

local Vector0 = Vector3.new(5,9,2) -- make some random Vector3 for example
local Vector0Magnitude = Vector0.Magnitude -- 10.488; not normalized

local NormalizedVector = Vector0.Unit -- this is what you're looking for
local NormalizedMagnitude = NormalizedVector.Magnitude -- always 1

print(NormalizedVector) -- Vector3 0.476, 0.858, 0.190

You can get the LookVector of a CFrame by defining its .LookVector

local CFrame0 = CFrame.new() -- can be any
local LookVector = CFrame0.LookVector

print(LookVector) -- Vector3 0, 0, -1
5 Likes

You’d want to ‘normalize’ a vector into what’s known as a ‘unit vector’ (a vector with length 1, hence the name ‘unit’) when you do for example angle calculations, so you’d only care about the vectors direction and not the actual magnitude information. It’s not a ‘must’ but it makes a lot of calculation easier.

1 Like

When you normalize a vector with the .Unit property it returns that vector with the same direction but a magnitude of 1, a use case is normalizing the vector to get its direction alone

1 Like

I don’t really get the point of normalized vectors, It’s not making any sense to me.

They’re used to represent direction in a 3D space, I’m not sure how else to explain it

Hmm, But I executed this command

print(Vector3.new(5,5,8).Unit)

and I got result of

0.46829289197922, 0.46829289197922, 0.74926865100861

I don’t know why would this happens or is there some logic to it

When you have a vector: Vector3.new(5,5,8) and get its Unit, this is what mathematically has happened:

First it calculates the magnitude of the current vector:

Vector3.X = 5 → 5^2 = 25 which is the same as doing 5 multiplied by 5 = 25
Vector3.Y = 5 → 5^2 = 25 which is the same as doing 5 multiplied by 5 = 25
Vector3.Z = 8 → 8^2 = 64 which is same as doing 8 multiplied by 8 = 64

After you have these 3 new values 25, 25, 64 you add them all up:

25 + 25 + 64 = 114 and then you calculate the square root of 114 which looks like: √ 114 → 10.6770783

Now when you have this magnitude value 10.6770783 we can calculate the Unit as follows:

Vector3.X = 5 / 10.6770783 = 0.4682929036869571
Vector3.Y = 5 / 10.6770783 = 0.4682929036869571
Vector3.Z = 8 / 10.6770783 = 0.7492686458991314

Perhaps the inaccuracies in Roblox’s calculation are caused by floating point representation related problems but that’s a topic for another day.

4 Likes

So what I understand is you can calculate the target point but if we want to use it as the direction we will need to add. Unit to it?

1 Like

I’ve tested my theory which says that with normalized vectors we can get perfect direction pointing at another point, I used raycast to test this.

1 Like

Yep! Now all you can do is multiply by a certain amount to move along that direction. The ‘starting point’ is Vec3 0,0,0 and it will give the Unit length toward the Vector point target.

To visualize this:
Animation

1 Like

Vector3 is a 3 number value in brackets.

Blockquote ex.Vector3.new(0,50,62)

CFrame is the frame of a part. I normally use it if I am teleporting players or moving parts.

Basically the entire idea behind a “normalized” vector is exactly what the name implies

You “normalize” it in that you make some part of the vector “normal” or predictable, in this case the length

Many math problems require that you have a specific length value in a vector, such as:

  • dot product
  • trigonometry (as in the unit circle)
  • matrix math like cframes

And really countless other things
Having a known length of 1 also helps with, like he said, giving a vector a certain length
When you have a normalized vector and you multiply it by 2, or 3, or 4 or any number, the length becomes that number with the specific direction

But honestly, in the end, the use of normalized vectors isnt really limited to any of these things, its just another commonly used tool in math
Wherever a math problem could be solved by knowing a specific length, normalized vectors are useful, but you really just have to use your creativity