Module: Spice

Defined in:
lib/spice_utils.rb,
lib/spice/version.rb,
ext/spice.c,
ext/spice.c

Overview

This is the heart of ruby_spice.

All of the function wrappers take place here.

Constant Summary

VERSION =

naif-spice rubygem version

"2.21"

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (nil, Fixnum) bodn2c(name)

Translate the name of a body or object to the corresponding SPICE integer ID code.

Parameters:

  • name (String)

    the name of a body or object, such as a planet, satellite, comet, asteroid, barycenter, DSN station, spacecraft, or instrument, that is "known" to the SPICE system, whether through hard-coded registration or run-time registration in the SPICE kernel pool. Case and leading and trailing blanks in `name' are not significant. However when a name is made up of more than one word, they must be separated by at least one blank.

    That is, all of the following strings are equivalent names:

    "JUPITER BARYCENTER"
    "Jupiter Barycenter"
    "JUPITER BARYCENTER   "
    "JUPITER    BARYCENTER"
    "   JUPITER BARYCENTER"

    However, "JUPITERBARYCENTER" is not equivalent to the names above.

Returns:

  • (nil)

    IF no code is found

  • (Fixnum)

    IF a code is found

See Also:



743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
# File 'ext/spice.c', line 743

VALUE bodn2c(int argc, VALUE *argv, VALUE self) {
  SpiceBoolean found;
  SpiceInt code;

  if (argc != 1) {
    rb_raise(rb_eArgError, "need just one arg please!");
    return Qnil;
  }

  Check_Type(argv[0], T_STRING);

  bodn2c_c(StringValuePtr(argv[0]), &code, &found);

  if (found == SPICEFALSE)
    return Qnil;
  
  check_spice_error();

  return INT2FIX(code);
}

+ (Array<Float>) bodvcd(bodyid, item)

Fetch from the kernel pool the double precision values of an item associated with a body, where the body is specified by an integer ID code.

Parameters:

  • bodyid (Fixnum)

    Body ID code.

  • item (String)

    Item for which values are desired. ("RADII","NUT_PREC_ANGLES", etc. )

Returns:

  • (Array<Float>)

    a ruby array containing the values

See Also:



1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
# File 'ext/spice.c', line 1754

VALUE bodvcd(VALUE self, VALUE bodyid, VALUE item) {
  double values[32];
  SpiceInt vret, i;
  VALUE rb_values;

  Check_Type(bodyid, T_FIXNUM);
  Check_Type(item, T_STRING);

  bodvcd_c(NUM2INT(bodyid), StringValuePtr(item), 32, &vret, values);

  rb_values = rb_ary_new2(vret);
  for (i=0; i<vret; i++)
    rb_ary_push(rb_values, rb_float_new(values[i]));

  check_spice_error();

  return rb_values;
}

+ (nil, Array) ckgp(inst, sclkdp, tol, ref)

Get pointing (attitude) for a specified spacecraft clock time.

Parameters:

  • inst (Fixnum)

    NAIF ID of instrument, spacecraft, or structure.

  • sclkdp (Float)

    Encoded spacecraft clock time.

  • tol (Float)

    Time tolerance.

  • ref (String)

    Reference frame.

Returns:

  • (nil)

    if no pointing information was found, otherwise:

  • (Array)

    A ruby array containing the c-matrix as it's first element and the sclk time as the second

See Also:



2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
# File 'ext/spice.c', line 2085

VALUE ckgp(VALUE self, VALUE inst, VALUE sclkdp, VALUE tol, VALUE ref) {
  double cmat[3][3];
  double slkout;
  SpiceBoolean found;

  Check_Type(inst, T_FIXNUM);
  Check_Type(sclkdp, T_FLOAT);
  Check_Type(tol, T_FLOAT);
  Check_Type(ref, T_STRING);

  ckgp_c(NUM2INT(inst), NUM2DBL(sclkdp), NUM2DBL(tol), StringValuePtr(ref), cmat, &slkout, &found);

  if (found == SPICEFALSE) {
    rb_raise(rb_eRuntimeError, "Pointing info not found for this sc time");
    return Qnil;
  }

  check_spice_error();

  return rb_ary_new3(2, rb_ary_new3(3, rb_ary_new3(3, rb_float_new(cmat[0][0]), rb_float_new(cmat[0][1]), rb_float_new(cmat[0][2])), rb_ary_new3(3, rb_float_new(cmat[1][0]), rb_float_new(cmat[1][1]), rb_float_new(cmat[1][2])), rb_ary_new3(3, rb_float_new(cmat[2][0]), rb_float_new(cmat[2][1]), rb_float_new(cmat[2][2]))), rb_float_new(slkout));
}

+ (Float) dpr

Return the number of degrees per radian.

Examples:

angleDEG = angleRAD*dpr()

Parameters:

  • NONE

Returns:

  • (Float)

    180.0/acos(-1)

See Also:



337
338
339
340
341
342
343
344
# File 'ext/spice.c', line 337

VALUE dpr(int argc, VALUE *argv, VALUE self) {
  if (argc != 0) {
    rb_raise(rb_eArgError, "no args, go away!");
    return Qnil;
  }

  return rb_float_new(dpr_c());
}

+ (Array<(Fixnum, Fixnum, Fixnum, String, String)>) et2lst(et, body, lon, type)

Given an ephemeris epoch, compute the local solar time for an object on the surface of a body at a specified longitude.

Parameters:

  • et (Float)

    Epoch expressed in TBD seconds past the J2000 epoch at which a local time is desired.

  • body (Fixnum)

    The NAIF ID-code of a body on which local time is to be measured.

  • lon (Float)

    The longitude (either planetocentric or planetographic) in radians of the site on the surface of body for which local time should be computed..

  • type (String)

    The form of longitude supplied by the variable lon. Allowed values are "PLANETOCENTRIC" and "PLANETOGRAPHIC". Note the case of the letters in type is insignificant. Both "PLANETOCENTRIC" and "planetocentric" are recognized. Leading and trailing blanks in type are not significant.

Returns:

  • (Array<(Fixnum, Fixnum, Fixnum, String, String)>)

    A Ruby array [hr, mn, sc, time, ampm]

  • hr = Local hour on a "24 hour" clock.

  • mn = Minutes past the hour.

  • sc = Seconds past the minute.

  • time = String giving local time on 24 hour clock.

  • ampm = String giving time on A.M./ P.M. scale.

See Also:

Since:

  • 2.14



381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'ext/spice.c', line 381

VALUE et2lst(int argc, VALUE *argv, VALUE self) {
  VALUE result = Qnil;
  SpiceInt timlen=32, ampmlen=32;
  SpiceInt hr, mn, sc;
  SpiceChar time[timlen], ampm[ampmlen];

  if (argc != 4) {
    rb_raise(rb_eArgError, "need 4 parameters!");
    return Qnil;
  }

  Check_Type(argv[0], T_FLOAT);  // et
  Check_Type(argv[1], T_FIXNUM); // body ID-code
  Check_Type(argv[2], T_FLOAT);  // lon
  Check_Type(argv[3], T_STRING); // type

  et2lst_c(NUM2DBL(argv[0]), FIX2INT(argv[1]), NUM2DBL(argv[2]), StringValuePtr(argv[3]), timlen, ampmlen, &hr, &mn, &sc, time, ampm);

  result = rb_ary_new();
  rb_ary_push(result, INT2FIX(hr));
  rb_ary_push(result, INT2FIX(mn));
  rb_ary_push(result, INT2FIX(sc));
  rb_ary_push(result, rb_str_new2(time));
  rb_ary_push(result, rb_str_new2(ampm));

  check_spice_error();

  return result;
}

+ (DateTime) et2rb(et)

Converts et into a ruby DateTime object

Parameters:

  • et (Float)

    a time value in et

Returns:

  • (DateTime)

    A ruby DateTime object



771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
# File 'ext/spice.c', line 771

VALUE et2rb(VALUE self, VALUE arg) {
  double et;
  char time_str[64];
  char tmpstr[1000];
  VALUE datetime;

  et = NUM2DBL(arg);

  et2utc_c(et, "ISOC", 3, 64, time_str);

  rb_eval_string("require 'date'");
  sprintf(tmpstr, "dt = DateTime.parse(\"%s\"); Time.utc(dt.year, dt.month, dt.day, dt.hour, dt.min, dt.sec, (dt.sec_fraction*(RUBY_VERSION =~ /^1\\.8\\./ ? 24*60*60 : 1)*1000000).to_i)", time_str);
  datetime = rb_eval_string(tmpstr);

  check_spice_error();

  return datetime;
}

+ (Array<Array, Array, Array>) eul2m(angle3, angle2, angle1, axis3, axis2, axis1)

Construct a rotation matrix from a set of Euler angles.

Parameters:

  • angle3 (Float)

    (IN RADIANS!)

  • angle2 (Float)

    (IN RADIANS!)

  • angle1 (Float)

    (IN RADIANS!)

  • axis3 (Fixnum)

    Axis number of the third rotation axes.

  • axis2 (Fixnum)

    Axis number of the second rotation axes.

  • axis1 (Fixnum)

    Axis number of the first rotation axes.

Returns:

  • (Array<Array, Array, Array>)

    A 3X3 ruby array representing the product of the 3 rotations.

See Also:



463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# File 'ext/spice.c', line 463

VALUE eul2m(int argc, VALUE *argv, VALUE self){
	double angle1, angle2, angle3;
	int axis1, axis2, axis3;
	int i;
	double r[3][3];

	if (argc != 6){
		rb_raise(rb_eArgError, "Need 6 Parameters!");
		return Qnil;
	}
	for( i = 0; i < 3; i++)
		Check_Type(argv[i], T_FLOAT);
	for( i = 3; i < 6; i++)
		Check_Type(argv[i], T_FIXNUM);

	angle3 = NUM2DBL(argv[0]);
	angle2 = NUM2DBL(argv[1]);
	angle1 = NUM2DBL(argv[2]);
	axis3  = FIX2INT(argv[3]);
	axis2  = FIX2INT(argv[4]);
	axis1  = FIX2INT(argv[5]);

	eul2m_c(angle3, angle2,  angle1, axis3, axis2, axis1, r);

	check_spice_error();

	return rb_ary_new3(3, rb_ary_new3(3, rb_float_new(r[0][0]), rb_float_new(r[0][1]), rb_float_new(r[0][2])),  rb_ary_new3(3, rb_float_new(r[1][0]), rb_float_new(r[1][1]), rb_float_new(r[1][2])), rb_ary_new3(3, rb_float_new(r[2][0]), rb_float_new(r[2][1]), rb_float_new(r[2][2])));

}

+ (Fixnum) furnsh(file, file...)

Load one or more SPICE kernels into a program.

Parameters:

  • file (String)

    Path to a Spice Kernel, can be a single kernel of .mk file

Returns:

  • (Fixnum)

    the number of kernels loaded

See Also:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'ext/spice.c', line 77

VALUE furnsh(int argc, VALUE *argv, VALUE self) {
  SpiceInt i;
  SpiceInt numkernels;

  block_signals();

  if (argc == 0) {
    rb_raise(rb_eArgError, "furnsh needs kernels!");
  } else {
    for(i=0; i < argc; i++) {
      Check_Type(argv[i], T_STRING);
    }
  }

  for(i=0; i < argc; i++) {
    furnsh_c(StringValuePtr(argv[i]));
  }

  ktotal_c("ALL", &numkernels);

  restore_signals();

  check_spice_error();

  return INT2FIX(numkernels);
}

+ (nil, Array) gdpool(name, start)

Return the d.p. value of a kernel variable from the kernel pool.

Parameters:

  • name (String)

    Name of the variable whose value is to be returned.

  • start (Fixnum)

    Which component to start retrieving for name

Returns:

  • (nil)

    if the varible was not found

  • (Array)

    A ruby array of values otherwise

See Also:



1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
# File 'ext/spice.c', line 1786

VALUE gdpool(VALUE self, VALUE name, VALUE start) {
  double values[32];
  SpiceInt vret, i;
  VALUE rb_values;
  SpiceBoolean found;

  Check_Type(name, T_STRING);
  Check_Type(start, T_FIXNUM);

  gdpool_c(StringValuePtr(name), NUM2INT(start), 32, &vret, values, &found);

  if (found == 0) {
    rb_raise(rb_eRuntimeError, "Variable not found in the pool");
    return Qnil;
  }

  rb_values = rb_ary_new2(vret);
  for (i=0; i<vret; i++)
    rb_ary_push(rb_values, rb_float_new(values[i]));

  check_spice_error();

  return rb_values;
}

+ (Array<String, String, Array<Float>, Array<Array<Float, Float, Float>>>) getfov(instid)

This routine returns the field-of-view (FOV) parameters for a specified instrument.

Parameters:

  • instid (Fixnum)

    NAIF ID of an instrument.

Returns:

  • (Array<String, String, Array<Float>, Array<Array<Float, Float, Float>>>)

    a Ruby array [shape, frame, [bsight], [bounds]]

  • shape: Instrument FOV shape.

  • frame: Name of the frame in which FOV vectors are defined.

  • bsight: Boresight vector.

  • bounds: FOV boundary vectors.

See Also:



983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
# File 'ext/spice.c', line 983

VALUE getfov(VALUE self, VALUE arg) {
  char shape[32];
  char frame[32];
  double bsight[3];
  SpiceInt n;
  double bounds[10][3];

  SpiceInt i;
  VALUE rb_bsight, rb_bounds;

  Check_Type(arg, T_FIXNUM);

  getfov_c(FIX2INT(arg), 10, 32, 32, shape, frame, bsight, &n, bounds);

  rb_bsight = rb_ary_new();
  for (i=0; i < 3; i++)
    rb_ary_push(rb_bsight, rb_float_new(bsight[i]));

  rb_bounds = rb_ary_new2(n);
  for (i = 0; i < n; i++)
    rb_ary_push(rb_bounds, rb_ary_new3(3, rb_float_new(bounds[i][0]), rb_float_new(bounds[i][1]), rb_float_new(bounds[i][2])));

  check_spice_error();

  return rb_ary_new3(4, rb_str_new2(shape), rb_str_new2(frame), rb_bsight, rb_bounds);
}

+ (Array<Array<Float, Float>>) gfdist(target, abcorr, obsrvr, relate, refval, adjust, step, nintvls, cnfine) + (Array<Array<Float, Float>>) gfdist(target, abcorr, obsrvr, relate, refval, adjust, step, nintvls, etstart, etstop)

Return the time window over which a specified constraint on observer-target distance is met.

Parameters:

  • target (String)

    Name of the target body.

  • abcorr (String)

    Aberration correction flag. See abcorr

  • obsrvr (String)

    Name of the observing body.

  • relate (String)

    Relational operator.

    Acceptable value's are:

    ">"      Distance is greater than the reference value `refval'.
    "="      Distance is equal to the reference value `refval'.
    "<"      Distance is less than the reference value `refval'.
    "ABSMAX" Distance is at an absolute maximum.
    "ABSMIN" Distance is at an absolute  minimum.
    "LOCMAX" Distance is at a local maximum.
    "LOCMIN" Distance is at a local minimum.
  • refval (Float)

    Reference value is the reference value used together with the argument `relate' to define an equality

  • adjust (Float)

    Adjustment value for absolute extrema searches.

    Adjust a parameter used to modify searches for absolute extrema: when `relate' is set to "ABSMAX" or "ABSMIN" and `adjust' is set to a positive value, gfdist_c will find times when the observer-target distance is within `adjust' km of the specified extreme value.

    If `adjust' is non-zero and a search for an absolute minimum `min' is performed, the result window contains time intervals when the observer-target distance has values between `min' and min+adjust.

    If the search is for an absolute maximum `max', the corresponding range is from max-adjust to `max'.

    `adjust' is not used for searches for local extrema, equality or inequality conditions

  • step (Float)

    Step size used for locating extrema and roots.

  • nintvls (Fixnum)

    Workspace window interval count. (number of intervals to return)

  • cnfine (SpiceCell)

    ** SPICE window to which the search is confined. cnfine is a SpiceDouble window. It must be initalized with wninsd()

  • etstart (Float)

    Instead of a cnfine window you can specify an et start and stop time (OSX)

  • etstop (Float)

Returns:

  • (Array<Array<Float, Float>>)

    A 2-demesional ruby array of windows [[start, end], [start, end]...]

  • times are returned in et

See Also:



1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
# File 'ext/spice.c', line 1064

VALUE gfdist(int argc, VALUE *argv, VALUE self) {
	SpiceInt i, niv;
	double beg, end;
	VALUE result;
	SPICEDOUBLE_CELL(intv, 5000);
	SPICEDOUBLE_CELL(win, 5000);
	SpiceCell *ptr;

	if (argc < 9 || argc > 10){
		rb_raise(rb_eArgError, "need 9 parameters!");
		return Qnil;
	}

	Check_Type(argv[0], T_STRING);/*target*/
	Check_Type(argv[1], T_STRING);/*abcorr*/
	Check_Type(argv[2], T_STRING);/*obsrvr*/
	Check_Type(argv[3], T_STRING);/*relate*/
	Check_Type(argv[4], T_FLOAT);/*refval*/
	Check_Type(argv[5], T_FLOAT);/*adj*/
	Check_Type(argv[6], T_FLOAT);/*step*/
	Check_Type(argv[7], T_FIXNUM);/*nintvls*/


	if (argc == 9){
		Check_Type(argv[8], T_DATA);/*spicedouble_Cell window*/

		Data_Get_Struct(argv[8], SpiceCell, ptr);
		gfdist_c (StringValuePtr(argv[0]), 
				StringValuePtr(argv[1]), 
				StringValuePtr(argv[2]), 
				StringValuePtr(argv[3]), 
				NUM2DBL(argv[4]), 
				NUM2DBL(argv[5]), 
				NUM2DBL(argv[6]), 
				FIX2INT(argv[7]),
				ptr , 
				&intv );
	}
	else{
		Check_Type(argv[8], T_FLOAT);/*start et*/
		Check_Type(argv[9], T_FLOAT);/*stop et*/

		wninsd_c(NUM2DBL(argv[8]), NUM2DBL(argv[9]), &win);
		gfdist_c(StringValuePtr(argv[0]), 
				StringValuePtr(argv[1]), 
				StringValuePtr(argv[2]), 
				StringValuePtr(argv[3]), 
				NUM2DBL(argv[4]), 
				NUM2DBL(argv[5]), 
				NUM2DBL(argv[6]), 
				FIX2INT(argv[7]),
				&win , 
				&intv );
	}
	check_spice_error();

	niv = wncard_c(&intv);
	if (niv == 0)
		return Qnil;

	result = rb_ary_new2(niv);

	for (i = 0; i < niv; i++) {
		wnfetd_c(&intv, i, &beg, &end);
		rb_ary_push(result, rb_ary_new3(2, INT2FIX(beg), INT2FIX(end)));
	}

	return result;
}

+ (nil, Array<Array<Float, Float>, Array<Float, Float>>) gfoclt(occtyp, front, fshape, fframe, back, bshape, bframe, abcorr, obsrvr, step, cnfine) + (nil, Array<Array<Float, Float>, Array<Float, Float>>) gfoclt(occtyp, front, fshape, fframe, back, bshape, bframe, abcorr, obsrvr, step, startet, stopet)

Determine time intervals when an observer sees one target occulted by, or in transit across, another.

Parameters:

  • occtyp (String)

    Type of occultation.

    Supported values:

    "FULL"
    "ANNULAR"
    "PARTIAL"
    "ANY"
  • front (String)

    Name of body occulting the other.

  • fshape (String)

    Type of shape model used for front body.

    Supported values:

    "ELLIPSOID"
    "POINT"
  • fframe (String)

    Body-fixed, body-centered frame for front body.

  • back (String)

    Name of body occulted by the other.

  • bshape (String)

    Type of shape model used for back body.

    Supported values:

    "ELLIPSOID"
    "POINT"
  • bframe (String)

    Body-fixed, body-centered frame for back body.

  • abcorr (String)

    Aberration correction flag. Please see abcorr

  • obsrvr (String)

    Name of the observing body.

  • step (Float)

    Step size in seconds for finding occultation events.

  • cnfine

    SPICE window to which the search is restricted. cnfine is a SpiceDouble window. It must be initalized with wninsd()

  • startet (Float)
  • stopet (Float)

Returns:

  • (nil)

    if no intervals found

  • (Array<Array<Float, Float>, Array<Float, Float>>)

    A 2-demesional ruby array of windows [ [start, end], [start, end]...]

  • times are returned in et

See Also:



2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
# File 'ext/spice.c', line 2206

VALUE gfoclt(int argc, VALUE* argv, VALUE self) {					
	SPICEDOUBLE_CELL (result, 5000);
	SpiceInt i, niv;
	double beg, end;
	VALUE rb_result;
	SpiceCell *cnfine;
	SPICEDOUBLE_CELL(win, 5000);

	if (argc < 11 || argc > 12){
		rb_raise(rb_eArgError, "need 11 parameters!");
		return Qnil;
	}
	Check_Type(argv[0], T_STRING); /*occtyp*/
	Check_Type(argv[1], T_STRING); /*front*/
	Check_Type(argv[2], T_STRING); /*fshape*/
	Check_Type(argv[3], T_STRING); /*fframe*/
	Check_Type(argv[4], T_STRING); /*back*/
	Check_Type(argv[5], T_STRING); /*bshape*/
	Check_Type(argv[6], T_STRING); /*bframe*/
	Check_Type(argv[7], T_STRING); /*abcorr*/
	Check_Type(argv[8], T_STRING); /*obsrvr*/
	Check_Type(argv[9], T_FLOAT); /*step*/


	if (argc == 11){
		Check_Type(argv[10],T_DATA); /*cnfine*/
		Data_Get_Struct(argv[10], SpiceCell, cnfine);

		gfoclt_c( StringValuePtr(argv[0]), 
				StringValuePtr(argv[1]),  
				StringValuePtr(argv[2]),
				StringValuePtr(argv[3]), 
				StringValuePtr(argv[4]), 
				StringValuePtr(argv[5]), 
				StringValuePtr(argv[6]), 
				StringValuePtr(argv[7]),  
				StringValuePtr(argv[8]),  
				NUM2DBL(argv[9]), 
				cnfine,
				&result);
	}
	else{
		Check_Type(argv[10], T_FLOAT);/*start et*/
		Check_Type(argv[11], T_FLOAT);/*stop et*/

		wninsd_c(NUM2DBL(argv[10]), NUM2DBL(argv[11]), &win);
		
		gfoclt_c( StringValuePtr(argv[0]), 
				StringValuePtr(argv[1]),  
				StringValuePtr(argv[2]),
				StringValuePtr(argv[3]), 
				StringValuePtr(argv[4]), 
				StringValuePtr(argv[5]), 
				StringValuePtr(argv[6]), 
				StringValuePtr(argv[7]),  
				StringValuePtr(argv[8]),  
				NUM2DBL(argv[9]), 
				&win,
				&result);
	}

	check_spice_error();

	niv = wncard_c(&result);
	if (niv == 0)
		return Qnil;

	rb_result = rb_ary_new2(niv);

	for (i = 0; i < niv; i++) {
		wnfetd_c(&result, i, &beg, &end);
		rb_ary_push(rb_result, rb_ary_new3(2, INT2FIX(beg), INT2FIX(end)));
	}

	return rb_result;
}

+ (Array<Array<Float, Float>>) gfrfov(inst, raydir, rframe, abcorr, obsrvr, step, cnfine) + (Array<Array<Float, Float>>) gfrfov(inst, raydir, rframe, abcorr, obsrvr, step, etstart, etstop)

Determine time intervals when a specified ray intersects the space bounded by the field-of-view (FOV) of a specified instrument.

Parameters:

  • inst (String)

    Name of the instrument.

  • raydir (Array<Float, Float, Float>)

    Ray's direction vector.

  • rframe (String)

    Reference frame of ray's direction vector.

  • abcorr (String)

    Aberration correction flag. See abcorr

  • obsrvr (String)

    Name of the observing body.

  • step (Float)

    Step size in seconds for finding FOV events.

  • cnfine (SpiceCell)

    SPICE window to which the search is restricted. cnfine is a SpiceDouble window. It must be initalized with wninsd()

  • etstart (Float)

    optional... can be used in place of a spicewindow

  • etstop (Float)

    optional... can be used in place of a spicewindow

Returns:

  • (Array<Array<Float, Float>>)

    A 2-demesional ruby array of windows [ [start, end], [start, end]...]

  • times are returned in et

See Also:



1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
# File 'ext/spice.c', line 1529

VALUE gfrfov(int argc, VALUE *argv, VALUE self){ 
	SpiceInt i, niv;
	double beg, end, ray[3];
	VALUE result;
	SPICEDOUBLE_CELL(intv, 5000);
	SPICEDOUBLE_CELL(win, 5000);
	SpiceCell *ptr;

	if (argc < 7 || argc > 8){
		rb_raise(rb_eArgError, "need 7 parameters!");
		return Qnil;
	}

	Check_Type(argv[0], T_STRING);/*inst*/
	Check_Type(argv[1], T_ARRAY);/*raydir double[3]*/
	Check_Type(argv[2], T_STRING);/*rframe*/
	Check_Type(argv[3], T_STRING);/*abcorr*/
	Check_Type(argv[4], T_STRING);/*obsvr*/
	Check_Type(argv[5], T_FLOAT);/*step*/

	for (i=0; i < 3; i++) {
		Check_Type(RARRAY_PTR(argv[1])[i], T_FLOAT);
		ray[i] = NUM2DBL(RARRAY_PTR(argv[1])[i]);
	}
	
	if (argc == 7){
	Check_Type(argv[6], T_DATA);/*cnfine*/
	Data_Get_Struct(argv[6], SpiceCell, ptr);

	gfrfov_c(StringValuePtr(argv[0]),
			ray,
			StringValuePtr(argv[2]),
			StringValuePtr(argv[3]),
			StringValuePtr(argv[4]),
			NUM2DBL(argv[5]),
			ptr,
			&intv);
	}
	else{
		Check_Type(argv[6], T_FLOAT);/*start et*/
		Check_Type(argv[7], T_FLOAT);/*stop et*/

		wninsd_c(NUM2DBL(argv[6]), NUM2DBL(argv[7]), &win);

		gfrfov_c(StringValuePtr(argv[0]),
				ray,
				StringValuePtr(argv[2]),
				StringValuePtr(argv[3]),
				StringValuePtr(argv[4]),
				NUM2DBL(argv[5]),
				&win,
				&intv);


	}

	check_spice_error();
	niv = wncard_c(&intv);
	if (niv == 0)
		return Qnil;

	result = rb_ary_new2(niv);

	for (i = 0; i < niv; i++){
		wnfetd_c(&intv, i, &beg, &end);
		rb_ary_push(result, rb_ary_new3(2, INT2FIX(beg), INT2FIX(end)));
	}

	return result;

}

+ (nil, Array<Array<Float, Float>>) gfsep(targ1, shape1, frame1, targ2, shape2, frame2, abcorr, obsrvr, relate, refval, adjust, step, nintvls, cnfine) + (nil, Array<Array<Float, Float>>) gfsep(targ1, shape1, frame1, targ2, shape2, frame2, abcorr, obsrvr, relate, refval, adjust, step, nintvls, start_et, stop_et)

Determine time intervals when the angular separation between the position vectors of two target bodies relative to an observer satisfies a numerical relationship.

Parameters:

  • targ1 (String)

    Name of first body

  • shape1 (String)

    Name of shape model describing the first body

  • frame1 (String)

    The body-fixed reference frame of the first body

  • targ2 (String)

    Name of second body

  • shape2 (String)

    Name of the shape model describing the second body

  • frame2 (String)

    The body-fixed reference frame of the second body

  • abcorr (String)

    Aberration correction flag. See abcorr

  • obsrvr (String)

    Name of the observing body

  • relate (String)

    Operator that either looks for an extreme value (max, min, local, absolute) or compares the angular separation value and refval

  • refval (Float)

    Reference value

  • adjust (Float)

    Absolute extremum adjustment value

  • step (Float)

    Step size in seconds for finding angular separation events

  • nintvls (Fixnum)

    Workspace window interval count

  • cnfine (SpiceCell)

    SPICE window to which the search is restricted

    cnfine is a SpiceDouble window. It must be initalized with wninsd()

  • start_et (Float)
  • stop_et (Float)

Returns:

  • (nil)

    if no intervals found

  • (Array<Array<Float, Float>>)

    A 2-demesional ruby array of windows [ [start, end], [start, end]...]

  • times are returned in et

See Also:



1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
# File 'ext/spice.c', line 1311

VALUE gfsep(int argc, VALUE *argv, VALUE self) {
	SpiceInt i, niv;
	double beg, end;
	VALUE result;
	SPICEDOUBLE_CELL(intv, 5000);
	SpiceCell *ptr;
	SPICEDOUBLE_CELL(win, 5000);

	if (argc < 14 || argc >> 15){
		rb_raise(rb_eArgError, "need 14 parameters!");
		return Qnil;
	}
	Check_Type(argv[0], T_STRING);/*target1*/
	Check_Type(argv[1], T_STRING);/*shape1*/
	Check_Type(argv[2], T_STRING);/*frame1*/
	Check_Type(argv[3], T_STRING);/*targ2*/
	Check_Type(argv[4], T_STRING);/*shape2*/
	Check_Type(argv[5], T_STRING);/*frame2*/
	Check_Type(argv[6], T_STRING);/*abcorr*/
	Check_Type(argv[7], T_STRING);/*obsvr*/
	Check_Type(argv[8], T_STRING);/*relate*/
	Check_Type(argv[9], T_FLOAT);/*refval*/
	Check_Type(argv[10], T_FLOAT);/*adjust*/
	Check_Type(argv[11], T_FLOAT);/*step*/
	Check_Type(argv[12], T_FIXNUM);/*nintvls*/


	if (argc == 14){
		Check_Type(argv[13], T_DATA);/*cfnine*/
		Data_Get_Struct(argv[13], SpiceCell, ptr);

		gfsep_c(StringValuePtr(argv[0]),
				StringValuePtr(argv[1]),
				StringValuePtr(argv[2]),
				StringValuePtr(argv[3]),
				StringValuePtr(argv[4]),
				StringValuePtr(argv[5]),
				StringValuePtr(argv[6]),
				StringValuePtr(argv[7]),
				StringValuePtr(argv[8]),
				NUM2DBL(argv[9]),
				NUM2DBL(argv[10]),
				NUM2DBL(argv[11]),
				FIX2INT(argv[12]),
				ptr,
				&intv);
	}
	else{
		Check_Type(argv[13], T_FLOAT);/*start et*/
		Check_Type(argv[14], T_FLOAT);/*stop et*/

		wninsd_c(NUM2DBL(argv[13]), NUM2DBL(argv[14]), &win);

		gfsep_c(StringValuePtr(argv[0]),
				StringValuePtr(argv[1]),
				StringValuePtr(argv[2]),
				StringValuePtr(argv[3]),
				StringValuePtr(argv[4]),
				StringValuePtr(argv[5]),
				StringValuePtr(argv[6]),
				StringValuePtr(argv[7]),
				StringValuePtr(argv[8]),
				NUM2DBL(argv[9]),
				NUM2DBL(argv[10]),
				NUM2DBL(argv[11]),
				FIX2INT(argv[12]),
				&win,
				&intv);

	}


	check_spice_error();
	niv = wncard_c(&intv);
	if (niv == 0)
		return Qnil;

	result = rb_ary_new2(niv);

	for (i = 0; i < niv; i++){
		wnfetd_c(&intv, i, &beg, &end);
		rb_ary_push(result, rb_ary_new3(2, INT2FIX(beg), INT2FIX(end)));
	}

	return result;

}

+ (nil, Array<Array<Float, Float>>) gfsntc(target, fixref, method, abcorr, obsrvr, dref, dvec, crdsys, coord, relate, retval, adjust, step, nintvls, cnfine) + (nil, Array<Array<Float, Float>>) gfsntc(target, fixref, method, abcorr, obsrvr, dref, dvec, crdsys, coord, relate, retval, adjust, step, nintvls, start_et, end_et)

Determine time intervals for which a coordinate of an surface intercept position vector satisfies a numerical constraint.

Parameters:

  • target (String)

    Name of the target body

  • fixref (String)

    Body fixed frame associated with 'target'

  • method (String)

    Name of method type for surface intercept calculation

  • abcorr (String)

    Aberration correction flag. Please see abcorr

  • obsrvr (String)

    Name of the observing body

  • dref (String)

    Reference frame of direction vector 'dvec'

  • dvec (Array<Float, Float, Float>)

    Pointing direction vector from 'obsrvr' (a ruby 3 vector of floats)

  • crdsys (String)

    Name of the coordinate system containing COORD

  • coord (String)

    Name of the coordinate of interest

  • relate (String)

    Operator that either looks for an extreme value (max, min, local, absolute) or compares the coordinate value and refval

  • refval (Float)

    Reference value

  • adjust (Float)

    Adjustment value for absolute extrema searches

  • step (Float)

    Step size used for locating extrema and roots

  • nintvls (Fixnum)

    Workspace window interval count

  • cnfine (SpiceCell)

    SPICE window to which the search is restricted cnfine is a SpiceDouble window. It must be initalized with wninsd() or a start_et and end_et can be used

  • start_et (Float)
  • end_et (Float)

Returns:

  • (nil)

    if no intervals found

  • (Array<Array<Float, Float>>)

    A 2-demesional ruby array of windows [[start, end],[start, end]...]

  • times are returned in et

See Also:



1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
# File 'ext/spice.c', line 1184

VALUE gfsntc(int argc, VALUE *argv, VALUE self) {
	double dvec[3];
	SpiceInt i, niv;
	double beg, end;
	VALUE result;
	SPICEDOUBLE_CELL(intv, 5000);
	SPICEDOUBLE_CELL(win, 5000);
	SpiceCell *ptr;
	if (argc < 15  || argc > 16){
		rb_raise(rb_eArgError, "need 15 parameters!");
		return Qnil;
	}

	Check_Type(argv[0], T_STRING);/*target*/
	Check_Type(argv[1], T_STRING);/*fixref*/
	Check_Type(argv[2], T_STRING);/*method*/
	Check_Type(argv[3], T_STRING);/*abcorr*/
	Check_Type(argv[4], T_STRING);/*obsrvr*/
	Check_Type(argv[5], T_STRING);/*dref*/
	Check_Type(argv[6], T_ARRAY); /*dvec*/
	Check_Type(argv[7], T_STRING);/*crdsys*/
	Check_Type(argv[8], T_STRING);/*coord*/
	Check_Type(argv[9], T_STRING);/*relate*/
	Check_Type(argv[10], T_FLOAT); /*refval*/
	Check_Type(argv[11], T_FLOAT); /*adjust*/
	Check_Type(argv[12], T_FLOAT); /*step*/
	Check_Type(argv[13], T_FIXNUM);/*nintvls*/

	for (i=0; i < 3; i++){
		Check_Type(RARRAY_PTR(argv[6])[i], T_FLOAT);
		dvec[i] = NUM2DBL(RARRAY_PTR(argv[6])[i]);
	}

	if (argc == 15){
		Check_Type(argv[14], T_DATA);/*spicedouble_Cell window*/
		Data_Get_Struct(argv[14], SpiceCell, ptr);

		gfsntc_c(StringValuePtr(argv[0]),
				StringValuePtr(argv[1]),
				StringValuePtr(argv[2]),
				StringValuePtr(argv[3]),
				StringValuePtr(argv[4]),
				StringValuePtr(argv[5]),
				dvec,
				StringValuePtr(argv[7]),
				StringValuePtr(argv[8]),
				StringValuePtr(argv[9]),
				NUM2DBL(argv[10]),
				NUM2DBL(argv[11]),
				NUM2DBL(argv[12]),
				FIX2INT(argv[13]),
				ptr,
				&intv);
	}
	else {
		Check_Type(argv[14], T_FLOAT);/*start et*/
		Check_Type(argv[15], T_FLOAT);/*stop et*/
		wninsd_c(NUM2DBL(argv[14]), NUM2DBL(argv[15]), &win);

		gfsntc_c ( StringValuePtr(argv[0]),
				StringValuePtr(argv[1]),
				StringValuePtr(argv[2]),
				StringValuePtr(argv[3]),
				StringValuePtr(argv[4]),
				StringValuePtr(argv[5]),
				dvec,
				StringValuePtr(argv[7]),
				StringValuePtr(argv[8]),
				StringValuePtr(argv[9]),
				NUM2DBL(argv[10]),
				NUM2DBL(argv[11]),
				NUM2DBL(argv[12]),
				FIX2INT(argv[13]),
				&win,
				&intv);

	}
	check_spice_error();

	niv = wncard_c(&intv);
	if (niv == 0)
		return Qnil;

	result = rb_ary_new2(niv);

	for (i = 0; i < niv; i++) {
		wnfetd_c(&intv, i, &beg, &end);
		rb_ary_push(result, rb_ary_new3(2, rb_float_new(beg), rb_float_new(end)));
	}

	return result;
}

+ (nil, Array<Array<Float, Float>>) gftfov(inst, target, tshape, tframe, abcorr, obsrvr, step, cnfine) + (nil, Array<Array<Float, Float>>) gftfov(inst, target, tshape, tframe, abcorr, obsrvr, step, etstart, etstop)

Determine time intervals when a specified ephemeris object intersects the space bounded by the field-of-view (FOV) of a specified instrument.

Parameters:

  • inst (String)

    Name of the instrument.

  • target (String)

    Name of the target body.

  • tshape (String)

    Type of shape model used for target body.

  • tframe (String)

    Body-fixed, body-centered frame for target body.

  • abcorr (String)

    Aberration correction flag. Please see abcorr

  • obsrvr (String)

    Name of the observing body.

  • step (Float)

    Step size in seconds for finding FOV events.

  • cnfine (SpiceCell)

    SPICE window to which the search is restricted. cnfine is a SpiceDouble window. It must be initalized with wninsd()

  • etstart (Float)

    optional... can be used in place of a spicewindow

  • etstop (Float)

    optional... can be used in place of a spicewindow

Returns:

  • (nil)

    if no intervals found

  • (Array<Array<Float, Float>>)

    A 2-demesional ruby array of windows [[start, end], [start, end]...]

  • times are returned in et

See Also:



1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
# File 'ext/spice.c', line 1435

VALUE gftfov(int argc, VALUE *argv, VALUE self) {
	SpiceInt i, niv;
	double beg, end;
	SpiceCell *ptr;
	VALUE result;
	SPICEDOUBLE_CELL(intv, 5000);
	SPICEDOUBLE_CELL(win, 5000);

	if (argc < 8 || argc > 9){
		rb_raise(rb_eArgError, "need 8 parameters!");
		return Qnil;
	}

	Check_Type(argv[0], T_STRING);/*inst*/
	Check_Type(argv[1], T_STRING);/*target*/
	Check_Type(argv[2], T_STRING);/*tshape*/
	Check_Type(argv[3], T_STRING);/*tframe*/
	Check_Type(argv[4], T_STRING);/*abcorr*/
	Check_Type(argv[5], T_STRING);/*obsvr*/
	Check_Type(argv[6], T_FLOAT);/*step*/


	if (argc == 8){
	Check_Type(argv[7], T_DATA);/*cnfine*/
	Data_Get_Struct(argv[7], SpiceCell, ptr);

	gftfov_c (      StringValuePtr(argv[0]),
			StringValuePtr(argv[1]),
			StringValuePtr(argv[2]),
			StringValuePtr(argv[3]),
			StringValuePtr(argv[4]),
			StringValuePtr(argv[5]),
			NUM2DBL(argv[6]),
			ptr,
			&intv  );
	}
	else{
		Check_Type(argv[7], T_FLOAT);/*start et*/
		Check_Type(argv[8], T_FLOAT);/*stop et*/

		wninsd_c(NUM2DBL(argv[7]), NUM2DBL(argv[8]), &win);
		gftfov_c (      StringValuePtr(argv[0]),
				StringValuePtr(argv[1]),
				StringValuePtr(argv[2]),
				StringValuePtr(argv[3]),
				StringValuePtr(argv[4]),
				StringValuePtr(argv[5]),
				NUM2DBL(argv[6]),
				&win,
				&intv  );
	}

	check_spice_error();
	niv = wncard_c(&intv);
	if (niv == 0)
		return Qnil;

	result = rb_ary_new2(niv);

	for (i = 0; i < niv; i++){
		wnfetd_c(&intv, i, &beg, &end);
		rb_ary_push(result, rb_ary_new3(2, INT2FIX(beg), INT2FIX(end)));
	}

	return result;

}

+ (Array<Float, Array<Float, Float, Float>, Float, Float, Float>) ilumin(method, target, et, fixref, abcorr, obsrvr, spoint)

Find the illumination angles (phase, solar incidence, and emission) at a specified surface point of a target body.

Parameters:

  • method (String)

    Computation method. The only choice currently supported is "Ellipsoid"

  • target (String)

    Name of target body. EX: "MOON"

  • et (Float)

    Epoch in ephemeris seconds past J2000 TDB.

  • fixref (String)

    Body-fixed, body-centered target body frame. EX "iau_moon"

  • abcorr (String)

    Desired aberration correction. Please see abcorr

  • obsrvr (String)

    Name of observing body. EX: "LRO"

  • spoint (Array<Float, Float, Float>)

    Body-fixed coordinates of a target surface point. a vector

Returns:

  • (Array<Float, Array<Float, Float, Float>, Float, Float, Float>)

    a ruby array: [trgepc, [srfvecX, srfvecY, srfvecZ], phaseAngle, solarAngle, emissionAngle]

  • NOTE: all angles are in radians

See Also:



607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
# File 'ext/spice.c', line 607

VALUE ilumin(int argc, VALUE *argv, VALUE self) {
  double spoint[3];
  double trgepc;
  double srfvec[3];
  double phase, solar, emissn;
  VALUE rb_srfvec;
  SpiceInt i;

  if (argc != 7) {
    rb_raise(rb_eArgError, "need 7 parameters!");
    return Qnil;
  }

  Check_Type(argv[0], T_STRING);
  Check_Type(argv[1], T_STRING);
  Check_Type(argv[2], T_FLOAT);
  Check_Type(argv[3], T_STRING);
  Check_Type(argv[4], T_STRING);
  Check_Type(argv[5], T_STRING);
  Check_Type(argv[6], T_ARRAY);

  if (RARRAY_LEN(argv[6]) != 3) {
    rb_raise(rb_eArgError, "The array should have 3 items in it");
    return Qnil;
  }

  for (i=0; i < 3; i++) {
    Check_Type(RARRAY_PTR(argv[6])[i], T_FLOAT);
    spoint[i] = NUM2DBL(RARRAY_PTR(argv[6])[i]);
  }

  ilumin_c(StringValuePtr(argv[0]), StringValuePtr(argv[1]), NUM2DBL(argv[2]), StringValuePtr(argv[3]), StringValuePtr(argv[4]), StringValuePtr(argv[5]), spoint, &trgepc, srfvec, &phase, &solar, &emissn);

  rb_srfvec = rb_ary_new();
  for (i=0; i < 3; i++)
    rb_ary_push(rb_srfvec, rb_float_new(srfvec[i]));

  check_spice_error();

  return rb_ary_new3(5, rb_float_new(trgepc), rb_srfvec, rb_float_new(phase), rb_float_new(solar), rb_float_new(emissn));
}

+ (Boolean) kclear

Clear the KEEPER system: unload all kernels, clear the kernel pool, and re-initialize the system.

Parameters:

  • NONE

Returns:

  • (Boolean)

    true if successful

See Also:



151
152
153
154
155
156
157
158
# File 'ext/spice.c', line 151

VALUE kclear(VALUE self) {
  VALUE result = Qtrue;

  kclear_c();
  check_spice_error();

  return result;
}

+ (Fixnum) ktotal

Return the current number of kernels that have been loaded via the KEEPER interface that are of a specified type.

Parameters:

  • NONE

Returns:

  • (Fixnum)

    the number of kernels

See Also:



170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'ext/spice.c', line 170

VALUE ktotal(int argc, VALUE *argv, VALUE self) {
  VALUE result = Qnil;
  SpiceInt numkernels;

  if (argc > 0) {
    rb_raise(rb_eArgError, "no parameters here");
    return result;
  }

  ktotal_c("ALL", &numkernels);
  check_spice_error();

  return INT2FIX(numkernels);
}

+ (Array<Float, Float, Float>) latrec(radius, longitude, latitude)

Convert from latitudinal coordinates to rectangular coordinates.

Parameters:

  • radius (Float)

    Distance of a point from the origin.

  • longitude (Float)

    Longitude of point in radians.

  • latitude (Float)

    Latitude of point in radians.

Returns:

  • (Array<Float, Float, Float>)

    A ruby array containing the rectangular vector. EX: [X,Y,Z]

See Also:



1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
# File 'ext/spice.c', line 1864

VALUE latrec(VALUE self, VALUE radius, VALUE lon, VALUE lat) {
  double spoint[3];

  Check_Type(radius, T_FLOAT);
  Check_Type(lon, T_FLOAT);
  Check_Type(lat, T_FLOAT);

  latrec_c(NUM2DBL(radius), NUM2DBL(lon), NUM2DBL(lat), spoint);

  check_spice_error();

  return rb_ary_new3(3, rb_float_new(spoint[0]), rb_float_new(spoint[1]), rb_float_new(spoint[2]));
}

+ (Float) lspcn

Compute L_s, the planetocentric longitude of the sun, as seen from a specified body.

Parameters:

  • body (String)

    Name of central body.

  • et (Float)

    Epoch in seconds past J2000 TDB.

  • abcorr (String)

    Aberration correction. Please see abcorr

Returns:

  • (Float)

    the value of L_s

See Also:



1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
# File 'ext/spice.c', line 1824

VALUE lspcn(VALUE self, VALUE body, VALUE et, VALUE abcorr) {
  SpiceDouble res;

  Check_Type(body, T_STRING);
  Check_Type(et, T_FLOAT);
  Check_Type(abcorr, T_STRING);

  res = lspcn_c(StringValuePtr(body), NUM2DBL(et), StringValuePtr(abcorr));

  check_spice_error();

  return rb_float_new(res);
}

+ (Array<Float, Float, Float>) m2eul(r, axis1, axis2, axis3)

Factor a rotation matrix as a product of three rotations about specified coordinate axes.

Parameters:

  • r (Array<Array<Float, Float, Float>>)

    A rotation matrix to be factored. passed in as a ruby array [3] [3]

  • axis1 (Fixnum)

    Numbers of third, second, and first rotation axes.

  • axis2 (Fixnum)
  • axis3 (Fixnum)

Returns:

  • (Array<Float, Float, Float>)

    A ruby array representing the 3 Euler angles. [angle3, angle2, angle1]

See Also:



2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
# File 'ext/spice.c', line 2356

VALUE m2eul(VALUE self, VALUE rb_r, VALUE rb_axis3, VALUE rb_axis2, VALUE rb_axis1) {
  double r[3][3];
  SpiceDouble angle3, angle2, angle1;
  SpiceInt i, j;

  if (RARRAY_LEN(rb_r) != 3) {
    rb_raise(rb_eArgError, "R should be 3x3");
    return Qnil;
  }

  for(i=0; i<3; i++) {
    if (RARRAY_LEN(RARRAY_PTR(rb_r)[i]) !=3) {
      rb_raise(rb_eArgError, "R should be 3x3");
      return Qnil;
    }

    for (j=0; j<3; j++) {
      Check_Type(RARRAY_PTR(RARRAY_PTR(rb_r)[i])[j], T_FLOAT);
      r[i][j] = NUM2DBL(RARRAY_PTR(RARRAY_PTR(rb_r)[i])[j]);
    }
  }

  m2eul_c((const double(*)[3])r, NUM2INT(rb_axis3), NUM2INT(rb_axis2), NUM2INT(rb_axis1), &angle3, &angle2, &angle1);

  check_spice_error();

  return rb_ary_new3(3, rb_float_new(angle3), rb_float_new(angle2), rb_float_new(angle1));
}

+ (Array<Float, Float, Float, Float>) m2q(r)

Find the rotation matrix corresponding to a specified unit quaternion.

Parameters:

  • r (Array<Array<Float, Float, Float>>)

    A 3x3 rotation matrix (In ruby [[3], [3], [3]])

Returns:

  • (Array<Float, Float, Float, Float>)

    a ruby array [4] containing A unit quaternion representing `r'.

