您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 资本运营 > 太阳角度计算c语言程序
******************************************************************************************************************/#includemain.h#includecracker.h#includemath.h/***************************************************************************************************************------------------------------------------------------------------------------------------------------------------------**Functionname:leap**Descriptions:判断当年是否为闰年**inputparameters:pTime--日期时间**outputparameters:leap(闰年返回1,平年返回0)**------------------------------------------------------------------------------------------------------------------------************************************************************************************************************/intleap(PCF8563_Time*pTime){intleap;leap=(pTime-Year%4==0&&pTime-Year%100!=0)||(pTime-Year%400==0);returnleap;}/***************************************************************************************************************------------------------------------------------------------------------------------------------------------------------**Functionname::DayAddCalculate**Descriptions:计算当天为一年中的第几天**inputparameters:pTime--日期时间**outputparameters:DayAdd----积日**------------------------------------------------------------------------------------------------------------------------*****************************/INT32UDayAddCalculate(PCF8563_Time*pTime){INT32UDayAdd;switch(pTime-Month){case1:DayAdd=(pTime-Day);break;case2:DayAdd=31+pTime-Day;break;case3:DayAdd=31+28+pTime-Day;break;case4:DayAdd=31+28+31+pTime-Day;break;case5:DayAdd=31+28+31+30+pTime-Day;break;case6:DayAdd=31+28+31+30+31+pTime-Day;break;case7:DayAdd=31+28+31+30+31+30+pTime-Day;break;case8:DayAdd=31+28+31+30+31+30+31+pTime-Day;break;case9:DayAdd=31+28+31+30+31+30+31+31+pTime-Day;break;case10:DayAdd=31+28+31+30+31+30+31+31+30+pTime-Day;break;case11:DayAdd=31+28+31+30+31+30+31+31+30+31+pTime-Day;break;case12:DayAdd=31+28+31+30+31+30+31+31+30+31+30+pTime-Day;break;default:break;/*cout月份输入错误!*/}if(leap(pTime)&&(pTime-Month=3))DayAdd=DayAdd+1;returnDayAdd;}/***************************************************************************************************************------------------------------------------------------------------------------------------------------------------------**Functionname::DecAngleCalculate**Descriptions:计算太阳的赤纬角**inputparameters:pTime--日期时间**outputparameters:赤纬角DecAngle**------------------------------------------------------------------------------------------------------------------------*****************************/FP64DecAngleCalculate(PCF8563_Time*pTime){INT32UDayAdd;DayAdd=DayAddCalculate(pTime);return(23.45*sin(2*PI*(284+DayAdd)/365))*PI/180;}/***************************************************************************************************************------------------------------------------------------------------------------------------------------------------------**Functionname::HourAngleCalculate**Descriptions:计算当前时角**inputparameters:pTime--日期时间**outputparameters:HourAngle*****************************/FP64HourAngleCalculate(PCF8563_Time*pTime){return(12-(pTime-Hour)-(pTime-Minute)/60.0-(pTime-Second)/3600.0)*PI/12;}///***************************************************************************************************************------------------------------------------------------------------------------------------------------------------------**Functionname::EleAngleCalculate**Descriptions:计算当前太阳的高度角**inputparameters:pTime--日期时间**outputparameters:EleAngle**------------------------------------------------------------------------------------------------------------------------*****************************/FP64EleAngleCalculate(PCF8563_Time*pTime){FP64DecAngle;FP64HourAngle;DecAngle=DecAngleCalculate(pTime);HourAngle=HourAngleCalculate(pTime);returnasin(sin(LAT)*sin(DecAngle)+cos(LAT)*cos(DecAngle)*cos(HourAngle));}/***************************************************************************************************************------------------------------------------------------------------------------------------------------------------------**Functionname::AziAngleCalculate**Descriptions:计算当前太阳的方位角**inputparameters:pTime--日期时间**outputparameters:AziAngle**------------------------------------------------------------------------------------------------------------------------FP64AziAngleCalculate(PCF8563_Time*pTime){FP64DecAngle;FP64EleAngle;DecAngle=DecAngleCalculate(pTime);EleAngle=EleAngleCalculate(pTime);if(pTime-Hour12)returnacos((sin(EleAngle)*sin(LAT)-sin(DecAngle))/(cos(EleAngle)*cos(LAT)));elsereturn-acos((sin(EleAngle)*sin(LAT)-sin(DecAngle))/(cos(EleAngle)*cos(LAT)));//returnasin(cos(DecAngle)*sin(LAT)/cos(EleAngle));}
本文标题:太阳角度计算c语言程序
链接地址:https://www.777doc.com/doc-5285210 .html