用 4 个点和指定的倾斜角度对人工 horizon 进行编码

Coding an artificial horizon with 4 points and a specified bank angle

我需要使用 LUA 在具有指定半径 的圆中实现人工 horizon 线的正确平移。我需要直线 (x1, y1, x2, y2)
的 4 个点中的每一个的方程 有任何想法吗?我什至无法理解这个概念。
提前致谢!

我假设你的 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)