Converting CFrame components to CFrame angles

  1. What do you want to achieve?
    I want to get CFrame like
    CFrame.new(x, y, z) * CFrame.Angles(x, y, z)
    from CFrame components like:
    0.02, 0.2, 0.52, 0, 0, -1, 0, 1, 0, 1, 0, 0.
    So the first three values are X,Y,Z position but how to get angles in rad/deg from 0, 0, -1, 0, 1, 0, 1, 0, 0?

  2. What is the issue?

  3. What solutions have you tried so far?
    There is no function for that on developer.roblox and couldnt find solution on devforum. Is CFrame.fromEulerAnglesXYZ supposed to convert it? It gives weird values.

1 Like

Can’t you just get the orientation and use math.rad on each axis?

1 Like

Orientation from what? I got CFrameValue object that stores CFrame and i want to know its value. When i try to print it, it prints me 12 components.

Could you explain what are you trying to do with the orientation.

Here is a link to a post that explains how you can do it: How to get a CFrame's angles - #3 by TheGamer101. Note that the rotation will be in radians.

1 Like

Simple way to get the rotation matrix which you can multiply by a CFrame to apply rotation on:

local rotationMatrix = cf - cf.Position

You can just multiply it by the CFrame you use just like you would with CFrame.Angles. The rotation matrix would return a CFrame exactly the same as the original CFrame but position coordinates being 0, 0, 0, thus keeping the rotational components and emptying the position coordinates.


EDIT: I made this reply before I saw a similar reply in the thread of the reply above me.

1 Like

I’m not sure if im doing it correctly but it still gives me 12 components.

So one day i stored CFrame value into CFrameValue object by using script:

workspace.viewmodel.offsets.idle.Value = CFrame.new(0.02, 0.2, 0.52) * CFrame.Angles(0, -90, 0)

And now when I forgot what value I did put in it, I wanted to print it to get it. But when I print it, it prints 12 cframe components instead of what I put into it. I wanted to get CFrame position and orientation.

I just found the solution for that by creating a part and puting script inside of it:

script.Parent.CFrame =  CFrame.new(0.0200000014, 0.200000018, 0.520000041, 0, 0, -1, 0, 1, 0, 1, 0, 0)

And then looking into its properties to find orientation in degrees. But thanks for trying to help me anyways and sorry for wasting your time :smiley:

1 Like

You get the the look vector and the up vector then multiple them then convert that to degrees iirc. The left vector is useless

2 Likes

In the future, you could do cframe:ToOrientation() to get its orientation once you construct a CFrame from the 12 numbers.

3 Likes