c# - 如何计算圆绕球体的曲率(弧)?

标签 c# winforms drawing astronomy

我想画一个代表月亮的圆圈,并在这个圆圈上画一条弧线,代表每个照度百分比的太阳照度。 虽然这个月亮的图像是二维的,但我需要弧线的曲率具有“真实感”。 我想要一个函数,它接收作为照明百分比的参数(例如:27%)并返回具有正确曲率的圆弧绘图。

最佳答案

月球明暗线是一条椭圆弧垂直轴恒定(等于月球直径),而水平轴随月球线性变化阶段 这是

   0 - New Moon
0.25 - First Quarter
0.50 - Full Moon
0.75 - Last Quarter 

位图创建来展示想法:

private static Bitmap DrawMoon(int radius, float phase) {
  phase = (phase % 1 + 1) % 1;

  Bitmap image = new Bitmap(2 * radius, 2 * radius);

  var rect = new Rectangle(10, 10, 2 * radius - 20, 2 * radius - 20);

  float w = Math.Abs(rect.Width - rect.Width * (4 * phase % 2));

  // Terminator is elliptical, verical axis is constant
  // While horizontal change as linear function from phase
  var term = new RectangleF(
    rect.Left + (rect.Width - w) / 2, rect.Top, w, rect.Height);

  // Width == 10 to exagerate the lines, to show they are elliptical
  using var pen = new Pen(Brushes.Yellow, 10);

  using (Graphics gs = Graphics.FromImage(image)) {
    gs.FillRectangle(Brushes.Black, new Rectangle(0, 0, image.Width, image.Height));

    if (phase > 0.5f)
      gs.DrawArc(pen, rect, 90, 180);
    else
      gs.DrawArc(pen, rect, -90, 180);

    if (phase < 0.25f || phase > 0.5 && phase < 0.75)
      gs.DrawArc(pen, term, -90, 180);
    else
      gs.DrawArc(pen, term, 90, 180);
  }

  return image;
}

几个月相(0.120.270.540.95):

enter image description here

enter image description here

enter image description here

enter image description here

如果您坚持照明百分比,您应该求解方程。月球照明是月球一半加上或减去椭圆一半的面积,例如相位[0..0.25]

illumination = pi * R * R / 2 - pi * R * R * (0.5 - 2 * phase)

因此,对于新月,我们有照明 == 0,对于第一季度照明 == pi * R * R/2

关于c# - 如何计算圆绕球体的曲率(弧)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75140355/

相关文章:

delphi - 如何在编辑控件中偏移光标的位置?

c# - 如何在管理控制台中打开所选对象的属性对话框?

c# - 获取无法确定调用者错误的应用程序身份

c# - 如何获取列表框中商品的价格总和?

c# - 服务器 500 : Too many pending secure conversations

c# - 如何解决错误 "Must use PackageReference"?

c# - 遵循 DRY 原则的业务规则验证

c# - 使用偏移在 Canvas 上绘制点?

javascript - html canvas - 绘制带动画和数字的圆圈

c# - web api put 识别查询字符串但不识别正文