Positioning UI objects using trigonometry

Hey everyone! i am in the process of making a compass gui but i have been stuck on this for several minutes now; i was wondering if anyone here knows how i can fix it :slightly_smiling_face:
1.I want to have my directions at the right places
2.the directions are not at the right places
image
3. I looked for solutions on the hub but did not find any!



local C = script.Parent:WaitForChild("CircleTing")

local Directions = {
	["15°"] = 15,
	["30°"] = 30,
	["NE"] = 45,
	["60°"] = 60,
	["75°"] = 75,
	["E"] = 90,
	["105°"] = 105,
	["120°"] = 120,
	["SE"] = 135,
	["150°"] = 150,
	["165°"] = 165,
	["S"] = 180,
	["195°"] = 195,
	["210°"] = 210,
	["SW"] = 225,
	["240°"] = 240,
	["255°"] = 255,
	["W"] = 270,
	["285°"] = 285,
	["300°"] = 300,
	["NW"] = 315,
	["330°"] = 330,
	["345°"] = 345,
	["N"] = 360,
	
	
}

function LoadDirections()
	local ax,ay = script.Parent.CircleTing.AbsoluteSize.X/2,script.Parent.CircleTing.AbsoluteSize.Y/2
	local radius = ax
	for i = 1,24 do
		local theta = i*15
		local i = nil
		for i2,v in pairs(Directions) do
			if v == theta then
				i = i2
				break
			end
		end
		local T = script.T:Clone()
		T.Parent = script.Parent.CircleTing
		local x,y = math.sin(theta)*radius,math.cos(theta)*radius
		T.Position = UDim2.new(0,ax+x,0,ay+y)
		T.Text = i
	end
end
LoadDirections()

am i formatting my script wrong? am i using the sin and cos wrong?

All of the trigonometric functions of the math library uses radians, not degrees. You can convert degrees to radians using the math.rad function:

theta = math.rad(theta)
local x,y = math.sin(theta)*radius,math.cos(theta)*radius
T.Position = UDim2.new(0,ax+x,0,ay+y)
T.Text = i

thank you :smile:

thank you :smile: