OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
GEO_vec_unit3.c
Go to the documentation of this file.
1 /* file: GEO_vec_unit3.c */
2 
3 #include <float.h>
4 #include "PGS_MODIS_35251.h"
5 #include "smfio.h"
6 #include "GEO_basic.h"
7 #include "GEO_util.h"
8 
10  double vec[3],
11  double unit_vec[3]
12  )
13 /*
14 !C*****************************************************************************
15 !Description: subroutine in the utility functions of the Level-1A geolocation
16  software to calculate the unit vector of a 3 element vector.
17 
18 !Input Parameters:
19  double vec[3] - the input 3-vector
20 
21 !Output Parameters:
22  double unit_vec[3] - the unit vector from the input 3-vector
23 
24 Call functions: modsmf(MODIS_X_MNEMONIC_STRING, "user message string", "function,
25  GEO_vec_unit3.c") - writes error status messages to log
26 
27 !Revision History:
28  $Log: GEO_vec_unit3.c,v $
29  Revision 1.6 1997/07/21 16:24:34 kuyper
30  Baselined Version 1
31 
32  * Revision 1.6 1997/03/26 18:17:18 fhliang
33  * Initial revision of SDST delivery of GEO_vec_unit3.c.
34  *
35  Revision 1.5 1997/03/10 17:30:41 kuyper
36  Changed to inequality test on vec_length.
37 
38  Revision 1.4 1997/02/13 19:59:52 kuyper
39  Merged seed files
40  Added RCS Log keyword.
41 
42  James Kuyper Jr. (kuyper@ltpmail.gsfc.nasa.gov)
43 
44  6/30/95
45  Tracey W. Holmes (holmes@modis-xl.gfsc.nasa.gov)
46  Added SDP error messages.
47 
48  6/12/95
49  Frederick S. Patt (patt@modis-xl.gsfc.nasa.gov)
50  Revised prolog.
51 
52  4/5/95
53  Ruiming Chen (rchen@ltpmail.gsfc.nasa.gov)
54  Finished coding.
55 
56 !Team-unique Header:
57  This software is developed by the MODIS Science Data Support
58  Team for the National Aeronautics and Space Administration,
59  Goddard Space Flight Center, under contract NAS5-32373.
60 
61 !END*************************************************************************
62 */
63 {
64  double vec_length = 0.0; /* vector length */
65  int i = 0; /* iteration parameter */
66 
67  GEO_vec_length3(vec, &vec_length);
68  if (vec_length < DBL_MIN) {
69  /* write to SDP event message */
70  modsmf(MODIS_E_UTIL_VEC, "", "GEO_vec_unit3, GEO_vec_unit3");
71 
72  return FAIL;
73  }
74 
75  for (i = 0; i < 3; ++i)
76  unit_vec[i] = vec[i] / vec_length;
77 
78  return SUCCESS;
79 }
#define SUCCESS
Definition: ObpgReadGrid.h:15
#define FAIL
Definition: ObpgReadGrid.h:18
#define MODIS_E_UTIL_VEC
void GEO_vec_length3(double vec[3], double *const length)
int i
Definition: decode_rs.h:71
int GEO_vec_unit3(double vec[3], double unit_vec[3])
Definition: GEO_vec_unit3.c:9