See Also:



2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
# File 'ext/spice.c', line 2397

VALUE m2q(int argc, VALUE *argv, VALUE self){
  double r[3][3];
  double q[4];
  int i, j;

  if (argc != 1) {
    rb_raise(rb_eArgError, "Need 1 parameter!");
    return Qnil;
  }
  Check_Type(argv[0], T_ARRAY);

  if (RARRAY_LEN(argv[0]) != 3) {
    rb_raise(rb_eArgError, "r should be 3x3");
    return Qnil;
  }

  for(i=0; i<3; i++) {
    if (RARRAY_LEN(RARRAY_PTR(argv[0])[i]) !=3) {
      rb_raise(rb_eArgError, "r should be 3x3");
      return Qnil;
    }
    for (j=0; j<3; j++) {
      Check_Type(RARRAY_PTR(RARRAY_PTR(argv[0])[i])[j], T_FLOAT);
      r[i][j] = NUM2DBL(RARRAY_PTR(RARRAY_PTR(argv[0])[i])[j]);
    }
  }

  m2q_c((const double(*)[3])r, q);

  check_spice_error();

  return rb_ary_new3(4, rb_float_new(q[0]),  rb_float_new(q[1]), rb_float_new(q[2]), rb_float_new(q[3]));
}

+ (Object) mxm(m1, m2)

