Esempio n. 1
0
static VALUE bodvrd(VALUE self, VALUE bodynm, VALUE item, VALUE maxn) {
  int dim, count;
  double * values = ALLOC_N(double, maxn); 
  VALUE rb_values = rb_ary_new();

  bodvrd_c(RB_SYM2STR(bodynm), RB_SYM2STR(item), FIX2INT(maxn), &dim, values);
  
  for(count = 0 ; count < dim ; count++) {
    rb_ary_push(rb_values, DBL2NUM(values[count]));
  }
  
  xfree(values);

  return rb_ary_new3(2, INT2FIX(dim), rb_values);
}
Esempio n. 2
0
double bc_elev(double lat, double lon, double et, char *target) {

  double pos[3], radii[3], normal[3], state[6], lt;
  int n;

  // the Earth's 3 radii
  bodvrd_c ("EARTH", "RADII", 3, &n, radii);

  double flat = (radii[2]-radii[0])/radii[0];

  // rectangular coordinates of position (ITRF93)
  georec_c (lon, lat, 0, radii[0], flat, pos);

  // surface normal vector to ellipsoid at latitude/longitude (this is
  // NOT the same as pos!)
  surfnm_c(radii[0], radii[1], radii[2], pos, normal);

  //  printf("POS: %f %f %f\n", pos[0], pos[1], pos[2]);
  //  printf("NORMAL: %f %f %f\n", normal[0], normal[1], normal[2]);

  //  printf("ET = %f\n", et);
  //  printf("POS: %f %f %f\n", pos[0], pos[1], pos[2]);

  // position of Sun in ITRF93
  spkcpo_c("Sun", et, "ITRF93", "OBSERVER", "CN+S", pos, "Earth", "ITRF93", state,  &lt);

  //  printf("STATE: %f %f %f\n", state[0], state[1], state[2]);

  double el = halfpi_c() - vsep_c(state,  normal); 

  //  printf("DEBUG: %f,%f,%f,%f,%f\n", lat, lon, 0., el, et);

  //  return halfpi_c() - vsep_c(normal,  state);
  return el;

}