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

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

Asked by 5 years ago

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

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

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
0
thanks! fusionFSJAL 33 — 5y
Ad

Answer this question