我想画一个代表月亮的圆圈,并在这个圆圈上画一条弧线,代表每个照度百分比的太阳照度。 虽然这个月亮的图像是二维的,但我需要弧线的曲率具有“真实感”。 我想要一个函数,它接收作为照明百分比的参数(例如: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.12、0.27、0.54、0.95):
如果您坚持照明百分比,您应该求解方程。月球照明是月球一半加上或减去椭圆一半的面积,例如相位[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/