Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you print out the actual radians in the output?

Let's say I code my brick to do this:

brick.CFrame = CFrame.Angles(math.rad(56), math.rad(24), math.rad(69)) print(brick.CFrame)

it'll print out this junk: 0, 0, 0, 0.327385426, -0.85286808, 0.406736642, 0.642893195, -0.114406422, -0.757363439, 0.692464471, 0.509437978, 0.510848105

I want it so that it prints out the radians like: 56, 24, 69

it would be a really useful tool for me when i try to do CFrame animation

1 answer

✓ Accepted answer

CFrames are effectively 4x4 matrix with 4 of the entries being implicit. This means they're defined by 12 numbers, which is what you see in the output when you tostring a CFrame.

To get (an approximation of) the angles used in the CFrame.Angles constructor, you can use the :toEulerAnglesXYZ() method, which returns three numbers:

brick.CFrame = CFrame.Angles(math.rad(56), math.rad(24), math.rad(69))

print(brick.CFrame:toEulerAnglesXYZ())
--> 0.97738438844681 0.41887903213501 1.2042771577835

The numbers 56, 24, 69 are not values in radians, but in degrees. The output of :toEulerAnglesXYZ() is in radians. If you want the output in degrees, you would have to convert the radians to degrees using the math.deg function:

local ax, ay, az = brick.CFrame:toEulerAnglesXYZ()

print(math.deg(ax), math.deg(ay), math.deg(az))
--> 56.000000419977 24.000000667861 68.999998505005

1 comment

0

thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.