OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
ias_math_interpolate_lagrange_3dvec.c
Go to the documentation of this file.
1 /*****************************************************************************
2 NAME: ias_math_interpolate_lagrange_3dvec
3 
4 PURPOSE:
5  Perform lagrange interpolation on a vector.
6 
7 RETURN VALUE: None
8 
9 RETURN PARAMETERS:
10  output:
11  Type = IAS_VECTOR*
12 *****************************************************************************/
13 #include "ias_math.h"
14 
16 (
17  const IAS_VECTOR *p_YY, /* I: Y-axis or values to be interpolated */
18  const double *p_XX, /* I: X-axis of value to be interpolated */
19  int num_points, /* I: Number of points to use in the interpolation */
20  double in_time, /* I: X-value for which Y value is to be calculated */
21  IAS_VECTOR *output /* O: Output result */
22 )
23 {
24  double term_x, term_y, term_z;
25  double sum_x, sum_y, sum_z;
26  double s;
27  int i, j;
28 
29  sum_x = sum_y = sum_z = 0.0;
30  for (i = 0; i < num_points; i++)
31  {
32  term_x = p_YY[i].x;
33  term_y = p_YY[i].y;
34  term_z = p_YY[i].z;
35 
36  for (j = 0; j < num_points; j++)
37  {
38  if (j != i)
39  {
40  s = ( in_time - p_XX[j]) / ( p_XX[i] - p_XX[j] );
41 
42  term_x = term_x * s;
43  term_y = term_y * s;
44  term_z = term_z * s;
45  }
46  }
47 
48  sum_x = sum_x + term_x;
49  sum_y = sum_y + term_y;
50  sum_z = sum_z + term_z;
51  }
52 
53  output->x = sum_x;
54  output->y = sum_y;
55  output->z = sum_z;
56 }
57 
int j
Definition: decode_rs.h:73
u5 which has been done in the LOCALGRANULEID metadata should have an extension NRT It is requested to identify the NRT production Changes from v6 which may affect scientific output
Definition: HISTORY.txt:186
data_t s[NROOTS]
Definition: decode_rs.h:75
void ias_math_interpolate_lagrange_3dvec(const IAS_VECTOR *p_YY, const double *p_XX, int num_points, double in_time, IAS_VECTOR *output)
int i
Definition: decode_rs.h:71