日期:2014-05-17  浏览次数:20726 次

大侠们帮看看,根据经度纬度日期算出日出日落时间,数据怎么差这么大
 public static void main(String[] args) throws Exception {
  String date1 = "2000/1/1";
  String date2 = getDate();
  //1计算day
  long day = getQuot(date1,date2);
  System.out.println( "距离 "+date1+" 还有 "+day+" 天" );
  double uto = 180.0;
  //2计算世纪数t
  double t = (day + uto/360)/36525;
  System.out.println("世纪数t:"+t);
  //3计算太阳的平黄经
  double l = 280.460 + 36000.770*t;
  System.out.println("平黄经l:"+l);
  //4计算太阳的平近点角
  double g = 357.528 +35999.050*t;
  System.out.println("平近点角g:"+g);
  //5计算太阳的黄道经度
  double y = l +1.915 * Math.sin(g) + 0.020 * Math.sin(2*g);
  System.out.println("黄道经度y:"+y);
  //6计算地球倾角
  double e = 23.4393 - 0.0130 * t;
  System.out.println("地球倾角e:"+e);
  //7计算太阳偏差
  double q = Math.asin( Math.sin(e) * Math.sin(y));
  System.out.println("太阳偏差q:"+q);
  //计算格林威治时间的太阳角gha
  double gha = uto -180 -1.915 * Math.sin(g) - 0.020 * Math.sin(2*g) + 2.466 * Math.sin(2*y) - 0.053 * Math.sin(4*y);
  System.out.println("格林威治时间的太阳角gha:"+gha);
  //定义h
  double h = -0.833;
  //定义纬度(bj)
  double glat = 39.92;
  //定义经度(bj)
  double lon = 116.46;
  //计算修正值ce
  double ce = Math.acos((Math.sin(h) - Math.sin(glat) * Math.sin(q)) / (Math.cos(glat) * Math.cos(q)));
  System.out.println("修正值ce:"+ce);
  //计算出日出日落时间
  double utsunrise = uto - (gha + lon + ce);
  double utsunset = uto - (gha + lon - ce);
  System.out.println("计算出日出时间utsunrise:"+utsunrise);
  System.out.println("计算出日落时间utsunset:"+utsunset);
  double timerise = utsunrise/15 +8;
  System.out.println("计算出日出时间timerise:"+timerise);

结果,菜菜一枚,请灌水
距离 2000/1/1 还有 4899 天
世纪数t:0.1341409993155373
平黄经l:5109.639263928815
平近点角g:5186.476541409994
黄道经度y:5110.181177816852
地球倾角e:23.437556167008896
太阳偏差q:-1.171209358753135
格林威治时间的太阳角gha:-2.296329676141743
修正值ce:1.5426183526693467
计算出日出时间utsunrise:64.2937113234724
计算出日落时间utsunset:67.3789480288111
计算出日出时间timerise:12.286247421564827

------解决方案--------------------
我也在用这个公式在套,但是我的问题是acos()函数中的参数只能是[1,-1]之间,而求修正值的时候这个地方出错,晕死
------解决方案--------------------
算出来不大对,有结果了吗