Multiply a 3x3 double precision matrix with a 3x3 double precision matrix

Parameters:

  • m1 (Array<Array<Float, Float, Float>, Array<Float, Float, Float>, Array<Float, Float, Float>>)

    3x3 double precision matrix. passed in as ruby array [3] [3]

  • m2 (Array<Array<Float, Float, Float>, Array<Float, Float, Float>, Array<Float, Float, Float>>)

    3x3 double precision matrix. passed in as ruby array [3] [3]

See Also:

Since:

  • 2.18



2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
# File 'ext/spice.c', line 2500

VALUE mxm(int argc, VALUE *argv, VALUE self){
  double m1[3][3];
  double m2[3][3];
  double mout[3][3];
  SpiceInt i, j;

  block_signals();


  if (argc != 2) { 
    rb_raise(rb_eArgError, "Needs 2 parameters!");
    return Qnil;
  }

  if (RARRAY_LEN(argv[0]) != 3 || RARRAY_LEN(argv[1]) != 3) {
    rb_raise(rb_eArgError, "M1 and M2 should be 3x3");
    return Qnil;
  }

  for(i = 0; i < 3; i++) {
    if (RARRAY_LEN(RARRAY_PTR(argv[0])[i]) != 3 || RARRAY_LEN(RARRAY_PTR(argv[1])[i]) != 3) {
      rb_raise(rb_eArgError, "M1 and M2 should be 3x3.");
      return Qnil;
    }

    for(j = 0; j < 3; j++) {
      Check_Type(RARRAY_PTR(RARRAY_PTR(argv[0])[i])[j], T_FLOAT);
      m1[i][j] = NUM2DBL(RARRAY_PTR(RARRAY_PTR(argv[0])[i])[j]);

      Check_Type(RARRAY_PTR(RARRAY_PTR(argv[1])[i])[j], T_FLOAT);
      m2[i][j] = NUM2DBL(RARRAY_PTR(RARRAY_PTR(argv[1])[i])[j]);
    }
  }

  mxm_c((const double(*)[3])m1, (const double(*)[3])m2, (double(*)[3])mout);

  restore_signals();

  check_spice_error();

  return rb_ary_new3(3, rb_ary_new3(3, rb_float_new(mout[0][0]),  rb_float_new(mout[0][1]), rb_float_new(mout[0][2])), rb_ary_new3(3, rb_float_new(mout[1][0]),  rb_float_new(mout[1][1]), rb_float_new(mout[1][2])), rb_ary_new3(3, rb_float_new(mout[2][0]),  rb_float_new(mout[2][1]), rb_float_new(mout[2][2])));
}

