# Vectors And CFrames

Hello everyone, I have a question.

``````local Part2 = game.Workspace:WaitForChild("Part2")
Part2.Position = Part2.Position + Vector3.new(0,0,1)
Part2.CFrame = Part2.CFrame * CFrame(0,0,1)
``````

Is there a difference between Position and CFrame, if so what is the difference?

In `CFrame`, you can define orientation while a `Vector` cannot.

@VegetationBush Eh, not really you can define an orientation using a Vector3 as well thatâs the concept of the BasePart.Orientation property used.

For the code sample, assuming the parts current orientation is (0,0,0) the change in position will be the same as you have noticed.

However the difference is the math that happening is actually different for CFrame multiplication vs Vector position adding which leads to some interesting properties happening as stated by the Dev reference API for CFrames.

CFrame CFrame * CFrame
Returns the composition of two CFrames.
Proceeding CFrames are offset in relative object space by preceding CFrames when multiplied together.

Notice the object space? Now try this out

``````local Part2 = game.Workspace:WaitForChild("Part2")
wait(5)
Part2.Position = Part2.Position + Vector3.new(0,0,1)
wait(5)
--Rotate Part2 45 degrees along it's current y axis
wait(5)
--You will notice a difference here
Part2.CFrame = Part2.CFrame * CFrame(0,0,1)
``````

You should notice that the Part2 will not move (0,0,1) along the worldâs Z axis but instead for where the partâs âRightSideâ is pointing as that is its current Z axis hence Object space.

I think position is the physical position of the model, part etc. Cframe is a camera thing, Iâm not really an expert at this.

CFrame has more functions than Position. Position is where it is but CFrame is where it is and how it is rotated.

A Vector3 Positon just has a partâs position

A CFrame Value is 4 Vector3s, the first one being positions, the others being the up/right/down/lookvectors. They are the axis rotation of a part.

A good way to think of it is for an example, lets say a parts LookVector was (0, 1,0) it would mean if you placed a part 1 stud directly of the front face (which is the LookVector) it would be (0,1,0) offsetted from the original part.

I donât fully understandâŚ

Just what I understand is Position according to Earth coordinates, Ä°s CFrame for itself?

Its hard to explain, but if you print a CFrame it gives you 12 numbers. The first 3 being the position, the rest determines the rotation axises.

When you do CFrame.new() it creates a new Position WITH an orientation of 0,0,0 (not in angles)
when you do Vector3.new() it just creates a new position

nah, CFrame and Position are both 3D, CFrame is the more âhardest to understand but great to useâ since it uses things like EulerAngles,CFrame.Angles,lookAt,BodyGyro,fromMatrix,fromAxis,lookVector whilst Vector3 is the âEasy to use,Great for Forcesâ since it only uses things like fromAxis,BodyMovers,Orientation and Velocity

If I had to choose, I would definitely use CFrame, since it has lookVector

1 Like

A Vector3 is a position or direction in 3D space.
It can mean a position in the world, such as a partâs Position. However, a Vector3 says nothing about what way the part is facing, only where it is.
It can mean a combined direction (`.unit`) and a length (`.magnitude`), such as a partâs Velocity, or a partâs LookVector, However, it is merely a direction, and says nothing about the orientation.

A Ray is a combined position and direction. It is essentially two Vector3s in one structure. A Ray thus has an origin point, direction and length. If you wanted to make a Part that represents a Ray (such as a bullet tracer), then you would have to assume the rotation of the Part - its front surface definitely faces the Rayâs direction, but the Ray says nothing about where the top/side surfaces would be facing. `CFrame.lookAt(from, to)` has to make this same assumption, and assumes you want the partâs top surface to face âupwardâ by using `CFrame.fromAxisAngle(direction, 0)`

A CFrame (Coordinate Frame) is a combined position and orientation. It is essentially four Vector3s in one structure.
The four vectors are the position, the forward direction, the side direction and the top direction. This makes a total of 12 numbers (3*4). Compared to the Ray, it adds a side vector and a (redundant) top vector, so that the position and orientation of a 3D object can be fully represented.
CFrame.lookVector is easy access to 3 of the 12 numbers in the CFrame.

`Part.Orientation` is not really a position or direction, it is a best-guess representation of the orientation of a part in Euler Angles (same as `CFrame:ToEulerAnglesYXZ()`, which is the same as `CFrame:ToOrientation()`).

2 Likes