js.cpp

来自「This a calculation the local sun zenith 」· C++ 代码 · 共 37 行

CPP
37
字号
// js.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "stdio.h"
#include "math.h"

int main(int argc, char* argv[])
{	
	int N = 164;
	int N0=79.6764+0.2422*(2007-1985) -int((2007-1985)/4);
	int t = N-N0;
	float a = 2*3.1415926*t/365.2422;
	float ER=1.000423+0.032359*sin(a)+0.000086*sin(2*a)-0.008349*cos(a)+0.000115*cos(2*a);
	float ED=0.3723+23.2567*sin(a)+0.1149*sin(2*a)		
		-0.1712*sin(3*a)-0.758*cos(a)+0.3656*cos(2*a)		
		+0.0201*cos(3*a);
	float Et=0.0028-1.9857*sin(a)+ 9.9059*sin(2*a)-7.0924*cos(a)-0.6882*cos(2*a);
	float s =11,F=54;
	float JD = 128,JF = 28;
	float sd1= (F-(120-(JD+JF/60))*4)/60;
	float Sf = sd1+Et/60;	
	float Shj = -(s + Sf/60 - 12)*15;
	float Zenith =  asin(sin(ED)*sin((42+24/60)*3.1415926/360)+cos(ED)*cos((42+24/60)*3.1415926/360)*cos(Shj));
	//Zenith = Zenith * 360/3.1415926;
	float A = acos((sin(Zenith)*sin((42+24/60)*3.1415926/360)-sin(ED))/cos(Zenith)*cos((42+24/60)*3.1415926/360));
	A = A * 360/3.1415926;
	printf("%f\n%f\n%f\n%f\n",a,ER,ED,Et);
	printf("%f:%f\n",s,sd1);
	printf("%f:%f\n",s,Sf);
	printf("%f\n",Shj);
	printf("%f\n",360/3.1415926);
	printf("Sun Azimuth Angle:");
	printf("%f\n",A);
	return 0;	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?