COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
jpleph.cpp File Reference
#include "support/configCosmos.h"
#include <stdio.h>
#include <cmath>
#include <cstring>
#include <stdlib.h>
#include "support/jpleph.h"
Include dependency graph for jpleph.cpp:

Macros

#define TRUE   1
 
#define FALSE   0
 
#define KM   1
 
#define SWAP_MACRO(A, B, TEMP)   { TEMP = A; A = B; B = TEMP; }
 

Functions

double DLL_FUNC jpl_get_double (const void *ephem, const int value)
 
double DLL_FUNC jpl_get_long (const void *ephem, const int value)
 
int DLL_FUNC jpl_pleph (void *ephem, const double et, const int ntarg, const int ncent, double rrd[], const int calc_velocity)
 
static void interp (struct interpolation_info *iinfo, const double coef[], const double t[2], const int ncf, const int ncm, const int na, const int ifl, double posvel[])
 
static void swap_long_integer (void *ptr)
 
static void swap_double (void *ptr, long count)
 
int DLL_FUNC jpl_state (void *ephem, const double et, const int list[12], double pv[][6], double nut[4], const int bary)
 
void *DLL_FUNC jpl_init_ephemeris (const char *ephemeris_filename, char nam[][6], double *val)
 
void DLL_FUNC jpl_close_ephemeris (void *ephem)
 

Macro Definition Documentation

#define TRUE   1
#define FALSE   0
#define KM   1
#define SWAP_MACRO (   A,
  B,
  TEMP 
)    { TEMP = A; A = B; B = TEMP; }

Function Documentation

static void interp ( struct interpolation_info iinfo,
const double  coef[],
const double  t[2],
const int  ncf,
const int  ncm,
const int  na,
const int  ifl,
double  posvel[] 
)
static
277 {
278  double dna, dt1, temp, tc, vfac, temp1;
279  int l, i, j;
280 
281  /* entry point. get correct sub-interval number for this set
282  of coefficients and then get normalized chebyshev time
283  within that subinterval. */
284 
285  dna = (double)na;
286  modf( t[0], &dt1);
287  temp = dna * t[0];
288  l = (int)(temp - dt1);
289 
290  /* tc is the normalized chebyshev time (-1 <= tc <= 1) */
291 
292  tc = 2.0 * (modf( temp, &temp1) + dt1) - 1.0;
293 
294  /* check to see whether chebyshev time has changed,
295  and compute new polynomial values if it has.
296  (the element iinfo->pc[1] is the value of t1[tc] and hence
297  contains the value of tc on the previous call.) */
298 
299  if(tc != iinfo->pc[1])
300  {
301  iinfo->np = 2;
302  iinfo->nv = 3;
303  iinfo->pc[1] = tc;
304  iinfo->twot = tc+tc;
305  }
306 
307  /* be sure that at least 'ncf' polynomials have been evaluated
308  and are stored in the array 'iinfo->pc'. */
309 
310  if(iinfo->np < ncf)
311  {
312  double *pc_ptr = iinfo->pc + iinfo->np;
313 
314  for(i=ncf - iinfo->np; i; i--, pc_ptr++)
315  {
316  if (i<0 || i>ncf)
317  {
318  i = 0;
319  break;
320  }
321  *pc_ptr = iinfo->twot * pc_ptr[-1] - pc_ptr[-2];
322  }
323  iinfo->np=ncf;
324  }
325 
326  /* interpolate to get position for each component */
327 
328  for( i = 0; i < ncm; ++i) /* ncm is a number of coordinates */
329  {
330  const double *coeff_ptr = coef + ncf * (i + l * ncm + 1);
331  const double *pc_ptr = iinfo->pc + ncf;
332 
333  posvel[i]=0.0;
334  for( j = ncf; j; j--)
335  posvel[i] += (*--pc_ptr) * (*--coeff_ptr);
336  }
337 
338  if(ifl <= 1) return;
339 
340  /* if velocity interpolation is wanted, be sure enough
341  derivative polynomials have been generated and stored. */
342 
343  vfac=(dna+dna)/t[1];
344  iinfo->vc[2] = iinfo->twot + iinfo->twot;
345  if( iinfo->nv < ncf)
346  {
347  double *vc_ptr = iinfo->vc + iinfo->nv;
348  const double *pc_ptr = iinfo->pc + iinfo->nv - 1;
349 
350  for( i = ncf - iinfo->nv; i; i--, vc_ptr++, pc_ptr++)
351  {
352  if (i<0 || i>ncf)
353  {
354  i = 0;
355  break;
356  }
357  *vc_ptr = iinfo->twot * vc_ptr[-1] + *pc_ptr + *pc_ptr - vc_ptr[-2];
358  }
359  iinfo->nv = ncf;
360  }
361 
362  /* interpolate to get velocity for each component */
363 
364  for( i = 0; i < ncm; ++i)
365  {
366  double tval = 0.;
367  const double *coeff_ptr = coef + ncf * (i + l * ncm + 1);
368  const double *vc_ptr = iinfo->vc + ncf;
369 
370  for( j = ncf; j; j--)
371  tval += (*--vc_ptr) * (*--coeff_ptr);
372  posvel[ i + ncm] = tval * vfac;
373  }
374  return;
375 }
int np
Definition: jpleph.h:149
int i
Definition: rw_test.cpp:37
double pc[18]
Definition: jpleph.h:148
static double coef[360+1][360+1][2]
Definition: physicslib.cpp:39
int nv
Definition: jpleph.h:149
double twot
Definition: jpleph.h:148
double vc[18]
Definition: jpleph.h:148
static void swap_long_integer ( void *  ptr)
static
386 {
387  char *tptr = (char *)ptr, tchar;
388 
389  SWAP_MACRO( tptr[0], tptr[3], tchar);
390  SWAP_MACRO( tptr[1], tptr[2], tchar);
391 }
#define SWAP_MACRO(A, B, TEMP)
Definition: jpleph.cpp:383
static void swap_double ( void *  ptr,
long  count 
)
static
394 {
395  char *tptr = (char *)ptr, tchar;
396 
397  while( count--)
398  {
399  SWAP_MACRO( tptr[0], tptr[7], tchar);
400  SWAP_MACRO( tptr[1], tptr[6], tchar);
401  SWAP_MACRO( tptr[2], tptr[5], tchar);
402  SWAP_MACRO( tptr[3], tptr[4], tchar);
403  tptr += 8;
404  }
405 }
int count
Definition: rw_test.cpp:36
#define SWAP_MACRO(A, B, TEMP)
Definition: jpleph.cpp:383