OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
ias_geo_find_deg.c
Go to the documentation of this file.
1 /****************************************************************************
2 NAME: ias_geo_find_deg
3 
4 PURPOSE: Extracts deg portions of an angle.
5 
6 RETURNS: void
7 
8 ALGORITHM DESCRIPTION:
9  Extract degree portion of angle
10  Return
11 
12 *****************************************************************************/
13 #include <math.h>
14 #include "ias_geo.h"
15 
16 void ias_geo_find_deg
17 (
18  double angle, /* I: Angle in total degrees */
19  int *degree /* O: Degree portion of the angle */
20 )
21 {
22  int sign; /* Sign of angle */
23  int minute; /* Minutes portion of angle */
24  double sec; /* Seconds portion of angle */
25 
26  *degree = (int) angle;
27  sign = 1;
28  if (*degree < 0)
29  sign = -1;
30  *degree = (int) fabs (angle);
31  minute = (int) ((fabs (angle) - *degree) * 60.0);
32  sec = (((fabs (angle) - *degree) * 60.0) - minute) * 60.0;
33  if (sec >= 60.0)
34  minute++;
35  if (minute >= 60)
36  (*degree)++;
37  *degree *= sign;
38 }
int sign(double x)
Definition: proj_cproj.c:340
void ias_geo_find_deg(double angle, int *degree)
#define fabs(a)
Definition: misc.h:93