Полагаю, ваша ось X направлена вправо, а ось Y - вверх.
local max_pitch = 50 -- at pitch=50° horizon goes beyond the circle
local radius = 100 -- circle radius
local center_x, center_y = 200, 150 -- circle center
function draw_horizon(banking_angle, pitch_angle)
local alpha = math.acos(-pitch_angle/max_pitch)
if alpha == alpha then
local beta = math.rad(90 - banking_angle)
local x1 = center_x + radius * math.cos(beta + alpha)
local y1 = center_y + radius * math.sin(beta + alpha)
local x2 = center_x + radius * math.cos(beta - alpha)
local y2 = center_y + radius * math.sin(beta - alpha)
drawline(x1, y1, x2, y2)
else
-- horizon is beyond the circle
end
end
-- current angles
local banking_angle = -40 -- 40° (positive right, negative left)
local pitch_angle = 10 -- 10° (positive climb, negative dive)
draw_horizon(banking_angle, pitch_angle)