月/月相位算法 [英] Moon / Lunar Phase Algorithm

查看:165
本文介绍了月/月相位算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道算法可以计算给定日期的月相或年龄,或者在给定年份中找到新/满月的日期?

Does anyone know an algorithm to either calculate the moon phase or age on a given date or find the dates for new/full moons in a given year?

Googling告诉我答案是在一些天文学书中,但是我真的不想买一整本书,当我只需要一个页面。

Googling tells me the answer is in some Astronomy book, but I don't really want to buy a whole book when I only need a single page.

更新:

我应该证明我的声明有关Google搜索更好一些。我的确找到了解决方案,只工作在一些时间的子集(像1900年代);和基于trig的解决方案,这将比我想要的计算更昂贵。

I should have qualified my statement about googling a little better. I did find solutions that only worked over some subset of time (like the 1900's); and the trig based solutions that would be more computationally expensive than I'd like.

S Lott在他的Python书中有几个算法来计算一年中的复活节,大多数都不到十行代码,有些工作在格里历。在3月份找到满月是找到复活节的关键,所以我想,应该有一个算法,不需要trig,并在公历日历中的所有日期工作。

S Lott in his Python book has several algorithms for calculating Easter on a given year, most are less than ten lines of code and some work for all days in the Gregorian calendar. Finding the full moon in March is a key piece of finding Easter so I figured there should be an algorithm that doesn't require trig and works for all dates in the Gregorian calendar.

推荐答案

我已经将一些代码移植到Python了。我只是链接到它,但事实证明,它脱离了网络在这段时间,所以我不得不把灰尘,并再次上传。查看源自 moon.py href =http://www.fourmilab.ch/moontool/> John Walker的moontool 。

I ported some code to Python for this a while back. I was going to just link to it, but it turns out that it fell off the web in the meantime, so I had to go dust it off and upload it again. See moon.py which is derived from John Walker's moontool.

我找不到这个的参考什么时间跨度是准确的,但似乎作者是相当严格。这意味着是,它确实使用trig,但我不能想象,你会使用它,因为这将使它在计算上是禁止的。 Python函数调用开销可能超过trig操作的成本。计算机在计算上速度很快。

I can't find a reference for this for what time spans it's accurate for either, but seems like the authors were pretty rigorous. Which means yes, it does use trig, but I can't imagine what the heck you would be using this for that would make it computationally prohibitive. Python function call overhead is probably more than the cost of the trig operations. Computers are pretty fast at computing.

代码中使用的算法来自以下来源:

The algorithms used in the code are drawn from the following sources:

Meeus,Jean。天文算法。 Richmond:Willmann-Bell,1991. ISBN 0-943396-35-2。

如果你只买一本书,确保它是这一个。算法以数学方式呈现,而不是作为计算机程序,但是实现本书中许多算法的源代码可以与QuickBasic,Turbo Pascal或C中的发布者分开订购。Meeus提供了许多工作的计算示例,您的代码,并且经常提供几种算法,在精度,速度,复杂性和长期(百年和千年)有效性之间存在不同的权衡。

A must-have; if you only buy one book, make sure it's this one. Algorithms are presented mathematically, not as computer programs, but source code implementing many of the algorithms in the book can be ordered separately from the publisher in either QuickBasic, Turbo Pascal, or C. Meeus provides many worked examples of calculations which are essential to debugging your code, and frequently presents several algorithms with different tradeoffs among accuracy, speed, complexity, and long-term (century and millennia) validity.

Duffett-Smith ,彼得。您的计算器的实用天文学。第3版。剑桥:剑桥大学出版社,1981. ISBN 0-521-28411-2。

如果你有兴趣开发计算行星位置,轨道,日食等的软件,这是一个有价值的参考。更多的背景信息给出比在Meeus,这有助于那些尚未精通天文学习常常混淆的术语。所给出的算法比Meeus提供的算法更简单和更不准确,但是适用于大多数实际工作。

Despite the word Calculator in the title; this is a valuable reference if you're interested in developing software which calculates planetary positions, orbits, eclipses, and the like. More background information is given than in Meeus, which helps those not already versed in astronomy learn the often-confusing terminology. The algorithms given are simpler and less accurate than those provided by Meeus, but are suitable for most practical work.

这篇关于月/月相位算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