# Kstars

angconversion.h
1/*
2 SPDX-FileCopyrightText: 2011 Akarsh Simha <akarshsimha@gmail.com>
3
5*/
6
7#ifndef ANGCONVERSION_H
8#define ANGCONVERSION_H
9
10#include <math.h> /* For M_PI */
11
12/* Angle conversion macros */
13#define RADPERDEG (M_PI / 180.0) /* Number of radians in a degree */
14
15/* Basic conversions between Degrees, Hours and Radians */
17{
19}
21{
23}
24inline double hour2deg(double x)
25{
26 return (x * 15.0);
27}
28inline double deg2hour(double x)
29{
30 return (x / 15.0);
31}
33{
35}
37{
39}
40
41/* Convert degrees to arcminutes or arcseconds and back */
42inline double deg2arcsec(double x)
43{
44 return (x * 3600.0);
45}
46inline double arcsec2deg(double x)
47{
48 return (x / 3600.0);
49}
50inline double deg2arcmin(double x)
51{
52 return (x * 60.0);
53}
54inline double arcmin2deg(double x)
55{
56 return (x / 60.0);
57}
58
59/* The following are redundant, but anyway */
60inline double hour2sec(double x)
61{
62 return (x * 3600.0);
63}
64inline double sec2hour(double x)
65{
66 return (x / 3600.0);
67}
68inline double hour2min(double x)
69{
70 return (x * 60.0);
71}
72inline double min2hour(double x)
73{
74 return (x / 60.0);
75}
76
77/* Convert DMS / HMS to Degrees / Hours */
78inline double dms2deg(double d, double m, double s)
79{
80 return (d + m / 60.0 + s / 3600.0);
81}
82inline double hms2hour(double h, double m, double s)
83{
84 return (h + m / 60.0 + s / 3600.0);
85}
86
87void deg2dms(double D, int *d, int *m, float *s)
88{
89 *d = (int)D;
90 *m = (int)((D - *d) * 60);
91 *s = (int)((D - *d) * 3600 - (*m * 60));
92}
93
94void hour2hms(double H, int *h, int *m, float *s) /* Another redundant function */
95{
96 *h = (int)H;
97 *m = (int)((H - *h) * 60);
98 *s = (int)((H - *h) * 3600 - (*m * 60));
99}
100
101#endif
This file is part of the KDE documentation.