+ (Array<Float, Float, Float>) mxv(m1, v1)

Multiply a 3x3 double precision matrix with a 3-dimensional double precision vector.

Parameters:

  • m1 (Array<Array<Float, Float, Float>, Array<Float, Float, Float>, Array<Float, Float, Float>>)

    3x3 double precision matrix. passed in as ruby array [3] [3]

  • v1 (Array<Float, Float, Float>)

    3-dimensional double precision vector. passed in as a 3 item ruby array

Returns:

  • (Array<Float, Float, Float>)

    A 3 item ruby array representing the product m1*vin.

See Also:



2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
# File 'ext/spice.c', line 2123

VALUE mxv(VALUE self, VALUE rb_m1, VALUE rb_v1) {
  double v2[3];
  double v1[3];
  double m1[3][3];
  SpiceInt i, j;

  if (RARRAY_LEN(rb_v1) != 3) {
    rb_raise(rb_eArgError, "V1 should have 3 items in it");
    return Qnil;
  }

  if (RARRAY_LEN(rb_m1) != 3) {
    rb_raise(rb_eArgError, "M1 should be 3x3");
    return Qnil;
  }

  for(i = 0; i < 3; i++) {
    Check_Type(RARRAY_PTR(rb_v1)[i], T_FLOAT);
    v1[i] = NUM2DBL(RARRAY_PTR(rb_v1)[i]);

    if (RARRAY_LEN(RARRAY_PTR(rb_m1)[i]) != 3) {
      rb_raise(rb_eArgError, "M1 should be 3x3.");
      return Qnil;
    }

    for(j = 0; j < 3; j++) {
      Check_Type(RARRAY_PTR(RARRAY_PTR(rb_m1)[i])[j], T_FLOAT);
      m1[i][j] = NUM2DBL(RARRAY_PTR(RARRAY_PTR(rb_m1)[i])[j]);
    }
  }

  mxv_c((const double(*)[3])m1, v1, v2);

  check_spice_error();

  return rb_ary_new3(3, rb_float_new(v2[0]), rb_float_new(v2[1]), rb_float_new(v2[2]));
}

