What is the difference between Cframe and Vector3

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I am new in Lua so I want understand when use vector3 and Cframe

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I see in developer page but only I see that is move
1 Like

CFrame (AKA CoordinateFrame) values are used to store rotational (In a 3-by-3 rotation matrix that stores values in radians.) and positional data, for example BasePart.CFrame for storing a BasePart's position and rotation, ect.

While Vector3 values stores 3 dimensional vectors that can be used to store a variety of things, like BasePart.Orientation for rotational data in Tait–Bryan angles format, BasePart.Position for positional data in a WorldRoot, BodyPosition.MaxForce for setting a limit on how much force can BodyPosition apply on each axis, ect.

It stores values in a 4x3 unit matrix actually, and not as radians. Using a matrix for rotation means that each pairing of numbers in the matrix is a vector. You have three perpendicular vectors to describe rotation and one vector to describe position.

1, 0, 0, 0
0, 1, 0, 0
0, 0, 1, 0

Going in columns, you have the right vector, top vector, back vector, and position.

This could be a 4x4 matrix and function fine with standard matrix transformations, but that’s not necessary for Roblox. Roblox has CFrames coded to function with a 3x3+position

3 Likes

in fact, internally it is 4x4 because it is a lookat matrix! it’s just that the components we can change are only accesible in those component fields

Vector3 is for a position or direction in Space.
CFrame is for when you need both.

for 3D space you need 3 total, so position and up and forward work

Simply put, Vector3 is the X, Y, and Z of an object’s position.
CFrame is an objects position and the rotation (Position and Orientation in one)

Meaning that if 2 objects had the same CFrame, they would be in the same position and they would face the same direction.

2 Likes

You’ll need to educate me then. I thought for certain that the bottom row was garbage and wasn’t stored anywhere. Their functions for sure only apply a 3x3+position transform, not a true 4x4.
Specifically, I have no idea what is or what makes it a lookat matrix.

1 Like

Can you show me a post or an article that says that CFrames are LookAt matrices? Because I can’t find a single post that mentions it and looking at a XML Roblox file shows that no such 4th row exist in saving process. Only x, y, z, R00, R01, R02, R10, R11, R12, R20, R21 and R22 values are stored as shown by this screenshot here (and I doubt this is much different in binary file format):
image

The only way that LookAt values can exist is that they are created at some point in runtime, which kind of defeats the point to make it a 4x4 matrix if you’re not going to save the entire matrix in the first place.

Moving on to @JarodOfOrbiter’s reply, yes, you’re technically not wrong on the fact that it kind of acts like 4x3 Matrix. However, I probably should’ve worded my sentence a bit better because I was only talking about the rotational part of the matrix at that part of the sentence, hence I typed this:

I added the positional data part after I said the “In a 3-by-3 rotation matrix that stores values in radians.” part to make it more clear that I’m only talking about the rotational data part of the CFrame values, though I should’ve worded it like this:

An another note:

While yeah, rotational values might be stored as Vector3s in runtime and as separate numbers in file, numbers stored on those values are still treated and saved to be used as radians later so my point still stands.

Anyways, that’s all I have to say in this matter.

When trying to scale a parts CFrame it resets its position while changing its size with Vector3 doesn’t. CFrame also can be used for rotation but it’s the same, changing it’s orientation with Vetcor3 doesn’t reset anything.

well thats just from my experience coding computer graphics stuff. its clear that cframe is a lookat matrix. the lookvector, upvector and rightvector describe the rotation and the position is where the lookat matrix is at. check this out, its common sense

demasiada informacion, no entiendo nada

Put simply

Vector3:


Position only




CFrame:


Position and rotation

Very epic

4 Likes

gracias a ti y a todos me ha servido de mucho aprender cual es cual

1 Like