This was from CFrame documentation from roblox. As I’m reading it, I couldn’t understand what the “R” stands for. What does that mean? Is this some sort of an actual value number for rotation? How does it work? and How do you use it in scripting?
This is simply a rotation matrix which roblox uses to describe rotations within 3D space. These are a bit advanced so I would suggest learning the math and understanding about how Rotation matrix’s translate to 3d rotations.
There is no easy way to fully understand how they work, but the sources below should help. I would recommend having a basic understanding of trigonometric rules and trig.
+ Some Sources
In my experience with CFrames for visual effects such as Motor6Ds/Inverse Kinematics you don’t use the numbers individually rather the vectors (.LookVector, .RightVector).
The only time I have seen the numbers used individually from my memory is for serialization in a datastore.
If you are curious on how the numbers work there are resources such as @paswa mentioned and this article by @EgoMoose which replicates a CFrame class in lua and how to convert those numbers into something meaningful and understandable like EulerAngles, haven’t tested it out but I know EgoMoose makes some great CFrame tutorials:
local c = ref[self];
local rx = atan2(-c, c)
local ry = asin(c);
local rz = atan2(-c, c);
return rx, ry, rz;
Otherwise another good starting point which is simpler which I also started with was CFrame.fromMatrix which is simpler to understand which explains a CFrame consisting of a RightVector, UpVector, and LookVector that is orthogonal to each other:
This used to be the replacement for CFrame.new(position1, position2) before the newer CFrame.lookAt() which is used all the time in roblox scripting.
From my understanding R is just a variable which represents the number components of the vector RightVector, UpVector, and LookVector components of a CFrame.
These numbers do not have units as these direction vectors are unitized (length of one). Just like a vector with (0, 1, 2) has the same direction as (0, 2, 4) what matters is these numbers combined such as the right vector which is (R00, R10, R20).
The 00 and 01 notation is just matrix row x column notation.
There’s no need to understand really, unless you’re just trying to satisfy your curiosity. During my time scripting in roblox, I have never once needed to know how the matricies behind CFrames work. If you’re just trying to understand how to use CFrames, this isn’t needed.