+ (Array<Array<Float, Float, Float>[3]>) pxform(from, to, et)

Return the matrix that transforms position vectors from one specified frame to another at a specified epoch.

Parameters:

  • from (String)

    Name of the frame to transform from.

  • to (String)

    Name of the frame to transform to.

  • et (Float)

    Epoch of the rotation matrix.

Returns:

  • (Array<Array<Float, Float, Float>[3]>)

    a ruby array [3] [3] containing the rotation matrix

See Also:



2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
# File 'ext/spice.c', line 2635

VALUE pxform(VALUE self, VALUE from, VALUE to, VALUE et) {
  double cmat[3][3];

  Check_Type(from, T_STRING);
  Check_Type(to, T_STRING);
  Check_Type(et, T_FLOAT);

  pxform_c(StringValuePtr(from), StringValuePtr(to), NUM2DBL(et), cmat);

  check_spice_error();

  return rb_ary_new3(3, rb_ary_new3(3, rb_float_new(cmat[0][0]), rb_float_new(cmat[0][1]), rb_float_new(cmat[0][2])), rb_ary_new3(3, rb_float_new(cmat[1][0]), rb_float_new(cmat[1][1]), rb_float_new(cmat[1][2])), rb_ary_new3(3, rb_float_new(cmat[2][0]), rb_float_new(cmat[2][1]), rb_float_new(cmat[2][2])));
}

+ (Array<Array<Float, Float, Float>[3]>) q2m(q)

Find the rotation matrix corresponding to a specified unit quaternion.

Parameters:

  • q (Array<Float, Float, Float, Float>)

    A unit quaternion. (in ruby a 4 element array)

Returns:

  • (Array<Array<Float, Float, Float>[3]>)

    a ruby array [3] [3] containing the rotation matrix corresponding to 'q'

See Also:



2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
# File 'ext/spice.c', line 2663

VALUE q2m(int argc, VALUE *argv, VALUE self){
  double q[4];
  double r[3][3];
  int i;

  if (argc != 1) {
    rb_raise(rb_eArgError, "Need 1 parameter!");
    return Qnil;
  }
  Check_Type(argv[0], T_ARRAY);

  for (i=0; i < 4; i++){
    Check_Type(RARRAY_PTR(argv[0])[i], T_FLOAT);
    q[i] = NUM2DBL(RARRAY_PTR(argv[0])[i]);
  }

  q2m_c(q, r);

  check_spice_error();


  return rb_ary_new3(3, rb_ary_new3(3, rb_float_new(r[0][0]),  rb_float_new(r[0][1]), rb_float_new(r[0][2])), rb_ary_new3(3, rb_float_new(r[1][0]),  rb_float_new(r[1][1]), rb_float_new(r[1][2])), rb_ary_new3(3, rb_float_new(r[2][0]),  rb_float_new(r[2][1]), rb_float_new(r[2][2])));
}

+ (Array<Float, Float, Float, Float>) qxq(q1, q2)

Calculate the product of two quaternions.

Parameters:

  • q1 (Array<Float, Float, Float, Float>)

    a ruby array [4] containing A unit quaternion

  • q2 (Array<Float, Float, Float, Float>)

    a ruby array [4] containing A unit quaternion

Returns:

  • (Array<Float, Float, Float, Float>)

    a ruby array [4] representing a unit quatrnion which is the product of q1 and q2 and output of this function

See Also:



2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
# File 'ext/spice.c', line 2445

VALUE qxq(int argc, VALUE *argv, VALUE self){
  double q1[4];
	double q2[4];
	double qout[4];
  int i;

	block_signals();

  if (argc != 2) { 
    rb_raise(rb_eArgError, "Needs 2 parameters!");
    return Qnil;
  }

  if (RARRAY_LEN(argv[0]) != 4 || RARRAY_LEN(argv[1]) != 4) {
    rb_raise(rb_eArgError, "q1 and q2 should be 4 element arrays");
    return Qnil;
  }
   	
	Check_Type(argv[0], T_ARRAY);
	Check_Type(argv[1], T_ARRAY);

	for( i = 0; i < 4; i++) {
			Check_Type(RARRAY_PTR(argv[0])[i], T_FLOAT);
    	q1[i] = NUM2DBL(RARRAY_PTR(argv[0])[i]);
			
			Check_Type(RARRAY_PTR(argv[1])[i], T_FLOAT);
      q2[i] = NUM2DBL(RARRAY_PTR(argv[1])[i]);
	}
  

	qxq_c(q1, q2, qout);

	restore_signals();

  check_spice_error();

	return rb_ary_new3(4, rb_float_new(qout[0]),  rb_float_new(qout[1]), rb_float_new(qout[2]), rb_float_new(qout[3]));
}

+ (Float) rb2et(date_time)

Convert a ruby DateTime object into et

Parameters:

  • date_time (DateTime)

    A ruby DateTime Object

Returns:

  • (Float)

    et



798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
# File 'ext/spice.c', line 798

VALUE rb2et(VALUE self, VALUE arg) {
  double et;
  VALUE rb_tmp1, rb_tmp2;
  int usec;
  char tmpstr[1000];

  usec = FIX2INT(rb_funcall(arg, rb_intern("usec"), 0));
  rb_tmp1 = rb_funcall(arg, rb_intern("utc"), 0);

  rb_tmp2 = rb_funcall(rb_tmp1, rb_intern("strftime"), 1, rb_str_new2("%Y-%m-%dT%H:%M:%S"));

  sprintf(tmpstr, "%s.%06d", StringValuePtr(rb_tmp2), usec);

  str2et_c(tmpstr, &et);

  check_spice_error();

  return rb_float_new(et);
}

+ (Array<Float, Float, Float>) reclat(rectan)

Convert from rectangular coordinates to latitudinal coordinates.

Examples:

# Returns a ruby array that can be saved as follows
radius, lon, lat = reclat(rectan)

Parameters:

  • rectan (Array<Float, Float, Float>)

    The rectangular coordinates of the input point. `rectan' is a 3-vector.

Returns:

  • (Array<Float, Float, Float>)

    Ruby array of [radius, lon, lat]

See Also:



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'ext/spice.c', line 296

VALUE reclat(int argc, VALUE* argv, VALUE self) {
  double spoint[3];
  SpiceInt i;
  double radius, lon, lat;

  if (argc != 1) {
    rb_raise(rb_eArgError, "Need just 1 parameter");
    return Qnil;
  }

  Check_Type(argv[0], T_ARRAY);

  if (RARRAY_LEN(argv[0]) != 3) {
    rb_raise(rb_eArgError, "The array should have 3 items in it");
    return Qnil;
  }

  for (i=0; i < 3; i++) {
    Check_Type(RARRAY_PTR(argv[0])[i], T_FLOAT);
    spoint[i] = NUM2DBL(RARRAY_PTR(argv[0])[i]);
  }

  reclat_c(spoint, &radius, &lon, &lat);

  check_spice_error();

  return rb_ary_new3(3, rb_float_new(radius), rb_float_new(lon), rb_float_new(lat));
}

+ (Array<Float, Float, Float>) recrad(rectan)

Convert rectangular coordinates to range, right ascension, and declination.

Parameters:

  • rectan (Array<Number, Number, Number>)

    Rectangular coordinates of a point. passed in as a 3 item ruby array

Returns:

  • (Array<Float, Float, Float>)

    A 3 item ruby array, representing: [range, ra. dec]

  • range Distance of the point from the origin.

  • ra Right ascension in radians.

  • dec Declination in radians.

See Also:



2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
# File 'ext/spice.c', line 2702

VALUE recrad(int argc, VALUE* argv, VALUE self) {
  double spoint[3];
  SpiceInt i;
  double range, ra, dec;

  if (argc != 1) {
    rb_raise(rb_eArgError, "Need just 1 parameter");
    return Qnil;
  }

  Check_Type(argv[0], T_ARRAY);

  if (RARRAY_LEN(argv[0]) != 3) {
    rb_raise(rb_eArgError, "The array should have 3 items in it");
    return Qnil;
  }

  for (i=0; i < 3; i++) {
    Check_Type(RARRAY_PTR(argv[0])[i], T_FLOAT);
    spoint[i] = NUM2DBL(RARRAY_PTR(argv[0])[i]);
  }

  recrad_c(spoint, &range, &ra, &dec);

  check_spice_error();

  return rb_ary_new3(3, rb_float_new(range), rb_float_new(ra), rb_float_new(dec));
}

+ (Array<Array, Array, Array>) rotate(angle, axis)

Calculate the 3x3 rotation matrix generated by a rotation of a specified angle about a specified axis. This rotation is thought of as rotating the coordinate system.

Parameters:

  • angle (Float)

    (IN RADIANS!)

  • axis (Fixnum)

    Axis of rotation (X=1, Y=2, Z=3).

Returns:

  • (Array<Array, Array, Array>)

    A 3X3 ruby array representing the resulting rotation matrix.

See Also:

Since:

  • 2.19



426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
# File 'ext/spice.c', line 426

VALUE rotate(int argc, VALUE *argv, VALUE self){
  double angle;
  int axis;
  double mout[3][3];

  if (argc != 2){
    rb_raise(rb_eArgError, "Need 2 Parameters!");
    return Qnil;
  }
  Check_Type(argv[0], T_FLOAT);
  Check_Type(argv[1], T_FIXNUM);

  angle = NUM2DBL(argv[0]);
  axis = FIX2INT(argv[1]);

  rotate_c(angle, axis, mout);

  check_spice_error();

  return rb_ary_new3(3, rb_ary_new3(3, rb_float_new(mout[0][0]), rb_float_new(mout[0][1]), rb_float_new(mout[0][2])),  rb_ary_new3(3, rb_float_new(mout[1][0]), rb_float_new(mout[1][1]), rb_float_new(mout[1][2])), rb_ary_new3(3, rb_float_new(mout[2][0]), rb_float_new(mout[2][1]), rb_float_new(mout[2][2])));
}

+ (Float) rpd

Return the number of radians per degree.

Parameters:

  • NONE

Returns:

  • (Float)

    acos(-1.0)/180

See Also:



1847
1848
1849
# File 'ext/spice.c', line 1847

VALUE rpd(VALUE self) {
  return rb_float_new(rpd_c());
}

+ (Float) scde2c(sc, et)

Convert ephemeris seconds past J2000 (ET) to continuous encoded spacecraft clock (`ticks'). Non-integral tick values may be returned.

Parameters:

  • sc (Fixnum)

    NAIF spacecraft ID code.

  • et (Float)

    Ephemeris time, seconds past J2000.

Returns:

  • (Float)

    SCLK, encoded as ticks since spacecraft clock start.

See Also:



2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
# File 'ext/spice.c', line 2554

