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

Please Explain (Constructor) CFrame.new(x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22)?

Asked by 9 years ago

May someone explain the math behind it and how it works. I've been told it's been used for Cframe Interpolation.

3
You don't need it. BlueTaslem 18071 — 9y
0
He's right you know funyun 958 — 9y
0
Good question, but you will not understand the real answer (and if you think you do, you don't). Be prepared for a boiled down answer that isn't necessarily wrong, but just dumbed down so you can actually understand SOMETHING. Unclear 1776 — 9y

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

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()


  1. 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() 

0
I am wondering though... -? what is the best way to try Cframe Interpolation... What do i need to know especially for math. Blockeus 68 — 9y
0
The math is quaternions, which I haven't ever bothered to research. I would highly suggest just using someone else's implementation instead of spending the time to arrive at exactly the same code. BlueTaslem 18071 — 9y
Ad

Answer this question