Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Advanced Cframes. What do these variables mean?

Asked by 3 years ago
CFrame.new(x, y, z, m11, m12, m13, m21, m22, m23, m31, m32, m33)
end

What does the m11, m12... etc represent, and how do they correspond to x,y,z and why do they correspond.

local function multiplyCFrame(a, b)
    local ax, ay, az, a11, a12, a13, a21, a22, a23, a31, a32, a33 = a:components()
    local bx, by, bz, b11, b12, b13, b21, b22, b23, b31, b32, b33 = b:components()
    local m11 = a11*b11+a12*b21+a13*b31
    local m12 = a11*b12+a12*b22+a13*b32
    local m13 = a11*b13+a12*b23+a13*b33
    local x = a11*bx+a12*by+a13*bz+ax
    local m21 = a21*b11+a22*b21+a23*b31
    local m22 = a21*b12+a22*b22+a23*b32
    local m23 = a21*b13+a22*b23+a23*b33
    local y = a21*bx+a22*by+a23*bz+ay
    local m31 = a31*b11+a32*b21+a33*b31
    local m32 = a31*b12+a32*b22+a33*b32
    local m33 = a31*b13+a32*b23+a33*b33
    local z = a31*bx+a32*by+a33*bz+az
    return CFrame.new(x, y, z, m11, m12, m13, m21, m22, m23, m31, m32, m33)
end

And what does multiplying these two Cframe do? Does it give us a new cframe?

0
I really don't understand your confusion at all. You know that CFrames are matrices and you know exactly how to multiply the matrices of two CFrames, but you don't know what CFrames are or what your function does? SteamG00B 1633 — 3y

1 answer

Log in to vote
0
Answered by
SteamG00B 1633 Moderation Voter
3 years ago

A CFrame is just a matrix of a part's position and rotation, so the x,y,z stand for the part's position, and the m11, m12... etc represent the rotation. These m values can also be broken down further into the LookVector, the RightVector, and the UpVector, which are just vector3s that represent the part's rotation.

Now when you multiply two CFrames, it does exactly what you've shown in your question. It returns a new CFrame that is the first CFrame modified by the second CFrame.

0
I don't understand how the m11,m12,m13 works, I know the pattern repeats in triplets but I don't know what they represent? is the m11 like x as m12 is y, etc for rotation ? HegemoneXT -45 — 3y
0
yes, m11 is the x value in the LookVector. SteamG00B 1633 — 3y
Ad

Answer this question