VALUE sce2c(VALUE self, VALUE sc, VALUE et) {
  double sctk;

  Check_Type(sc, T_FIXNUM);
  Check_Type(et, T_FLOAT);

  sce2c_c(NUM2INT(sc), NUM2DBL(et), &sctk);

  check_spice_error();

  return rb_float_new(sctk);
}

+ (Float) scs2e(sc, sclkch)

Convert a spacecraft clock string to ephemeris seconds past J2000 (ET).

Parameters:

  • sc (Fixnum)

    NAIF integer code for a spacecraft.

  • sclkch (String)

    An SCLK string.

Returns:

  • (Float)

    et-Ephemeris time, seconds past J2000.

See Also:



2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
# File 'ext/spice.c', line 2577

VALUE scs2e(VALUE self, VALUE sc, VALUE sclk) {
  double et;

  Check_Type(sc, T_FIXNUM);
  Check_Type(sclk, T_STRING);

  scs2e_c(NUM2INT(sc), StringValuePtr(sclk), &et);

  check_spice_error();

  return rb_float_new(et);
}

+ (Float) sctiks(sc, clkstr)

Convert a spacecraft clock format string to number of "ticks".

Parameters:

  • sc (Fixnum)

    NAIF spacecraft identification code.

  • clkstr (String)

    Character representation of a spacecraft clock.

Returns:

  • (Float)

    the number of ticks

See Also:



2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
# File 'ext/spice.c', line 2023

VALUE sctiks(VALUE self, VALUE sc, VALUE slkstr) {
  double ticks;

  Check_Type(sc, T_FIXNUM);
  Check_Type(slkstr, T_STRING);

  sctiks_c(NUM2INT(sc), StringValuePtr(slkstr), &ticks);

  check_spice_error();

  return rb_float_new(ticks);
}

+ (nil, Array) sincpt(method, target, et, fixref, abcorr, obsrvr, dref, dvec)

Given an observer and a direction vector defining a ray, compute the surface intercept of the ray on a target body at a specified epoch, optionally corrected for light time and stellar aberration.

Parameters:

  • method (String)

    Computation method.

  • target (String)

    Name of target body.

  • et (Float)

    Epoch in ephemeris seconds past J2000 TDB.

  • fixref (String)

    Body-fixed, body-centered target body frame.

  • abcorr (String)

    Aberration correction. Please see abcorr

  • obsrvr (String)

    Name of observing body.

  • dref (String)

    Reference frame of ray's direction vector.

  • dvec (Array<Float, Float, Float>)

    Ray's direction vector.

Returns:

  • (nil)

    if no intersection is found. Otherwise:

  • (Array)

    A ruby array [[spointX, spointY, spointZ],trgepc,[srfvecX, srfvecY, srfvecZ]]

See Also:



915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
# File 'ext/spice.c', line 915

VALUE sincpt(int argc, VALUE *argv, VALUE self) {
  double spoint[3] = {0.0,0.0,0.0};
  double trgepc;
  double srfvec[3];
  double dvec[3];
  SpiceBoolean found;
  VALUE rb_srfvec, rb_spoint;
  SpiceInt i;

  if (argc != 8) {
    rb_raise(rb_eArgError, "need 7 parameters!");
    return Qnil;
  }

  Check_Type(argv[0], T_STRING);
  Check_Type(argv[1], T_STRING);
  Check_Type(argv[2], T_FLOAT);
  Check_Type(argv[3], T_STRING);
  Check_Type(argv[4], T_STRING);
  Check_Type(argv[5], T_STRING);
  Check_Type(argv[6], T_STRING);
  Check_Type(argv[7], T_ARRAY);

  if (RARRAY_LEN(argv[7]) != 3) {
    rb_raise(rb_eArgError, "The array should have 3 items in it");
    return Qnil;
  }

  for (i=0; i < 3; i++) {
    Check_Type(RARRAY_PTR(argv[7])[i], T_FLOAT);
    dvec[i] = NUM2DBL(RARRAY_PTR(argv[7])[i]);
  }

  sincpt_c(StringValuePtr(argv[0]), StringValuePtr(argv[1]), NUM2DBL(argv[2]), StringValuePtr(argv[3]), StringValuePtr(argv[4]), StringValuePtr(argv[5]), StringValuePtr(argv[6]), dvec, spoint, &trgepc, srfvec, &found);

  if (found == 0) {
    rb_raise(rb_eRuntimeError, "Intercept point not found");
    return Qnil;
  }

  rb_spoint = rb_ary_new();
  for (i=0; i < 3; i++)
    rb_ary_push(rb_spoint, rb_float_new(spoint[i]));

  rb_srfvec = rb_ary_new();
  for (i=0; i < 3; i++)
    rb_ary_push(rb_srfvec, rb_float_new(srfvec[i]));

  check_spice_error();

  return rb_ary_new3(3, rb_spoint, rb_float_new(trgepc), rb_srfvec);
}

+ (Array<Array<Float, Float>>) spkcov(spk, idcode)

Find the coverage window for a specified ephemeris object in a specified SPK file.

Parameters:

  • spk (String, Array<String>)

    name of the spk file, Can be a single spk OR an array of spks

  • idcode (Fixnum)

    is the integer ID code of an object for which ephemeris data are expected to exist in the specified SPK file.

Returns:

  • (Array<Array<Float, Float>>)

    An array of start/end time pairs which the spk covers [[start, end], [start, end]...]

See Also:



665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
# File 'ext/spice.c', line 665

VALUE spkcov(int argc, VALUE *argv, VALUE self) {
  SPICEDOUBLE_CELL (cover, 2000);
  SpiceInt i;
  SpiceInt niv;
  double b, e;
  VALUE result;

  if (argc != 2) {
    rb_raise(rb_eArgError, "We need two args!");
    return Qnil;
  }

 
  if (TYPE(argv[0]) != T_STRING && TYPE(argv[0]) != T_ARRAY) {
    rb_raise(rb_eArgError, "gimme some spks!");
    return Qnil;
  }

  Check_Type(argv[1], T_FIXNUM);

  scard_c(0, &cover);

  if (TYPE(argv[0]) == T_STRING) {
    spkcov_c(StringValuePtr(argv[0]), FIX2INT(argv[1]), &cover);
  } else {
    for (i=0; i < RARRAY_LEN(argv[0]); i++)
      spkcov_c(StringValuePtr(RARRAY_PTR(argv[0])[i]), FIX2INT(argv[1]), &cover);
  }

  niv = wncard_c(&cover);

  if (niv == 0)
    return Qnil;

  result = rb_ary_new2(niv);

  for (i = 0; i < niv; i++) {
    wnfetd_c(&cover, i, &b, &e);
    printf("%f %f\n",b, e);
    rb_ary_push(result, rb_ary_new3(2, INT2FIX(b), INT2FIX(e)));
  }
  /*build up an array of arrays with start/end time pairs*/

  check_spice_error();

  return result;
}

+ (Array<Array<Float, Float, Float>, Float>) spkezp(targ, et, ref, abcorr, obs)

Return the position of a target body relative to an observing body, optionally corrected for light time (planetary aberration) and stellar aberration.

Parameters:

  • targ (Fixnum)

    Target body NAIF ID code.

  • et (Float)

    Observer epoch.

  • ref (String)

    Reference frame of output position vector.

  • abcorr (String)

    Aberration correction flag. Please see abcorr

  • obs (Fixnum)

    Observing body NAIF ID code.

Returns:

  • (Array<Array<Float, Float, Float>, Float>)

    A ruby array containing the position vector, and light time between obs and targ [[ptargX, ptargY, ptargZ], lt]

See Also:



1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
# File 'ext/spice.c', line 1619

VALUE spkezp(int argc, VALUE *argv, VALUE self) {
  double ptarg[3] = {0.0,0.0,0.0};
  double lt;
  VALUE rb_ptarg;
  SpiceInt i;

  if (argc != 5) {
    rb_raise(rb_eArgError, "need 5 parameters!");
    return Qnil;
  }

  Check_Type(argv[0], T_FIXNUM);
  Check_Type(argv[1], T_FLOAT);
  Check_Type(argv[2], T_STRING);
  Check_Type(argv[3], T_STRING);
  Check_Type(argv[4], T_FIXNUM);

  spkezp_c(FIX2INT(argv[0]), NUM2DBL(argv[1]), StringValuePtr(argv[2]), StringValuePtr(argv[3]), FIX2INT(argv[4]), ptarg, &lt);

  rb_ptarg = rb_ary_new();
  for (i=0; i < 3; i++)
    rb_ary_push(rb_ptarg, rb_float_new(ptarg[i]));

  check_spice_error();

  return rb_ary_new3(2, rb_ptarg, rb_float_new(lt));
}

+ (Array<Array<Float, Float, Float>, Float>) spkezr(targ, et, ref, abcorr, obs)

Return the state (position and velocity) of a target body relative to an observing body, optionally corrected for light time (planetary aberration) and stellar aberration.

Parameters:

  • targ (String)

    Target body name.

  • et (Float)

    Observer epoch.

  • ref (String)

    Reference frame of output state vector.

  • abcorr (String)

    Aberration correction flag. Please see abcorr

  • obs (String)

    Observing body name.

Returns:

  • (Array<Array<Float, Float, Float>, Float>)

    A ruby array, containing the State Vector, and light time between obs and targ [[x, y, z, vx, vy, vz], lt]

See Also:



1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
# File 'ext/spice.c', line 1665

VALUE spkezr(int argc, VALUE *argv, VALUE self) {
  double starg[6] = {0.0,0.0,0.0,0.0,0.0,0.0};
  double lt;
  VALUE rb_starg;
  SpiceInt i;

  if (argc != 5) {
    rb_raise(rb_eArgError, "need 5 parameters!");
    return Qnil;
  }

  Check_Type(argv[0], T_STRING);
  Check_Type(argv[1], T_FLOAT);
  Check_Type(argv[2], T_STRING);
  Check_Type(argv[3], T_STRING);
  Check_Type(argv[4], T_STRING);

  spkezr_c(StringValuePtr(argv[0]), NUM2DBL(argv[1]), StringValuePtr(argv[2]), StringValuePtr(argv[3]), StringValuePtr(argv[4]), starg, &lt);

  rb_starg = rb_ary_new();
  for (i=0; i < 6; i++)
    rb_ary_push(rb_starg, rb_float_new(starg[i]));

  check_spice_error();

  return rb_ary_new3(2, rb_starg, rb_float_new(lt));
}

+ (Array<Float, Float, Float>, Float) spkpos(targ, et, ref, abcorr, obs)

Return the position of a target body relative to an observing body, optionally corrected for light time (planetary aberration) and stellar aberration.

Parameters:

  • targ (String)

    Target body name.

  • et (Float)

    Observer epoch.

  • ref (String)

    Reference frame of output position vector.

  • abcorr (String)

    Aberration correction flag. See abcorr

  • obs (String)

    Observing body name.

Returns:

  • (Array<Float, Float, Float>, Float)

    A ruby array containing the target position vector and One way light time between observer and target. [[X, Y, Z], lt]

See Also:



2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
# File 'ext/spice.c', line 2749

VALUE spkpos(VALUE self, VALUE rb_targ, VALUE rb_et, VALUE rb_ref, VALUE rb_abcorr, VALUE rb_obs) {
  SpiceDouble ptarg[3], lt;

  Check_Type(rb_targ, T_STRING);
  Check_Type(rb_et, T_FLOAT);
  Check_Type(rb_ref, T_STRING);
  Check_Type(rb_abcorr, T_STRING);
  Check_Type(rb_obs, T_STRING);

  spkpos_c(StringValuePtr(rb_targ), NUM2DBL(rb_et), StringValuePtr(rb_ref), StringValuePtr(rb_abcorr), StringValuePtr(rb_obs), ptarg, &lt);

  check_spice_error();

  return rb_ary_new3(2, rb_ary_new3(3, rb_float_new(ptarg[0]), rb_float_new(ptarg[1]), rb_float_new(ptarg[2])), rb_float_new(lt));
}

+ (Float) str2et(time)

Convert a string representing an epoch to a double precision value representing the number of TDB seconds past the J2000 epoch corresponding to the input epoch.

Parameters:

  • time (String)

    a time string

Returns:

  • (Float)

    et

See Also:



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'ext/spice.c', line 196

VALUE str2et(int argc, VALUE *argv, VALUE self) {
  double et;

  if (argc != 1) {
    rb_raise(rb_eArgError, "need one parameter, the time string");
    return Qnil;
  }

  Check_Type(argv[0], T_STRING);

  str2et_c(StringValuePtr(argv[0]), &et);

  check_spice_error();

  return rb_float_new(et);
}

+ (Array<Array<Float, Float, Float>, Float, Array<Float, Float, Float>>) subpnt(method, target, et, fixref, abcorr, obsrvr)

Compute the rectangular coordinates of the sub-observer point on a target body at a specified epoch, optionally corrected for light time and stellar aberration.

