问下关于这个求太阳高度角和方位角的程序 150
#include<iostream>#include<math.h>usingnamespacestd;#definePI3.14159265358979unsigned...
#include<iostream>
#include<math.h>
using namespace std;
#define PI 3.14159265358979
unsigned int n_ca(unsigned int a,unsigned int b);
double delt_sun_ca(double a);
double et_ca(double a);
double angle_hour_ca(unsigned int h,unsigned int m,double e);
int main()
{
unsigned int y,m,d;
unsigned int hour,minute;
cout<<"输入当前年月日:"<<endl;
cin>>y>>m>>d;
cout<<"输入当前时分:"<<endl;
cin>>hour>>minute;
double LONG,LAT;
cout<<"输入当地经度LONG与当地纬度LAT:"<<endl;
cin>>LONG>>LAT;
LONG=LONG*PI/180;
LAT=LAT*PI/180;
cout<<"输入的经度纬度分别为:"<<LONG<<"rad,"<<LAT<<"rad\n";
double delt_sun;
unsigned int n;
n=n_ca(m,d);
cout<<"现在是一年中的第"<<n<<"天。\n";
delt_sun=delt_sun_ca(n);
delt_sun=delt_sun*PI/180;
cout<<"当前的太阳赤纬为:"<<delt_sun<<"rad\n";
cout<<"转换成角度制太阳赤纬角为"<<(delt_sun*180/PI)<<"度\n";
double et,angle_hour;
et=et_ca(LONG);
angle_hour=angle_hour_ca(hour,minute,et);
cout<<"现在太阳的时角为"<<angle_hour<<"rad.\n";
double sin_h, h_sun,h_sun1;
sin_h=sin(LAT)*sin(delt_sun)+cos(LAT)*cos(delt_sun)*cos(angle_hour);
h_sun=asin(sin_h);
h_sun1=h_sun*180/PI;
cout<<"转换成当前太阳的高度角为:"<<h_sun1<<"度\n";
double cos_gam,gam_sun,gam_sun1;
cos_gam=(sin_h*sin(LAT)-sin(delt_sun))/(cos(h_sun)*cos(LAT));
gam_sun=acos(cos_gam);
gam_sun1=gam_sun*180/PI;
cout<<"当前太阳的方位角为:"<<gam_sun<<"rad,"<<gam_sun1<<" 度\n";
system("pause");
}
unsigned int n_ca(unsigned int a,unsigned int b)
{
int n=0;
switch(a)
{
case 1:
n=b;break;
case 2:
n=31+b;break;
case 3:
n=31+28+b;break;
case 4:
n=31+28+31+b;break;
case 5:
n=31+28+31+30+b;break;
case 6:
n=31+28+31+30+31+b;break;
case 7:
n=31+28+31+30+31+30+b;break;
case 8:
n=31+28+31+30+31+30+31+b;break;
case 9:
n=31+28+31+30+31+30+31+31+b;break;
case 10:
n=31+28+31+30+31+30+31+31+30+b;break;
case 11:
n=31+28+31+30+31+30+31+31+30+31+b;break;
case 12:
n=31+28+31+30+31+30+31+31+30+31+30+b;break;
default:
cout<<"月份输入错误!\n";
}
return n;
}
double delt_sun_ca(double a)
{
return 23.45*sin(360*(284+2*PI*a)/365);
}
double et_ca(double a)
{
return (120-a*180/PI)*4;
}
double angle_hour_ca(unsigned int h,unsigned int m,double e)
{
return (h+(m-e)/60-12)*15*PI/180;
}
以二分二至日为例,太阳高度角算的貌似没有问题,是先增后减的规律,但太阳方位角算的是递减的,而
别的论文上的图,方位角全是递增的,究竟怎么回事,麻烦大神帮忙看看太阳方位角的计算程序那一块究竟哪里有问题,为什么我算的是递减的角度。 展开
#include<math.h>
using namespace std;
#define PI 3.14159265358979
unsigned int n_ca(unsigned int a,unsigned int b);
double delt_sun_ca(double a);
double et_ca(double a);
double angle_hour_ca(unsigned int h,unsigned int m,double e);
int main()
{
unsigned int y,m,d;
unsigned int hour,minute;
cout<<"输入当前年月日:"<<endl;
cin>>y>>m>>d;
cout<<"输入当前时分:"<<endl;
cin>>hour>>minute;
double LONG,LAT;
cout<<"输入当地经度LONG与当地纬度LAT:"<<endl;
cin>>LONG>>LAT;
LONG=LONG*PI/180;
LAT=LAT*PI/180;
cout<<"输入的经度纬度分别为:"<<LONG<<"rad,"<<LAT<<"rad\n";
double delt_sun;
unsigned int n;
n=n_ca(m,d);
cout<<"现在是一年中的第"<<n<<"天。\n";
delt_sun=delt_sun_ca(n);
delt_sun=delt_sun*PI/180;
cout<<"当前的太阳赤纬为:"<<delt_sun<<"rad\n";
cout<<"转换成角度制太阳赤纬角为"<<(delt_sun*180/PI)<<"度\n";
double et,angle_hour;
et=et_ca(LONG);
angle_hour=angle_hour_ca(hour,minute,et);
cout<<"现在太阳的时角为"<<angle_hour<<"rad.\n";
double sin_h, h_sun,h_sun1;
sin_h=sin(LAT)*sin(delt_sun)+cos(LAT)*cos(delt_sun)*cos(angle_hour);
h_sun=asin(sin_h);
h_sun1=h_sun*180/PI;
cout<<"转换成当前太阳的高度角为:"<<h_sun1<<"度\n";
double cos_gam,gam_sun,gam_sun1;
cos_gam=(sin_h*sin(LAT)-sin(delt_sun))/(cos(h_sun)*cos(LAT));
gam_sun=acos(cos_gam);
gam_sun1=gam_sun*180/PI;
cout<<"当前太阳的方位角为:"<<gam_sun<<"rad,"<<gam_sun1<<" 度\n";
system("pause");
}
unsigned int n_ca(unsigned int a,unsigned int b)
{
int n=0;
switch(a)
{
case 1:
n=b;break;
case 2:
n=31+b;break;
case 3:
n=31+28+b;break;
case 4:
n=31+28+31+b;break;
case 5:
n=31+28+31+30+b;break;
case 6:
n=31+28+31+30+31+b;break;
case 7:
n=31+28+31+30+31+30+b;break;
case 8:
n=31+28+31+30+31+30+31+b;break;
case 9:
n=31+28+31+30+31+30+31+31+b;break;
case 10:
n=31+28+31+30+31+30+31+31+30+b;break;
case 11:
n=31+28+31+30+31+30+31+31+30+31+b;break;
case 12:
n=31+28+31+30+31+30+31+31+30+31+30+b;break;
default:
cout<<"月份输入错误!\n";
}
return n;
}
double delt_sun_ca(double a)
{
return 23.45*sin(360*(284+2*PI*a)/365);
}
double et_ca(double a)
{
return (120-a*180/PI)*4;
}
double angle_hour_ca(unsigned int h,unsigned int m,double e)
{
return (h+(m-e)/60-12)*15*PI/180;
}
以二分二至日为例,太阳高度角算的貌似没有问题,是先增后减的规律,但太阳方位角算的是递减的,而
别的论文上的图,方位角全是递增的,究竟怎么回事,麻烦大神帮忙看看太阳方位角的计算程序那一块究竟哪里有问题,为什么我算的是递减的角度。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询