- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在我的 C 应用程序中,我想计算给定日期、纬度和经度的日出/日落时间。我一直在网上搜索,但找不到可用的示例。
我试图实现这个示例: http://souptonuts.sourceforge.net/code/sunrise.c.html
但是这个示例没有正常工作。
是否有可以在我的应用程序中轻松实现的简单 C 源代码或方法?
编辑:
我在这个 link 上实现了代码但它给了我错误的日落/日出值。我也尝试了 Saul 的链接 here但它也给了我错误的结果。
我有41N,28E位置。当我尝试这些代码时,两个示例都表示日出时间约为 10:13,日落时间为 23:24。但正确的值是 06:06、20:13。
我无法理解这个问题。
最佳答案
计算 sunrise / sunset time 的十个简单步骤给定日期、纬度和经度
首先计算一年中的第几天
N1 = floor(275 * 月/9)N2 = floor((month + 9)/12)N3 = (1 + floor((year - 4 * floor(year/4) + 2)/3))N = N1 - (N2 * N3) + 天 - 30
将经度转换为小时值并计算大概时间
lngHour = 经度/15
如果需要上升时间: t = N + ((6 - lngHour)/24)如果需要设置时间: t = N + ((18 - lngHour)/24)
计算太阳的平均距平
M = (0.9856 * t) - 3.289
计算太阳的真经度
L = M + (1.916 * sin(M)) + (0.020 * sin(2 * M)) + 282.634注意:L 可能需要通过加/减 360 调整到 [0,360) 范围内
5a。计算太阳的赤经
RA = atan(0.91764 * tan(L))
NOTE: RA potentially needs to be adjusted into the range [0,360) by adding/subtracting 360
5b。赤经值需要和L在同一象限
Lquadrant = (floor( L/90)) * 90
RAquadrant = (floor(RA/90)) * 90
RA = RA + (Lquadrant - RAquadrant)
5c。赤经值需要换算成小时
RA = RA / 15
计算太阳的赤纬
sinDec = 0.39782 * sin(L)cosDec = cos(asin(sinDec))
7a。计算太阳的地方时角
cosH = (cos(zenith) - (sinDec * sin(latitude))) / (cosDec * cos(latitude))
if (cosH > 1)
the sun never rises on this location (on the specified date)
if (cosH < -1)
the sun never sets on this location (on the specified date)
7b。计算完H并换算成小时
if if rising time is desired:
H = 360 - acos(cosH)
if setting time is desired:
H = acos(cosH)
H = H / 15
计算本地上升/下降的平均时间
T = H + RA - (0.06571 * t) - 6.622
调整回 UTC
UT = T - lngHour注意:UT 可能需要通过加/减 24 调整到 [0,24) 范围内
将UT值转换为本地时区的纬度/经度
localT = UT + localOffset
关于c - c中的日出日落时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7064531/
对于我的应用程序,我使用 sunriseCalc-lib。这个库计算日出时间并返回像这样的字符串 12:20。是否可以检查当前时间是否晚于日出时间?我有以下代码: Location l
我正在尝试根据下面提供的链接使用 python 计算日落/上升时间。 我通过 excel 和 python 完成的结果与实际值不匹配。关于我可能做错了什么的任何想法? 我的 Excel 工作表可以在
在 Google 地球中,您可以使用“阳光”图层查看地形在任何给定日期时间转换的阴影:http://i.stack.imgur.com/YFGMj.png 但是,我无法找到任何方法从 API 访问阳光
C# 中有没有一种方法可以计算给定的纬度和经度在给定的一天太阳落下和升起的时间? 最佳答案 我知道这篇文章很旧,但万一有人还在看... CoordinateSharp可以作为 Nuget 包使用。它是
PyEphem是一个简洁的库,可以根据纬度、经度和 UTC 时间戳轻松计算位置的日出、日落、黎明和黄昏 我不想浏览 calculation我自己,而是想知道是否有一个我可以使用的现有库 最佳答案 ht
基本上我想做的是: 获取观察点(使用纬度/经度) 在给定起始日期的情况下计算下一个春分和至日的日期 找出每个人的日落方位角 找出每个人的日出方位角 *请注意,我在 ArcGIS 中工作,所以我的一些值
我是一名优秀的程序员,十分优秀!