May someone explain the math behind it and how it works. I've been told it's been used for Cframe Interpolation.
As mentioned before, CFrames are matrices.
In particular, they are 4x4 matrices. This is so that you have a 3x3 matrix, which represents rotations in 3D, plus a fourth fixed dimension. They are arranged like this:
[ x f u r ] [ y w p g ] [ z d p t ] [ 1 0 0 0 ] -- [x y z]: Position -- [f w d]: Forward direction -- [u p p]: Up direction -- [r g t]: Right direction
That is, there are 12 numbers that define a CFrame.
CFrame.new(x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22)
corresponds to filling the entries of that matrix in the order (x, y, z, f, w, d, u, p, p, r, g, t)1.
The only time you need this constructor is to restore arbitrary CFrames that were saved -- since you need all 12 numbers to uniquely represent it, this will be your only choice if you, e.g., wanted to store CFrames in a string.
Normally, you don't want to do anything as silly as that, and the other constructors CFrame.new(x, y, z)
and CFrame.Angles(x, y, z)
and CFrame.new(from, to)
are far more than enough.
Takeway: This exposes the way CFrames are stored in a fairly useless way. You shouldn't use it unless you are using it in conjunction with :components()
I think. Someone might correct me on the order. Again, you shouldn't be using this constructor except to replicate the results of tostring
to :components()
↩