# Help understanding what happens when I multiply 2 CFrames

I looked at the CFrame math operations article on the wiki but I’m still confused. What is happening when 2 CFrames are being multiplied. Do the look vectors add with the look vectors, do the position vectors add with the position vectors? I can’t seem to figure it out, and would like some explanation.

5 Likes

its basically local cf `CFrame:ToWorldSpace(cframe)`,which allows you to offset `cf` from `CFrame` relatively by the parameter, `cframe`.
Sorry if the variables confuse you, they should all be `CFrame` values.

Edit: I also figured out what multiplying CFrames did with this article: https://developer.roblox.com/en-us/articles/Understanding-CFrame.

1 Like

CFrames are matrices, and when you multiply two matrices, each row is multiplied by all of the columns.

Generally, multiplying two matrices is like so:
Say we have a two matrices, where A is and B is , then `AB` is:

With cframes, it is the same thing:

The components of the back vector, up vector and right vector are being multiplied and added in the matrix

13 Likes

When you multiply by one CFrame by another, the other one is added to the first CFrame locally. That means if you do this:

``````cframe * CFrame.new(0, 1, 0)
``````

that will return `cframe`, but up one. Not necessarily adding 1 to the Y position, it depends on `cframe`'s rotation. Think of `cframe` being the origin, and the new CFrame being a position relative to that origin.

5 Likes

The understanding for what the actual computation is has already been said above by @Raretendoblox .
As for understanding what said computation actually results in visually, I recommend reading this:

It assumes you have some knowledge of terms like origin, radians, and some other stuff about Cartesian coordinate systems, and, vectors. Try to faintly follow through what I’ve said by visualising each three axes of a CFrame with arrows coming out of it’s position (CFrame.Position). You can visualise this by using something similar to the right/left-hand rule by pointing your fingers in the direction of the axes. (Remembering that each axis is perpendicular to any other axis.) Also, imagine the position of your hand as CFrame.Position. E.g. I might use my thumb to represent pointing in the direction of CFrame.UpVector and index finger as CFrame.RightVector, and, middle as CFrame.LookVector. (For right hand.)

For more information on the general topic, research visualizing composition of linear transformations, or just, visualizing linear transformations.

Here’s 2 extra gifs that might help with understanding (once you’ve read and understood my reply in that other topic.)

12 Likes

I know the result of multiplying a CFrame with a Vector3 is that the vector gets rotated with the CFrame’s rotation and then offset with the CFrame’s position. But I don’t understand what happens when multiplying 2 CFrames.

Edit:

I’ve made a quick image to help explain what I’m asking. I’m wondering what the result of this operation would be.