This repository has been archived on 2026-10-26. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
KNZ_GeoTrackLab/deg2dms.h
T
KenanZhu111 c44c1df50f Adding and modify many useful function
in their header file:
-blh2enu.h
-xyz2blh.h
-rahcal.h
-deg2dms.h
-degRrad.h
2024-09-21 11:38:30 +08:00

34 lines
982 B
C

#ifndef _DEG2DMS_H_
#define _DEG2DMS_H_
#include<stdlib.h>
#include<math.h>
typedef struct
{
double D;
double M;
double S;
}deg2dms, *pdeg2dms;
/* -------------------------------------------------------------------------- */
/// @brief 将十进制的度数转换为度分秒形式
/// @param deg2dms 结构体传递参数
/// @param D 要转换度数
/// @return 返回自定义结构体包含度,分,秒成员
/* -------------------------------------------------------------------------- */
pdeg2dms DEG2DMS(pdeg2dms deg2dms,
double D)
{
deg2dms = (pdeg2dms)malloc(sizeof(pdeg2dms));
int sig = D / fabs(D);//符号判断
deg2dms->D = (int)(D);//转换为度分秒
deg2dms->M = (int)((D - deg2dms->D) * 60);//分秒去除符号格式
deg2dms->S = (int)(((D - deg2dms->D) * 60 - deg2dms->M) * 60);
deg2dms->M = deg2dms->M * sig;
deg2dms->S = deg2dms->S * sig;
return deg2dms;
}
#endif