Parameters:

  • method (String)

    Computation method. EX: "Near point: ellipsoid" or "Intercept: ellipsoid"

  • target (String)

    Name of target body. EX: "MOON"

  • et (Float)

    Epoch in ephemeris seconds past J2000 TDB.

  • fixref (String)

    Body-fixed, body-centered target body frame. EX: "iau_moon"

  • abcorr (String)

    Aberration correction. Please see abcorr

  • obsrvr (String)

    Name of observing body. EX: "LRO"

Returns:

  • (Array<Array<Float, Float, Float>, Float, Array<Float, Float, Float>>)

    A Ruby array [[spointX, spointY, spointZ], trgepc, [srfvecX, srfvecY, srfvecZ]]

  • spoint = [X, Y, Z] Sub-observer point on the target body.

  • trgepc = Sub-observer point epoch.

  • srfvec = [X, Y, Z] Vector from observer to sub-observer point.

See Also:



240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'ext/spice.c', line 240

VALUE subpnt(int argc, VALUE *argv, VALUE self) {
  VALUE result = Qnil;
  double spoint[3];
  double trgepc;
  double srfvec[3];
  VALUE rb_spoint, rb_srfvec;
  SpiceInt i;

  if (argc != 6) {
    rb_raise(rb_eArgError, "need 6 parameters!");
    return Qnil;
  }

  Check_Type(argv[0], T_STRING);
  Check_Type(argv[1], T_STRING);
  Check_Type(argv[2], T_FLOAT);
  Check_Type(argv[3], T_STRING);
  Check_Type(argv[4], T_STRING);
  Check_Type(argv[5], T_STRING);

  subpnt_c(StringValuePtr(argv[0]), StringValuePtr(argv[1]), NUM2DBL(argv[2]), StringValuePtr(argv[3]), StringValuePtr(argv[4]), StringValuePtr(argv[5]), spoint, &trgepc, srfvec);

  rb_spoint = rb_ary_new();
  for (i=0; i < 3; i++)
    rb_ary_push(rb_spoint, rb_float_new(spoint[i]));

  rb_srfvec = rb_ary_new();
  for (i=0; i < 3; i++)
    rb_ary_push(rb_srfvec, rb_float_new(srfvec[i]));

  result = rb_ary_new();
  rb_ary_push(result, rb_spoint);
  rb_ary_push(result, rb_float_new(trgepc));
  rb_ary_push(result, rb_srfvec);

  check_spice_error();

  return result;
}

+ (Array<Array<Float, Float, Float>, Float, Array<Float, Float, Float>>) subslr(method, target, et, fixref, abcorr, obsrvr)

Compute the rectangular coordinates of the sub-solar point on a target body at a specified epoch, optionally corrected for light time and stellar aberration.

Parameters:

  • method (String)

    Computation method. EX: "Near point: ellipsoid" or "Intercept: ellipsoid"

  • target (String)

    Name of target body. EX: "MOON"

  • et (Float)

    Epoch in ephemeris seconds past J2000 TDB.

  • fixref (String)

    Body-fixed, body-centered target body frame. EX: "iau_moon"

  • abcorr (String)

    Aberration correction. Please see abcorr

  • obsrvr (String)

    Name of observing body. EX: "LRO"

Returns:

  • (Array<Array<Float, Float, Float>, Float, Array<Float, Float, Float>>)

    a ruby array [[spointX, spointY, spointZ], trgepc, [srfvecX, srfvecY, srfvecZ]]

  • spoint = [X, Y, Z] Sub-observer point on the target body.

  • trgepc = Sub-observer point epoch.

  • srfvec = [X, Y, Z] Vector from observer to sub-solar point.

See Also:



845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
# File 'ext/spice.c', line 845

VALUE subslr(int argc, VALUE *argv, VALUE self) {
  VALUE result = Qnil;
  double spoint[3];
  double trgepc;
  double srfvec[3];
  VALUE rb_spoint, rb_srfvec;
  SpiceInt i;

  if (argc != 6) {
    rb_raise(rb_eArgError, "need 6 parameters!");
    return Qnil;
  }

  Check_Type(argv[0], T_STRING);
  Check_Type(argv[1], T_STRING);
  Check_Type(argv[2], T_FLOAT);
  Check_Type(argv[3], T_STRING);
  Check_Type(argv[4], T_STRING);
  Check_Type(argv[5], T_STRING);

  subslr_c(StringValuePtr(argv[0]), StringValuePtr(argv[1]), NUM2DBL(argv[2]), StringValuePtr(argv[3]), StringValuePtr(argv[4]), StringValuePtr(argv[5]), spoint, &trgepc, srfvec);

  rb_spoint = rb_ary_new();
  for (i=0; i < 3; i++)
    rb_ary_push(rb_spoint, rb_float_new(spoint[i]));

  rb_srfvec = rb_ary_new();
  for (i=0; i < 3; i++)
    rb_ary_push(rb_srfvec, rb_float_new(srfvec[i]));

  result = rb_ary_new();
  rb_ary_push(result, rb_spoint);
  rb_ary_push(result, rb_float_new(trgepc));
  rb_ary_push(result, rb_srfvec);

  check_spice_error();

  return result;
}

+ (Array<Array<Float, Float, Float, Float, Float, Float>[6]>) sxform(from, to, et)

Return the state transformation matrix from one frame to another at a specified epoch.

Parameters:

  • from (String)

    Name of the frame to transform from.

  • to (String)

    Name of the frame to transform to.

  • et (Float)

    Epoch of the state transformation matrix.

Returns:

  • (Array<Array<Float, Float, Float, Float, Float, Float>[6]>)

    A ruby array [6] [6] representing the state transformation matrix.

See Also:



2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
# File 'ext/spice.c', line 2603

VALUE sxform(VALUE self, VALUE from, VALUE to, VALUE et) {
  double cmat[6][6];

  Check_Type(from, T_STRING);
  Check_Type(to, T_STRING);
  Check_Type(et, T_FLOAT);

  sxform_c(StringValuePtr(from), StringValuePtr(to), NUM2DBL(et), cmat);

  check_spice_error();

  return rb_ary_new3(6, rb_ary_new3(6, rb_float_new(cmat[0][0]), rb_float_new(cmat[0][1]), rb_float_new(cmat[0][2]), rb_float_new(cmat[0][3]), rb_float_new(cmat[0][4]), rb_float_new(cmat[0][5])),
			rb_ary_new3(6, rb_float_new(cmat[1][0]), rb_float_new(cmat[1][1]), rb_float_new(cmat[1][2]), rb_float_new(cmat[1][3]), rb_float_new(cmat[1][4]), rb_float_new(cmat[1][5])),
			rb_ary_new3(6, rb_float_new(cmat[2][0]), rb_float_new(cmat[2][1]), rb_float_new(cmat[2][2]), rb_float_new(cmat[2][3]), rb_float_new(cmat[2][4]), rb_float_new(cmat[2][5])),
			rb_ary_new3(6, rb_float_new(cmat[3][0]), rb_float_new(cmat[3][1]), rb_float_new(cmat[3][2]), rb_float_new(cmat[3][3]), rb_float_new(cmat[3][4]), rb_float_new(cmat[3][5])),
			rb_ary_new3(6, rb_float_new(cmat[4][0]), rb_float_new(cmat[4][1]), rb_float_new(cmat[4][2]), rb_float_new(cmat[4][3]), rb_float_new(cmat[4][4]), rb_float_new(cmat[4][5])),
			rb_ary_new3(6, rb_float_new(cmat[5][0]), rb_float_new(cmat[5][1]), rb_float_new(cmat[5][2]), rb_float_new(cmat[5][3]), rb_float_new(cmat[5][4]), rb_float_new(cmat[5][5])));
}

+ (Array<Float, Float, Float>) ucrss(v1, v2)

Compute the normalized cross product of two 3-vectors.

Parameters:

  • v1 (Array<Float, Float, Float>)

    Left vector for cross product.

  • v2 (Array<Float, Float, Float>)

    Right vector for cross product.

Returns:

  • (Array<Float, Float, Float>)

    a 3 item ruby array representing the Normalized cross product (v1xv2) / |v1xv2|.

See Also:



1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
# File 'ext/spice.c', line 1927

VALUE ucrss(VALUE self, VALUE rb_v1, VALUE rb_v2) {
  double v1[3], v2[3], vd[3];
  SpiceInt i;

  Check_Type(rb_v1, T_ARRAY);
  Check_Type(rb_v2, T_ARRAY);
  
  for(i = 0; i < 3; i++) {
    Check_Type(RARRAY_PTR(rb_v1)[i], T_FLOAT);
    Check_Type(RARRAY_PTR(rb_v2)[i], T_FLOAT);
    v1[i] = NUM2DBL(RARRAY_PTR(rb_v1)[i]);
    v2[i] = NUM2DBL(RARRAY_PTR(rb_v2)[i]);
  }

  ucrss_c(v1, v2, vd);

  check_spice_error();

  return rb_ary_new3(3, rb_float_new(vd[0]), rb_float_new(vd[1]), rb_float_new(vd[2]));
}

+ (Fixnum) unload(file, file...)

Unload a SPICE kernel

Parameters:

  • file (String)

    Path to a Spice Kernel, can be a single kernel or .mk file

Returns:

  • (Fixnum)

    the number of kernels unloaded

See Also:



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'ext/spice.c', line 114

VALUE unload(int argc, VALUE *argv, VALUE self) {
  SpiceInt i;
  SpiceInt numkernels;

  block_signals();

  if (argc == 0) {
    rb_raise(rb_eArgError, "unload needs kernels!");
  } else {
    for(i=0; i < argc; i++) {
      Check_Type(argv[i], T_STRING);
    }
  }

  for(i=0; i < argc; i++) {
    unload_c(StringValuePtr(argv[i]));
  }

  ktotal_c("ALL", &numkernels);

  restore_signals();

  check_spice_error();

  return INT2FIX(numkernels);
}

+ (Array<Float, Float, Float>) vcrss(v1, v2)

Compute the cross product of two 3-dimensional vectors.

Parameters:

  • v1 (Array<Float, Float, Float>)

    Left hand vector for cross product.

  • v2 (Array<Float, Float, Float>)

    Right hand vector for cross product.

Returns:

  • (Array<Float, Float, Float>)

    a 3 item ruby array representing the Cross product v1xv2.

See Also:



1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
# File 'ext/spice.c', line 1961

VALUE vcrss(VALUE self, VALUE rb_v1, VALUE rb_v2) {
  double v1[3], v2[3], vd[3];
  SpiceInt i;

  Check_Type(rb_v1, T_ARRAY);
  Check_Type(rb_v2, T_ARRAY);
  
  for(i = 0; i < 3; i++) {
    Check_Type(RARRAY_PTR(rb_v1)[i], T_FLOAT);
    Check_Type(RARRAY_PTR(rb_v2)[i], T_FLOAT);
    v1[i] = NUM2DBL(RARRAY_PTR(rb_v1)[i]);
    v2[i] = NUM2DBL(RARRAY_PTR(rb_v2)[i]);
  }

  vcrss_c(v1, v2, vd);

  check_spice_error();

  return rb_ary_new3(3, rb_float_new(vd[0]), rb_float_new(vd[1]), rb_float_new(vd[2]));
}

+ (Float) vdist(v1, v2)

Return the distance between two three-dimensional vectors.

Parameters:

  • v1 (Array<Float, Float, Float>)

    passed as a 3 item ruby array [x, y, z]

  • v2 (Array<Float, Float, Float>)

    passed as a 3 item ruby array [x, y, z]

Returns:

  • (Float)

    the distance

See Also:



1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
# File 'ext/spice.c', line 1705

VALUE vdist(VALUE self, VALUE v1, VALUE v2) {
  double vec1[3], vec2[3], res;
  SpiceInt i;

  Check_Type(v1, T_ARRAY);
  Check_Type(v2, T_ARRAY);

  if (RARRAY_LEN(v1) != 3) {
    rb_raise(rb_eArgError, "The array should have 3 items in it");
    return Qnil;
  }

  if (RARRAY_LEN(v2) != 3) {
    rb_raise(rb_eArgError, "The array should have 3 items in it");
    return Qnil;
  }

  for (i=0; i < 3; i++) {
    Check_Type(RARRAY_PTR(v1)[i], T_FLOAT);
    vec1[i] = NUM2DBL(RARRAY_PTR(v1)[i]);
  }

  for (i=0; i < 3; i++) {
    Check_Type(RARRAY_PTR(v2)[i], T_FLOAT);
    vec2[i] = NUM2DBL(RARRAY_PTR(v2)[i]);
  }

  res = vdist_c(vec1, vec2);

  check_spice_error();

  return rb_float_new(res);
}

+ (Float) vdot(v1, v2)

Compute the dot product of two double precision, 3-dimensional vectors.

Parameters:

  • v1 (Array<Float, Float, Float>)

    First vector in the dot product.

  • v2 (Array<Float, Float, Float>)

    Second vector in the dot product.

Returns:

  • (Float)

    the value of the dot product of v1 and v2.

See Also:



1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
# File 'ext/spice.c', line 1992

