中华农历论坛知识讨论区历法知识 → Swiss Ephemeris 应用程序编程接口(1)


  共有39544人关注过本帖树形打印

主题:Swiss Ephemeris 应用程序编程接口(1)

帅哥哟,离线,有人找我吗?
hero_hacker
  21楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:56 积分:682 威望:0 精华:1 注册:2010/8/12 21:56:00
  发帖心情 Post By:2016/10/4 13:18:00

例二 水星大距计算
void greatest_elongation()
{

double dret[20];

double jut,tjd_ut;

int i=0,j,k;

int direct=0;

double buffer=0;

char buf[8000];

char s[AS_MAXCH];

double d_timezone=-8;
    int32 iyear_out, imonth_out, iday_out, ihour_out, imin_out;

double dsec_out;

int flag=0;



strcpy(buf,"");



jday = 1;

jmon = 1;//pd.mon;

jyear = pd.year;

jhour = (int)d_timezone;

jmin = 0;

jsec = 0;

jut = jhour + jmin / 60.0 + jsec / 3600.0;



if ((long) pd.year * 10000L + (long) pd.mon * 100L + (long) pd.mday < 15821015L)


gregflag = FALSE;

else


gregflag = TRUE;



tjd_ut = swe_julday(jyear,jmon,jday,jut,gregflag);

tjd = tjd_ut;

//  SE_MERCURY      2  水星

for(i=0;i<365;i++)

{


swe_pheno(tjd, SE_MERCURY, iflag, dret, serr);


if(buffer!=0)


{



flag=0;



if(dret[2]>=buffer) //上升



{




if(direct==-1)




{





flag=1;




}




direct=1;



}



else if(dret[2]


{




if(direct==1)




{





flag=2;




}




direct=-1;



}







if(dret[2]>15 && flag>=1)



{




tjd=tjd-1;        //回退一天




buffer=0;




for(j=0;j<24;j++) 




{





tjd=tjd+(double)1/24;





swe_pheno(tjd, SE_MERCURY, iflag, dret, serr);





if(dret[2]




{






buffer = dret[2];






break;





}





buffer = dret[2];




}









tjd=tjd-(double)1/24;




for(k=0;k<60;k++)




{





tjd=tjd+(double)1/1440;





swe_pheno(tjd, SE_MERCURY, iflag, dret, serr);





if(dret[2]




{






buffer = dret[2];






break;





}





buffer = dret[2];




}









swe_revjul(tjd, gregflag, &jyear, &jmon, &jday, &jut);




jut += 0.5 / 3600;




jhour = (int) jut;




jmin = (int) fmod(jut * 60, 60);




jsec = (int) fmod(jut * 3600, 60);









swe_utc_time_zone(





jyear, jmon, jday,





jhour, jmin, jsec,





d_timezone,





&iyear_out, &imonth_out, &iday_out,





&ihour_out, &imin_out, &dsec_out





);









sprintf(s, "水星大距  %d.%d.%d - %02d:%02d\r\n", iyear_out, imonth_out, iday_out,ihour_out, imin_out);




do_print(buf, s);




buffer=0;




direct=0;




tjd = swe_julday(jyear,jmon,jday,jut,gregflag);



}














}


buffer = dret[2];


tjd++;

}



MessageBox(0,buf,"",0);
}
[此贴子已经被作者于2016-10-6 22:16:53编辑过]

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
hero_hacker
  22楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:56 积分:682 威望:0 精华:1 注册:2010/8/12 21:56:00
  发帖心情 Post By:2016/10/5 11:09:00

// 例三 木星合月的测试计算
int Conjunction()
{

char serr[AS_MAXCH]; 

int jday = 1, jmon = 1, jyear = 2016;

double jut = 0.0;

double tjd_ut, x[6],x1,x2,y;

long iflag, iflgret;

double d_timezone=-8;

char buf[8000];

char s[AS_MAXCH];

int direct=0;

double buffer=0;
    int32 iyear_out, imonth_out, iday_out, ihour_out, imin_out;

double dsec_out;

int flag=0,j,k;



jyear = pd.year;

strcpy(buf,"");

swe_set_ephe_path(NULL);

iflag = SEFLG_SPEED;



// 年月日转换为儒略日数

tjd_ut = swe_julday(jyear,jmon,jday,d_timezone,SE_GREG_CAL);       



tjd_ut--;


for (i = 0; i <= 365; i++)

{


iflgret = swe_calc_ut(tjd_ut, SE_JUPITER, iflag, x, serr);


x1 = swe_degnorm(x[0]);


iflgret = swe_calc_ut(tjd_ut, SE_MOON, iflag, x, serr);


x2 = swe_degnorm(x[0]);


y=fabs(x2-x1);





if(y>=buffer && buffer!=0) //当前值大于上一次的值。取用上一次的时间


{



tjd_ut-=1; //回退一天 0.412155



flag=0;



buffer=0;







for (j = 0; j <= 24; j++)  // 小时计算



{




iflgret = swe_calc_ut(tjd_ut, SE_JUPITER, iflag, x, serr);




x1 = swe_degnorm(x[0]);




iflgret = swe_calc_ut(tjd_ut, SE_MOON, iflag, x, serr);




x2 = swe_degnorm(x[0]);




y=fabs(x2-x1);









if(y>=buffer && buffer!=0) //




{





buffer=0;





tjd_ut-=(double)2/24; //回退一小时  0.083471





flag=0;





for (k = 0; k <= 60; k++)  // 分计算





{






iflgret = swe_calc_ut(tjd_ut, SE_JUPITER, iflag, x, serr);






x1 = swe_degnorm(x[0]);






iflgret = swe_calc_ut(tjd_ut, SE_MOON, iflag, x, serr);






x2 = swe_degnorm(x[0]);






y=fabs(x2-x1);













if(y>=buffer && buffer!=0) //上升






{







swe_revjul(tjd_ut, gregflag, &jyear, &jmon, &jday, &jut);







jut += 0.5 / 3600;







jhour = (int) jut;







jmin = (int) fmod(jut * 60, 60);







jsec = (int) fmod(jut * 3600, 60);















swe_utc_time_zone(








jyear, jmon, jday,








jhour, jmin, jsec,








d_timezone,








&iyear_out, &imonth_out, &iday_out,








&ihour_out, &imin_out, &dsec_out








);















sprintf(s, "木星合月  %d.%d.%d - %02d:%02d\r\n", iyear_out, imonth_out, iday_out,ihour_out, imin_out);







do_print(buf, s);







flag=0;







buffer=0;







direct=0;







i=i+27;







tjd_ut = swe_julday(jyear,jmon,jday+27,d_timezone,SE_GREG_CAL);







goto out;






}






tjd_ut=tjd_ut+(double)1/1440;






buffer = y;





}




}




tjd_ut+=(double)1/24;




buffer = y;



}


}
out:


tjd_ut+=1;


buffer = y;

}

MessageBox(0,buf,"",0);

return OK;
}

[此贴子已经被作者于2016-10-9 19:04:54编辑过]

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
hero_hacker
  23楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:56 积分:682 威望:0 精华:1 注册:2010/8/12 21:56:00
  发帖心情 Post By:2016/10/6 22:18:00

// 例四 水星“留”的计算
void retention()
{

char serr[AS_MAXCH]; 

int jday = 1, jmon = 1, jyear = 2016;

double jut = 0.0;

double tjd_ut, x[6];

long iflag, iflgret;

double d_timezone=-8;

char buf[8000];

char s[AS_MAXCH];

int direct=0;

double buffer=0;
    int32 iyear_out, imonth_out, iday_out, ihour_out, imin_out;

double dsec_out;

int flag=0,j,k;



jyear = pd.year;

strcpy(buf,"");

swe_set_ephe_path(NULL);

iflag = SEFLG_SPEED;



// 年月日转换为儒略日数

tjd_ut = swe_julday(jyear,jmon,jday,d_timezone,SE_GREG_CAL);       



tjd_ut--;



for (i = 0; i <= 365; i++)

{


iflgret = swe_calc(tjd_ut, SE_MERCURY, iflag, x, serr);





if(buffer!=0)


{



flag=0;



if(x[3]>=buffer) //上升



{




if(x[3]>0 && buffer<0)





flag=1;



}



else if(x[3]


{




if(buffer>=0 && x[3]<0)





flag=2;



}







if(flag>=1)



{




tjd_ut-=1; //回退一天 0.412155




flag=0;




buffer=0;









for (j = 0; j <= 24; j++)  // 小时计算




{





iflgret = swe_calc(tjd_ut, SE_MERCURY, iflag, x, serr);











if( (buffer>0 && x[3]<0) || (buffer<0 && x[3]>0) )//





{






buffer=0;






tjd_ut-=(double)2/24; //回退一小时  0.083471






flag=0;






for (k = 0; k <= 120; k++)  // 分计算






{







iflgret = swe_calc(tjd_ut, SE_MERCURY, iflag, x, serr);















if( (buffer>0 && x[3]<0) || (buffer<0 && x[3]>0) )//上升







{








swe_revjul(tjd_ut, gregflag, &jyear, &jmon, &jday, &jut);








jut += 0.5 / 3600;








jhour = (int) jut;








jmin = (int) fmod(jut * 60, 60);








jsec = (int) fmod(jut * 3600, 60);









swe_utc_time_zone(








jyear, jmon, jday,








jhour, jmin, jsec,








d_timezone,








&iyear_out, &imonth_out, &iday_out,








&ihour_out, &imin_out, &dsec_out








);















sprintf(s, "水星留  %d.%d.%d - %02d:%02d\r\n", iyear_out, imonth_out, iday_out,ihour_out, imin_out);
















//sprintf(s, "水星留  %d.%d.%d - %02d:%02d\r\n", jyear, jmon, jday,jhour, jmin);








do_print(buf, s);








flag=0;








buffer=0;








direct=0;








i=i+19;








tjd_ut = swe_julday(jyear,jmon,jday+19,d_timezone,SE_GREG_CAL);








goto out;







}







tjd_ut=tjd_ut+(double)1/1440;







buffer = x[3];






}





}





tjd_ut+=(double)1/24;





buffer = x[3];




}



}


}



tjd_ut+=1;


buffer = x[3];
out:;

}

MessageBox(0,buf,"",0);

return ;
}
[此贴子已经被作者于2016-10-10 10:50:30编辑过]

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
iflfwl
  24楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:1 积分:201 威望:0 精华:0 注册:2016/10/6 23:48:00
  发帖心情 Post By:2016/10/7

 感谢汉化了!想请教,读取了Swiss Ephemeris中经度、纬度、距离、经度速度这些数据怎么转换成星盘上黄道和赤道上的度数?

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
hero_hacker
  25楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:56 积分:682 威望:0 精华:1 注册:2010/8/12 21:56:00
  发帖心情 Post By:2016/10/9 19:05:00

// 例五 土星冲日
// SE_SATURN
/*
土星冲日是指土星、地球、太阳三者依次排成一条直线,
也就是土星与太阳黄经相差180度的现象,天文学上称为“土星冲日”。
*/
int opposition()
{

char serr[AS_MAXCH]; 

int jday = 1, jmon = 1, jyear = 2016;

double jut = 0.0;

double tjd_ut, x[6],x1,x2,y;

long iflag, iflgret;

double d_timezone=-8;

char buf[8000];

char s[AS_MAXCH];

int direct=0;

double buffer=0;


int flag=0,j,k;



jyear = pd.year;

strcpy(buf,"");

swe_set_ephe_path(NULL);

iflag = SEFLG_SPEED;




tjd_ut = swe_julday(jyear,jmon,jday,d_timezone,SE_GREG_CAL);       



tjd_ut--;


for (i = 0; i <= 365; i++)

{


iflgret = swe_calc(tjd_ut, SE_SATURN, iflag, x, serr);


x1 = swe_degnorm(x[0]);


iflgret = swe_calc(tjd_ut, SE_SUN, iflag, x, serr);


x2 = swe_degnorm(x[0]);


y=fabs(fabs(x2-x1)-180);





if(y>=buffer && buffer!=0 && y<2)


{



tjd_ut-=2;



flag=0;



buffer=0;







for (j = 0; j <= 24; j++) 



{




iflgret = swe_calc(tjd_ut, SE_SATURN, iflag, x, serr);




x1 = swe_degnorm(x[0]);




iflgret = swe_calc(tjd_ut, SE_SUN, iflag, x, serr);




x2 = swe_degnorm(x[0]);




y=fabs(fabs(x2-x1)-180);









if(y>=buffer && buffer!=0)




{





buffer=0;





tjd_ut-=(double)2/24;





flag=0;





for (k = 0; k <= 60; k++) 





{






iflgret = swe_calc(tjd_ut, SE_SATURN, iflag, x, serr);






x1 = swe_degnorm(x[0]);






iflgret = swe_calc(tjd_ut, SE_SUN, iflag, x, serr);






x2 = swe_degnorm(x[0]);






y=fabs(fabs(x2-x1)-180);













if(y>=buffer && buffer!=0)






{







swe_revjul(tjd_ut, gregflag, &jyear, &jmon, &jday, &jut);







jut += 0.5 / 3600;







jhour = (int) jut;







jmin = (int) fmod(jut * 60, 60);







jsec = (int) fmod(jut * 3600, 60);
















sprintf(s, "土星冲日  %d.%d.%d - %02d:%02d\r\n", jyear, jmon, jday,jhour, jmin);







do_print(buf, s);







flag=0;







buffer=0;







direct=0;







i=i+3;







tjd_ut = swe_julday(jyear,jmon,jday+3,d_timezone,SE_GREG_CAL);







goto out;






}






tjd_ut=tjd_ut+(double)1/1440;






buffer = y;





}




}




tjd_ut+=(double)1/24;




buffer = y;



}


}


tjd_ut+=1;


buffer = y;
out:;

}

MessageBox(0,buf,"",0);

return OK;
}
[此贴子已经被作者于2016-10-11 16:53:17编辑过]

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
hero_hacker
  26楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:56 积分:682 威望:0 精华:1 注册:2010/8/12 21:56:00
  发帖心情 Post By:2016/10/10 10:51:00

// 例六 土星方照
void quadrature()
{

char serr[AS_MAXCH]; 

int jday = 1, jmon = 1, jyear = 2016;

double jut = 0.0;

double tjd_ut, x[6],x1,x2,y;

long iflag, iflgret;

double d_timezone=-8;

char buf[8000];

char s[AS_MAXCH];

int direct=0;

double buffer=0;


int flag=0,j,k;



jyear = pd.year;

strcpy(buf,"");

swe_set_ephe_path(NULL);

iflag = SEFLG_SPEED;




tjd_ut = swe_julday(jyear,jmon,jday,d_timezone,SE_GREG_CAL);       



tjd_ut--;


for (i = 0; i <= 365; i++)

{


iflgret = swe_calc(tjd_ut, SE_SATURN, iflag, x, serr);


x1 = swe_degnorm(x[0]);


iflgret = swe_calc(tjd_ut, SE_SUN, iflag, x, serr);


x2 = swe_degnorm(x[0]);


y=fabs(fabs(x2-x1)-90);





if(y>=buffer && buffer!=0 && y<2)


{



tjd_ut-=2;



flag=0;



buffer=0;







for (j = 0; j <= 24; j++) 



{




iflgret = swe_calc(tjd_ut, SE_SATURN, iflag, x, serr);




x1 = swe_degnorm(x[0]);




iflgret = swe_calc(tjd_ut, SE_SUN, iflag, x, serr);




x2 = swe_degnorm(x[0]);




y=fabs(fabs(x2-x1)-90);









if(y>=buffer && buffer!=0)




{





buffer=0;





tjd_ut-=(double)2/24;





flag=0;





for (k = 0; k <= 60; k++) 





{






iflgret = swe_calc(tjd_ut, SE_SATURN, iflag, x, serr);






x1 = swe_degnorm(x[0]);






iflgret = swe_calc(tjd_ut, SE_SUN, iflag, x, serr);






x2 = swe_degnorm(x[0]);






y=fabs(fabs(x2-x1)-90);













if(y>=buffer && buffer!=0)






{







swe_revjul(tjd_ut, gregflag, &jyear, &jmon, &jday, &jut);







jut += 0.5 / 3600;







jhour = (int) jut;







jmin = (int) fmod(jut * 60, 60);







jsec = (int) fmod(jut * 3600, 60);
















sprintf(s, "土星方照  %d.%d.%d - %02d:%02d\r\n", jyear, jmon, jday,jhour, jmin);







do_print(buf, s);







flag=0;







buffer=0;







direct=0;







i=i+3;







tjd_ut = swe_julday(jyear,jmon,jday+3,d_timezone,SE_GREG_CAL);







goto out;






}






tjd_ut=tjd_ut+(double)1/1440;






buffer = y;





}




}




tjd_ut+=(double)1/24;




buffer = y;



}


}


tjd_ut+=1;


buffer = y;
out:;

}

MessageBox(0,buf,"",0);

return ;
}
[此贴子已经被作者于2016-10-12 8:37:52编辑过]

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
hero_hacker
  27楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:56 积分:682 威望:0 精华:1 注册:2010/8/12 21:56:00
  发帖心情 Post By:2016/10/13 9:39:00

// 例七 月过近地点、远地点时间计算
void Apogee_Perigee()
{

char serr[AS_MAXCH]; 

int jday = 1, jmon = 1, jyear = 2016;

double jut = 0.0;

double tjd_ut, x[6],x1,x2,x0;

long iflag, iflgret;

double d_timezone=-8;

char buf[8000];

char s[AS_MAXCH];

int direct=0;

double buffer=0;
    int32 iyear_out, imonth_out, iday_out, ihour_out, imin_out;

double dsec_out;

int flag=0,a;



jyear = pd.year;

strcpy(buf,"");

swe_set_ephe_path(NULL);

iflag = SEFLG_SPEED;



// 年月日转换为儒略日数

tjd_ut = swe_julday(jyear,jmon,jday,d_timezone,SE_GREG_CAL);       



tjd_ut--;



while(TRUE)

{


swe_calc(tjd_ut-(double)1/1440, SE_MOON, iflag, x, serr);


x0=x[2];


iflgret = swe_calc(tjd_ut, SE_MOON, iflag, x, serr);


x1=x[2];


iflgret = swe_calc(tjd_ut+(double)1/1440, SE_MOON, iflag, x, serr);


x2=x[2];





flag=0;


if(x1>x0 && x1>x2)



flag=1;


if(x1


flag=2;



if(flag>=1)


{



swe_revjul(tjd_ut, gregflag, &jyear, &jmon, &jday, &jut);



jut += 0.5 / 3600;



jhour = (int) jut;



jmin = (int) fmod(jut * 60, 60);



jsec = (int) fmod(jut * 3600, 60);







swe_utc_time_zone(




jyear, jmon, jday,




jhour, jmin, jsec,




d_timezone,




&iyear_out, &imonth_out, &iday_out,




&ihour_out, &imin_out, &dsec_out




);







if(jyear>pd.year)




break;




a=(x1*149597870700)/1000;



if(a>400000)




sprintf(s, "月球过远地点  %d.%d.%d - %02d:%02d %dkm\r\n", iyear_out, imonth_out, iday_out,ihour_out, imin_out,a);



else




sprintf(s, "月球过近地点  %d.%d.%d - %02d:%02d %dkm\r\n", iyear_out, imonth_out, iday_out,ihour_out, imin_out,a);




do_print(buf, s);




tjd_ut = swe_julday(jyear,jmon,jday+12,d_timezone,SE_GREG_CAL);


}


tjd_ut+=(double)1/1440;

}

MessageBox(0,buf,"",0);

return ;
}

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
hero_hacker
  28楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:56 积分:682 威望:0 精华:1 注册:2010/8/12 21:56:00
  发帖心情 Post By:2016/10/14 9:39:00

// 例八 月过赤纬点计算
void declination()
{

char serr[AS_MAXCH]; 

int jday = 1, jmon = 1, jyear = 2016;

double jut = 0.0;

double tjd_ut, x[6],x1,x2,x0;

long iflag, iflgret;

double d_timezone=-8;

char buf[8000];

char s[AS_MAXCH];

int direct=0;

double buffer=0;
    int32 iyear_out, imonth_out, iday_out, ihour_out, imin_out;

double dsec_out;

int flag=0;



jyear = pd.year;

strcpy(buf,"");

swe_set_ephe_path(NULL);

iflag = SEFLG_SPEED;



// 年月日转换为儒略日数

tjd_ut = swe_julday(jyear,jmon,jday,d_timezone,SE_GREG_CAL);       



tjd_ut--;



while(TRUE)

{


swe_calc(tjd_ut-(double)1/1440, SE_MOON, iflag, x, serr);


swe_calc(tjd_ut-(double)1/1440, SE_MOON, iflag | SEFLG_EQUATORIAL, x, serr);


x0=x[1];


iflgret = swe_calc(tjd_ut, SE_MOON, iflag, x, serr);


iflgret = swe_calc(tjd_ut, SE_MOON, iflag | SEFLG_EQUATORIAL, x, serr);


x1=x[1];


iflgret = swe_calc(tjd_ut+(double)1/1440, SE_MOON, iflag, x, serr);


iflgret = swe_calc(tjd_ut+(double)1/1440, SE_MOON, iflag | SEFLG_EQUATORIAL, x, serr);


x2=x[1];





flag=0;


if(x1>x0 && x1>x2)



flag=1;


if(x1


flag=2;



if(flag>=1)


{



swe_revjul(tjd_ut, gregflag, &jyear, &jmon, &jday, &jut);



jut += 0.5 / 3600;



jhour = (int) jut;



jmin = (int) fmod(jut * 60, 60);



jsec = (int) fmod(jut * 3600, 60);







swe_utc_time_zone(




jyear, jmon, jday,




jhour, jmin, jsec,




d_timezone,




&iyear_out, &imonth_out, &iday_out,




&ihour_out, &imin_out, &dsec_out




);







if(jyear>pd.year)




break;




if(x[1]>0)




sprintf(s, "月过赤纬北点  %d.%d.%d - %02d:%02d %f°\r\n", iyear_out, imonth_out, iday_out,ihour_out, imin_out,x[1]);



else




sprintf(s, "月过赤纬南点  %d.%d.%d - %02d:%02d %f°\r\n", iyear_out, imonth_out, iday_out,ihour_out, imin_out,x[1]);




do_print(buf, s);




tjd_ut = swe_julday(jyear,jmon,jday+10,d_timezone,SE_GREG_CAL);


}


tjd_ut+=(double)1/1440;

}

MessageBox(0,buf,"",0);

return ;
}

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
hero_hacker
  29楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:56 积分:682 威望:0 精华:1 注册:2010/8/12 21:56:00
  发帖心情 Post By:2016/10/15 8:59:00

// 例九 地球的近日点远日点计算
void perihelion_aphelion()
{

char serr[AS_MAXCH]; 

int jday = 1, jmon = 1, jyear = 2016;

double jut = 0.0;

double tjd_ut, x[6],x1,x2,x0;

long iflag, iflgret;

double d_timezone=-8;

char buf[8000];

char s[AS_MAXCH];

int direct=0;

double buffer=0;
    int32 iyear_out, imonth_out, iday_out, ihour_out, imin_out;

double dsec_out;

int flag=0;



jyear = pd.year;

strcpy(buf,"");

swe_set_ephe_path(NULL);

iflag = SEFLG_SPEED;



// 年月日转换为儒略日数

tjd_ut = swe_julday(jyear,jmon,jday,d_timezone,SE_GREG_CAL);       



tjd_ut--;



while(TRUE)

{


swe_calc(tjd_ut-(double)1/1440, SE_SUN, iflag, x, serr);


x0=x[2];


iflgret = swe_calc(tjd_ut, SE_SUN, iflag, x, serr);


x1=x[2];


iflgret = swe_calc(tjd_ut+(double)1/1440, SE_SUN, iflag, x, serr);


x2=x[2];





flag=0;


if(x1>x0 && x1>x2)



flag=1;


if(x1


flag=2;



if(flag>=1)


{



swe_revjul(tjd_ut, gregflag, &jyear, &jmon, &jday, &jut);



jut += 0.5 / 3600;



jhour = (int) jut;



jmin = (int) fmod(jut * 60, 60);



jsec = (int) fmod(jut * 3600, 60);







swe_utc_time_zone(




jyear, jmon, jday,




jhour, jmin, jsec,




d_timezone,




&iyear_out, &imonth_out, &iday_out,




&ihour_out, &imin_out, &dsec_out




);







if(jyear>pd.year)




break;




if(jmon==1)




sprintf(s, "地球过近日点  %d.%d.%d - %02d:%02d %fau\r\n", iyear_out, imonth_out, iday_out,ihour_out, imin_out,x[2]);



else




sprintf(s, "地球过远日点  %d.%d.%d - %02d:%02d %fau\r\n", iyear_out, imonth_out, iday_out,ihour_out, imin_out,x[2]);




do_print(buf, s);




tjd_ut = swe_julday(jyear,jmon,jday+160,d_timezone,SE_GREG_CAL);


}


tjd_ut+=(double)1/1440;

}

MessageBox(0,buf,"",0);

return ;
}

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
hero_hacker
  30楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:56 积分:682 威望:0 精华:1 注册:2010/8/12 21:56:00
  发帖心情 Post By:2016/10/16 22:20:00

// 例十 月亮过升交点、降交点
/*
月球交点是月球的轨道交点,它是月球轨道在天球上穿越过黄道(太阳在以恒星为背景的天球上移动的路径)的位置。
升交点是月球穿越黄道进入北方的点,降交点是穿越黄道进入南方的点。
当月亮经过升交点或者降交点时 其地心黄纬为零。
*/
void moon_node()
{

char serr[AS_MAXCH]; 

int jday = 1, jmon = 1, jyear = pd.year;

double jut = 0.0;

double tjd_ut, x[6],x1,x2,x0;

long iflag=SEFLG_SPEED;

double d_timezone=-8;

char buf[8000];

char s[AS_MAXCH];
    int32 iyear_out, imonth_out, iday_out, ihour_out, imin_out;

double dsec_out;

int flag=0;



strcpy(buf,"");

swe_set_ephe_path(NULL);



// 年月日转换为儒略日数

tjd_ut = swe_julday(jyear,jmon,jday,d_timezone,SE_GREG_CAL);       



tjd_ut--;



while(TRUE)

{


swe_calc(tjd_ut-(double)1/1440, SE_MOON, iflag, x, serr);


x0=x[1];


swe_calc(tjd_ut, SE_MOON, iflag, x, serr);


x1=x[1];


swe_calc(tjd_ut+(double)1/1440, SE_MOON, iflag, x, serr);


x2=x[1];





flag=0;



if( (x1>0 && x0<0) || (x1<0 && x0="x0" >0) )



flag=1;



swe_revjul(tjd_ut, gregflag, &jyear, &jmon, &jday, &jut);


if(jyear>pd.year)



break;



if(flag>=1)


{



swe_revjul(tjd_ut, gregflag, &jyear, &jmon, &jday, &jut);



jut += 0.5 / 3600;



jhour = (int) jut;



jmin = (int) fmod(jut * 60, 60);



jsec = (int) fmod(jut * 3600, 60);







swe_utc_time_zone(




jyear, jmon, jday,




jhour, jmin, jsec,




d_timezone,




&iyear_out, &imonth_out, &iday_out,




&ihour_out, &imin_out, &dsec_out




);







if(jyear>pd.year)




break;





if(x1



sprintf(s, "月过降交点  %d.%d.%d - %02d:%02d\r\n", iyear_out, imonth_out, iday_out,ihour_out, imin_out);



else




sprintf(s, "月过升交点  %d.%d.%d - %02d:%02d\r\n", iyear_out, imonth_out, iday_out,ihour_out, imin_out);




do_print(buf, s);




tjd_ut = swe_julday(jyear,jmon,jday+13,d_timezone,SE_GREG_CAL);


}


tjd_ut+=(double)1/1440;

}

MessageBox(0,buf,"",0);

return ;
}

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
总数 31 上一页 1 2 3 4 下一页

返回版面帖子列表

Swiss Ephemeris 应用程序编程接口(1)








签名