太阳位置计算c程序 c程序怎么计算有几个字符
太阳位置计算c程序
根据Paul Schlyter, Stockholm, Sweden中等精度的行星位置计算方法,实现了其中太阳位置的计算方法。
/////////////////////////////////////////////////////////////////////////////////////////////////////
// nbsp; 名称:太阳位置计算程序
// nbsp; 作者:胡铂()
// nbsp; 日期 2004-09-30
// nbsp; 说明:根据Paul Schlyter, Stockholm, Sweden的中等精度计算方法实现
////////////////////////////////////////////////////////////////////////////////////////////////////
#include
#include
#define Pi nbsp;3.14159265
#define DE Pi/180
/////////////////////////////////////////////////////////////////
float jde(int Y,int M,int D,int hour,int min,int sec)
{
int f,g;
double mid1,mid2,J,JDE,A;
nbsp;if(M>=3)
nbsp;{
nbsp; f=Y;
nbsp; g=M;
nbsp;}
nbsp;if(M==1||M==2)
nbsp;{
nbsp; f=Y-1;
nbsp; g=M+12;
nbsp;};
nbsp;mid1=floor(365.25*f);
nbsp;mid2=floor(30.6001*(g+1));
nbsp;A=2-floor(f/100)+floor(f/400);
nbsp;J=mid1+mid2+D+A+1720994.5;
nbsp;JDE=J+hour/24+min/1440+sec/86400;
nbsp;return JDE;
}
/////////////////////////////////////变量声明///////////////////////////////
void main()
{ int i,year,month,day,hour,min,sec;
nbsp;double d,w,a,e,M,oblecl,L,E,xe,ye,r,v,lon,x,y,z,xequt,yequt,zequt,dist,RA,Decl;
//
scanf(
// printf(
///////////////////////////////测试数据////////////////////////////////////////////////////
year=1990;
month=4;
day=19;
hour=0;
min=0;
sec=0;
////////////////////////////////////////////轨道根数//////////////////////////////////////
nbsp;d=jde(year,month,day,hour,min,sec)-2451543.5;//相对儒略日;
nbsp; w=282.9404+4.70935*0.00001*d;//升交点经度
nbsp; a=1;
nbsp; e=0.016709-1.151*0.000000001*d;//偏心率
nbsp; M = 356.0470 + 0.9856002585 * d;//平近点角
nbsp; oblecl = 23.4393-3.563*0.0000001 * d;//黄赤交角
//////////////////////////////////////////////////////////////////////////////////////////// nbsp; nbsp;L=w+M;//太阳的平均精度
nbsp;L=fmod(L,360);
nbsp;E=M + (180/Pi) * e * sin(M*DE) * (1 + e * cos(M*DE));//(开普勒方程的近似解) nbsp;E=fmod(E,360);
nbsp;xe=cos(E*DE) - e;//椭圆轨道上的直角坐标x
nbsp;ye=sin(E*DE) * sqrt(1 - e*e);//椭圆轨道上的直角坐标y
nbsp;r=sqrt(xe*xe+ye*ye);//距离
nbsp;v=atan2(ye,xe)*180/Pi;//真近点角
nbsp;//lon=fmod((v+w),360);//太阳的精度
nbsp;//太阳的黄道直角坐标
nbsp;lon=v+w;
nbsp;x=r*cos(lon*Pi/180);
nbsp;y=r*sin(lon*Pi/180);
nbsp;z=0;
nbsp;//太阳的赤道直角坐标
nbsp;xequt=x;
nbsp;yequt=y*cos(oblecl*Pi/180);
nbsp;zequt = y* sin(oblecl*Pi/180);
nbsp;//日地距离、赤经赤纬
nbsp;dist=sqrt(xequt*xequt+yequt*yequt);
nbsp;RA=atan2(yequt,xequt)*180/Pi;
nbsp;RA=fmod(RA,360);
nbsp;Decl=asin(zequt/r)*180/Pi;
nbsp;Decl=fmod(Decl,360);
nbsp;////////////////////////////////////////////////////////////////////
nbsp;printf(
nbsp; printf(
nbsp; printf(
nbsp; printf(
nbsp; printf(
nbsp; printf(
nbsp; printf(
nbsp; printf(
nbsp; printf(
nbsp; printf(
nbsp; printf(
nbsp; printf(
nbsp; printf(
nbsp; printf(
nbsp;
nbsp;
nbsp;
nbsp;
}
/////////////////////////////////
/////////////////////////////////////////////
太阳位置计算程序(2006-12-24 15:07:26)
转载 分类:格物偶得
/////////////////////////////////////////////////////////////////////////////////////////////////////
// 名称:太阳位置计算程序
// 作者:胡铂(.org)
// 日期 2004-09-30
// 说明:根据Paul Schlyter, Stockholm, Sweden的中等精度计算方法实现
////////////////////////////////////////////////////////////////////////////////////////////////////
#include
#include
#define Pi 3.14159265
#define DE Pi/180
/////////////////////////////////////////////////////////////////
float jde(int Y,int M,int D,int hour,int min,int sec)
{
int f,g;
double mid1,mid2,J,JDE,A;
if(M>=3)
{
f=Y;
g=M;
}
if(M==1||M==2)
{
f=Y-1;
g=M+12;
};
mid1=floor(365.25*f);
mid2=floor(30.6001*(g+1));
A=2-floor(f/100)+floor(f/400);
J=mid1+mid2+D+A+1720994.5;
JDE=J+hour/24+min/1440+sec/86400;
return JDE;
}
/////////////////////////////////////变量声明///////////////////////////////
void main()
{ int i,year,month,day,hour,min,sec;
double d,w,a,e,M,oblecl,L,E,xe,ye,r,v,lon,x,y,z,xequt,yequt,zequt,dist,RA,Decl;
// scanf(
// printf(
///////////////////////////////测试数据////////////////////////////////////////////////////
year=1990;
month=4;
day=19;
hour=0;
min=0;
sec=0;
////////////////////////////////////////////轨道根数//////////////////////////////////////
d=jde(year,month,day,hour,min,sec)-2451543.5;//相对儒略日;
w=282.9404+4.70935*0.00001*d;//升交点经度
a=1;
e=0.016709-1.151*0.000000001*d;//偏心率
M = 356.0470 + 0.9856002585 * d;//平近点角
oblecl = 23.4393-3.563*0.0000001 * d;//黄赤交角
////////////////////////////////////////////////////////////////////////////////////////////
L=w+M;//太阳的平均精度
L=fmod(L,360);
E=M + (180/Pi) * e * sin(M*DE) * (1 + e * cos(M*DE));//(开普勒方程的近似解) E=fmod(E,360);
xe=cos(E*DE) - e;//椭圆轨道上的直角坐标x
ye=sin(E*DE) * sqrt(1 - e*e);//椭圆轨道上的直角坐标y
r=sqrt(xe*xe+ye*ye);//距离
v=atan2(ye,xe)*180/Pi;//真近点角
//lon=fmod((v+w),360);//太阳的精度
//太阳的黄道直角坐标
lon=v+w;
x=r*cos(lon*Pi/180);
y=r*sin(lon*Pi/180);
z=0;
//太阳的赤道直角坐标
xequt=x;
yequt=y*cos(oblecl*Pi/180);
zequt = y* sin(oblecl*Pi/180);
//日地距离、赤经赤纬
dist=sqrt(xequt*xequt+yequt*yequt);
RA=atan2(yequt,xequt)*180/Pi;
RA=fmod(RA,360);
Decl=asin(zequt/r)*180/Pi;
Decl=fmod(Decl,360);
////////////////////////////////////////////////////////////////////
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
}
/////////////////////////////////////////////////////////////////////////
太阳位置计算程序
///////////////////////////////////////////////////////////////////////////////////////////////////// // 名称:太阳位置计算程序
// 作者:胡铂(.org)
// 日期 2004-09-30
// 说明:根据Paul Schlyter, Stockholm, Sweden的中等精度计算方法实现
//////////////////////////////////////////////////////////////////////////////////////////////////// #include
#include
#define Pi 3.14159265
#define DE Pi/180
/////////////////////////////////////////////////////////////////
float jde(int Y,int M,int D,int hour,int min,int sec)
{
int f,g;
double mid1,mid2,J,JDE,A;
if(M>=3)
{
f=Y;
g=M;
}
if(M==1||M==2)
{
f=Y-1;
g=M+12;
};
mid1=floor(365.25*f);
mid2=floor(30.6001*(g+1));
A=2-floor(f/100)+floor(f/400);
J=mid1+mid2+D+A+1720994.5;
JDE=J+hour/24+min/1440+sec/86400;
return JDE;
}
/////////////////////////////////////变量声明///////////////////////////////
void main()
{ int i,year,month,day,hour,min,sec;
double d,w,a,e,M,oblecl,L,E,xe,ye,r,v,lon,x,y,z,xequt,yequt,zequt,dist,RA,Decl; // scanf(
///////////////////////////////测试数据//////////////////////////////////////////////////// year=1990;
month=4;
day=19;
hour=0;
min=0;
sec=0;
////////////////////////////////////////////轨道根数////////////////////////////////////// d=jde(year,month,day,hour,min,sec)-2451543.5;//相对儒略日;
w=282.9404+4.70935*0.00001*d;//升交点经度
a=1;
e=0.016709-1.151*0.000000001*d;//偏心率
M = 356.0470 + 0.9856002585 * d;//平近点角
oblecl = 23.4393-3.563*0.0000001 * d;//黄赤交角
//////////////////////////////////////////////////////////////////////////////////////////// L=w+M;//太阳的平均精度
L=fmod(L,360);
E=M + (180/Pi) * e * sin(M*DE) * (1 + e * cos(M*DE));//(开普勒方程的近似解) E=fmod(E,360);
xe=cos(E*DE) - e;//椭圆轨道上的直角坐标x
ye=sin(E*DE) * sqrt(1 - e*e);//椭圆轨道上的直角坐标y
r=sqrt(xe*xe+ye*ye);//距离
v=atan2(ye,xe)*180/Pi;//真近点角
//lon=fmod((v+w),360);//太阳的精度
//太阳的黄道直角坐标
lon=v+w;
x=r*cos(lon*Pi/180);
y=r*sin(lon*Pi/180);
z=0;
//太阳的赤道直角坐标
xequt=x;
yequt=y*cos(oblecl*Pi/180);
zequt = y* sin(oblecl*Pi/180);
//日地距离、赤经赤纬
dist=sqrt(xequt*xequt+yequt*yequt);
RA=atan2(yequt,xequt)*180/Pi;
RA=fmod(RA,360);
Decl=asin(zequt/r)*180/Pi;
Decl=fmod(Decl,360);
//////////////////////////////////////////////////////////////////// printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
}