VALUE vdot(VALUE self, VALUE rb_v1, VALUE rb_v2) {
  double v1[3], v2[3], res;
  SpiceInt i;

  Check_Type(rb_v1, T_ARRAY);
  Check_Type(rb_v2, T_ARRAY);
  
  for(i = 0; i < 3; i++) {
    Check_Type(RARRAY_PTR(rb_v1)[i], T_FLOAT);
    Check_Type(RARRAY_PTR(rb_v2)[i], T_FLOAT);
    v1[i] = NUM2DBL(RARRAY_PTR(rb_v1)[i]);
    v2[i] = NUM2DBL(RARRAY_PTR(rb_v2)[i]);
  }

  res = vdot_c(v1, v2);

  check_spice_error();

  return rb_float_new(res);
}

+ (Float) vnorm(v1)

Compute the magnitude of a double precision, 3-dimensional vector.

Examples:

vector = 1,2,3
mag = vnorm(vector)

Parameters:

  • v1 (Array<Float, Float, Float>)

    Vector whose magnitude is to be found.

Returns:

  • (Float)

    the magnitude of the vector

See Also:



507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'ext/spice.c', line 507

VALUE vnorm(int argc, VALUE *argv, VALUE self) {
  double srfvec[3], res;
  SpiceInt i;

  if (argc != 1) {
    rb_raise(rb_eArgError, "Need just 1 parameter");
    return Qnil;
  }

  Check_Type(argv[0], T_ARRAY);

  if (RARRAY_LEN(argv[0]) != 3) {
    rb_raise(rb_eArgError, "The array should have 3 items in it");
    return Qnil;
  }

  for (i=0; i < 3; i++) {
    Check_Type(RARRAY_PTR(argv[0])[i], T_FLOAT);
    srfvec[i] = NUM2DBL(RARRAY_PTR(argv[0])[i]);
  }

  res = vnorm_c(srfvec);

  check_spice_error();

  return rb_float_new(res);
}

+ (Array<Float, Float, Float>) vperp(v1, v2)

Find the component of a vector that is perpendicular to a second vector.

Parameters:

  • v1 (Array<Float, Float, Float>)

    The vector whose orthogonal component is sought.

  • v2 (Array<Float, Float, Float>)

    The vector used as the orthogonal reference.

Returns:

  • (Array<Float, Float, Float>)

    A Ruby Array representing the component of a orthogonal to b.

See Also:



548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
# File 'ext/spice.c', line 548

VALUE vperp(VALUE self, VALUE v1, VALUE v2) {
  double vec1[3], vec2[3], result[3];
  SpiceInt i;

  Check_Type(v1, T_ARRAY);
  Check_Type(v2, T_ARRAY);

  if (RARRAY_LEN(v1) != 3) {
    rb_raise(rb_eArgError, "The array should have 3 items in it");
    return Qnil;
  }
  if (RARRAY_LEN(v2) != 3) {
    rb_raise(rb_eArgError, "The array should have 3 items in it");
    return Qnil;
  }

  for (i=0; i < 3; i++) {
    Check_Type(RARRAY_PTR(v1)[i], T_FLOAT);
    vec1[i] = NUM2DBL(RARRAY_PTR(v1)[i]);
  }
  for (i=0; i < 3; i++) {
    Check_Type(RARRAY_PTR(v2)[i], T_FLOAT);
    vec2[i] = NUM2DBL(RARRAY_PTR(v2)[i]);
  }

  vperp_c(vec1, vec2, result);

  check_spice_error();

  return rb_ary_new3(3, rb_float_new(result[0]), rb_float_new(result[1]), rb_float_new(result[2]));
}

+ (Float) vsep(v1, v2)

Find the separation angle in radians between two double precision, 3-dimensional vectors. This angle is defined as zero if either vector is zero.

Parameters:

  • v1 (Array<Float, Float, Float>)

    first vector passed in as a 3 item ruby array

  • v2 (Array<Float, Float, Float>)

    second vector passed in as a 3 item ruby array

Returns:

  • (Float)

    the seperation angle in radians

See Also:



2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
# File 'ext/spice.c', line 2050

VALUE vsep(VALUE self, VALUE rb_v1, VALUE rb_v2) {
  double v1[3], v2[3], res;
  SpiceInt i;

  Check_Type(rb_v1, T_ARRAY);
  Check_Type(rb_v2, T_ARRAY);
  
  for(i = 0; i < 3; i++) {
    Check_Type(RARRAY_PTR(rb_v1)[i], T_FLOAT);
    Check_Type(RARRAY_PTR(rb_v2)[i], T_FLOAT);
    v1[i] = NUM2DBL(RARRAY_PTR(rb_v1)[i]);
    v2[i] = NUM2DBL(RARRAY_PTR(rb_v2)[i]);
  }

  res = vsep_c(v1, v2);

  check_spice_error();

  return rb_float_new(res);
}

+ (Array<Float, Float, Float>) vsub(v1, v2)

Compute the difference between two 3-dimensional, double precision vectors.

Parameters:

  • v1 (Array<Float, Float, Float>)

    First vector (minuend). passed in as a 3 item ruby array [X, Y, Z]

  • v2 (Array<Float, Float, Float>)

    Second vector (subtrahend). passed in as a 3 item ruby array [X, Y, Z]

Returns:

  • (Array<Float, Float, Float>)

    A 3 item ruby array representing the difference vector

See Also:



1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
# File 'ext/spice.c', line 1892

VALUE vsub(VALUE self, VALUE rb_v1, VALUE rb_v2) {
  double v1[3], v2[3], vd[3];
  SpiceInt i;

  Check_Type(rb_v1, T_ARRAY);
  Check_Type(rb_v2, T_ARRAY);
  
  for(i = 0; i < 3; i++) {
    Check_Type(RARRAY_PTR(rb_v1)[i], T_FLOAT);
    Check_Type(RARRAY_PTR(rb_v2)[i], T_FLOAT);
    v1[i] = NUM2DBL(RARRAY_PTR(rb_v1)[i]);
    v2[i] = NUM2DBL(RARRAY_PTR(rb_v2)[i]);
  }

  vsub_c(v1, v2, vd);

  check_spice_error();

  return rb_ary_new3(3, rb_float_new(vd[0]), rb_float_new(vd[1]), rb_float_new(vd[2]));
}

+ (Array<Array<Fixnum, Fixnum>>) wn2rb(window)

Returns An array of window arrays [ [beg, end], [beg, end]…]

Parameters:

  • window (DATA)

    Spice window

Returns:

  • (Array<Array<Fixnum, Fixnum>>)

    An array of window arrays [ [beg, end], [beg, end]...]



2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
# File 'ext/spice.c', line 2848

VALUE wn2rb (VALUE self, VALUE window) {
	int niv, i;
	VALUE result;
	double beg, end;
	SpiceCell *ptr;

	Check_Type(window, T_DATA);
	Data_Get_Struct(window, SpiceCell, ptr);


	niv = wncard_c(ptr);
	if (niv == 0)
		return Qnil;

	result = rb_ary_new2(niv);

	for (i = 0; i < niv; i++){
		wnfetd_c(ptr, i, &beg, &end);
		rb_ary_push(result, rb_ary_new3(2, INT2FIX(beg), INT2FIX(end)));
	}

	return result;
}

+ (Object) wninsd(left, right)

Insert an interval into a double precision window.

Parameters:

  • left (Float)

    Left endpoint of new interval (et).

  • right (Float)

    Right endpoint of new interval (et).

Returns:

  • A pointer to the SpiceCell containing the window

  • This can then be passed into functions which require a spiceWindow

See Also:



2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
# File 'ext/spice.c', line 2781

VALUE wninsd (int argc, VALUE *argv, VALUE self) {
	VALUE rb_window;
	VALUE class = 0;
	SpiceCell *ptr = 0;
	SPICEDOUBLE_CELL (window, 5000);
	if (argc < 2 || argc > 3){
		rb_raise(rb_eArgError, "need 2 parameters!");
		return Qnil;
	}


	/*        !!!!!! Not ready to lose this bit incase we decide to rework 
	 *        !!!!!! Window handling at a later date to work on osX
	 *        !!!!!! This sets up a usable SpiceDouble Cell without using
	 *        !!!!!! the NAIF marcos, which do some invisible magic
	 *        !!!!!! alicht@ser.asu.edu
	 *	//The extra 6's in here are defined in Spice_cel.h they 
	 *	//they are used to hold "spice cell control parameters
	 *	//In the case of DP cells, the only one set is [4], it's 
	 *	//set to the size of the cell minus the ctrl size (ie 5006 - 6 = 5000)
	 *        SpiceCell *window = malloc(sizeof(SpiceCell));
	 *        SpiceDouble windowArr[5006];
	 *        memset(windowArr, 0, 5006);
	 *
	 *        windowArr[4] = 5000;
	 *        window->dtype = SPICE_DP;
	 *        window->length = 0;
	 *        window->size = 5000;
	 *        window->card = SPICETRUE;
	 *        window->isSet = SPICEFALSE;
	 *        window->adjust = SPICEFALSE;
	 *        window->base = (void *)windowArr;
	 *        window->data = (void *)(&((SpiceDouble *) window->base)[6]);
	 */

	Check_Type(argv[0], T_FLOAT);
	Check_Type(argv[1], T_FLOAT);
	if ( argc == 3) {
          Check_Type(argv[2], T_DATA);
          Data_Get_Struct(argv[2], SpiceCell, ptr);
	  wninsd_c( NUM2DBL(argv[0]), NUM2DBL(argv[1]), ptr);
	}

	  wninsd_c( NUM2DBL(argv[0]), NUM2DBL(argv[1]), &window );

	check_spice_error();
        /*
	 *A spice cell is just a struct full of primitive types wrapped 
	 *around an array of the spice_type, an array of doubles in this 
	 *case
         */
	if (argc == 2)
	  rb_window = Data_Wrap_Struct(class, 0, 0, &window);
	else
	  rb_window = Data_Wrap_Struct(class, 0, 0, ptr);

	return rb_window;
}

+ (Array<Float>, Boolean) xf2eul(xform, axisa, axisb, axisc)

Convert a state transformation matrix to Euler angles and their derivatives with respect to a specified set of axes.

Parameters:

  • xform (Array<Array>)

    A state transformation matrix. passed in by a 6x6 ruby array [6] [6]

  • axisa (Fixnum)

    Axis A of the Euler angle factorization.

  • axisb (Fixnum)

    Axis B of the Euler angle factorization.

  • axisc (Fixnum)

    Axis C of the Euler angle factorization.

Returns:

  • (Array<Float>, Boolean)

    A ruby array contatining (An array of Euler angles and their derivatives) and wether or not it is a unique representation(true|false)

See Also:



2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
# File 'ext/spice.c', line 2303

VALUE xf2eul(VALUE self, VALUE rb_cmat, VALUE rb_axisa, VALUE rb_axisb, VALUE rb_axisc) {
  double cmat[6][6];
  double eulang[6];
  SpiceBoolean unique;
  SpiceInt i, j;
  VALUE rb_unique;

  if (RARRAY_LEN(rb_cmat) != 6) {
    rb_raise(rb_eArgError, "cmat should be 6x6");
    return Qnil;
  }

  for(i = 0; i < 6; i++) {
    if (RARRAY_LEN(RARRAY_PTR(rb_cmat)[i]) != 6) {
      rb_raise(rb_eArgError, "cmat should be 6x6.");
      return Qnil;
    }

    for(j = 0; j < 6; j++) {
      Check_Type(RARRAY_PTR(RARRAY_PTR(rb_cmat)[i])[j], T_FLOAT);
      cmat[i][j] = NUM2DBL(RARRAY_PTR(RARRAY_PTR(rb_cmat)[i])[j]);
    }
  }

  xf2eul_c((const double(*)[6])cmat, NUM2INT(rb_axisa), NUM2INT(rb_axisb), NUM2INT(rb_axisc), eulang, &unique);

  check_spice_error();

  if (unique == SPICETRUE)
    rb_unique = Qtrue;
  else
    rb_unique = Qfalse;

  return rb_ary_new3(2, rb_ary_new3(6, rb_float_new(eulang[0]), rb_float_new(eulang[1]), rb_float_new(eulang[2]), rb_float_new(eulang[3]), rb_float_new(eulang[4]), rb_float_new(eulang[5])), rb_unique);
}

Instance Method Details

- (Array) wndifd(one, two)

Takes the difference between two 'ruby spice windows'

cspice functions which return spice windows return a 2d array of windows in ruby spice

that is: [[beg, end], ... , [beg, end]]

Parameters:

  • one (Array)
  • two (Array)

Returns:

  • (Array)

    Everything in window one, but NOT in window two



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/spice_utils.rb', line 142

def wndifd one,two
  unless (one.kind_of?(Array) and two.kind_of?(Array))
    raise ArgumentError
  end
  return one if two.length == 0
  return []  if one.length == 0

  ret = []
  result = []
  one.each do |a|
    a_rng = (a[0]..a[1]) #first
    r =  a_rng.intersection(0..two[0][0])
    ret << r unless r.nil?
    (0...two.size-1).each do |b|

      r = a_rng.intersection(two[b][1]..two[b+1][0])
      ret << r unless r.nil?

    end
    r = a_rng.intersection(two.last.last..a[1]) #last
    ret << r unless r.nil?
  end
  ret.each {|range| result << [range.begin, range.end]}
  result
end