angle.h

来自「用 c++编写的GPS水准拟合的程序」· C头文件 代码 · 共 32 行

H
32
字号
#include "math.h"
#include "iostream.h"
#define PI 3.141592653589793
#include "iomanip.h"

double dtor(double a)//the angle from degree、minitue and second to radian 
{
	double r=0.0;
	int d=0,m=0;double s=0.0;
	a=a*10000.0;
	d=(int)(a/10000);//cout<<"d="<<d<<endl;
	m=(int)((a-d*10000.0)/100.0);
	if(m>=60)  cout<<"input error!\n";//cout<<"m="<<m<<endl;
    s=a-d*10000.0-m*100.0;
	if(s>=60)  cout<<"input error!\n";//cout<<"s="<<s<<endl;
	r=d+m/60.0+s/3600.0; //cout<<"it is"<<r<<" degree"<<endl;
	r=r*PI/180.0;
	return r;
}

double rtod(double r)//the angle from radia to degree、minitue and second
{
	double a=r*180.0/PI,s=0.0,s0=0.0;
	int d=0,m=0;
	s0=a*3600.0;
	d=int(s0/3600.0);//cout<<"\n d=" <<d<<endl;
	m=(int)((s0-d*3600)/60.0);//cout<<"\n m=" <<m<<endl;
	s=s0-d*3600-m*60.0;//cout<<"\n s=" <<s<<endl;
	double g=d+m/100.0+s/10000.0;
	return g;
}

⌨️ 快捷键说明

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