📄 surmath.cpp
字号:
// SurMath.cpp: implementation of the SurMath class.
#include "stdafx.h"
#include "SurMath.h"
#include <math.h>
//azimuth B->P的坐标方位角,单位为弧度
void Coordinate(SurPnt * pB, double azimuth, double dist, SurPnt * P)
{
P->x = pB->x + dist * cos(azimuth);
P->y = pB->y + dist * sin(azimuth);
}
//度分秒化成弧度
double DMStoRAD(int d, int m, float s)
{
return (d + m/60.0 + s/3600) / 180.0 * 3.1415926535897932384626433832795;
}
double Azimuth(SurPnt * A, SurPnt * B)
{
double dx = B->x - A->x;
double dy = B->y - A->y;
return atan2(dy, dx) + (dy < 0 ? 1 : 0) * _2PI;
}
double DMStoRAD(double dms)
{
int d, m, f; double s;
f = dms>=0 ? 1 : -1;
//0.001秒 = 4.8481368110953599358991410235795e-9弧度
dms += f * 0.0000001;
d = (int)dms;
dms = (dms - d) * 100.0;
m = (int)dms;
s = (dms - m) * 100.0;
return (d + m / 60.0 + s / 3600.0) * _TORAD
- f * 4.8481368110953599358991410235795e-9;
}
//方位角传递
double Azimuth(double az0, double Bi)
{
return az0 + Bi + _PI;
}
PPnt GetPnt(char * name, Pnt pnts[], int n)
{
for (int i=0; i<n; i++)
{
if( strcmp(pnts[i].name, name) == 0)
return &pnts[i];
}
return NULL;
}
double RADtoDMS(double rad)
{
int f = rad >= 0 ? 1 : -1; // 符号 + -
//加0.001秒(用弧度表示),化为度
rad = (rad + f * 4.8481368110953599358991410235795e-9) * _TODEG;
int d = (int)rad;
rad = (rad - d) * 60.0;
int m = (int)rad;
double s = (rad - m) * 60.0;
return d + m / 100.0 + s / 10000.0 - f * 0.0000001;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -