swe4r 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/ext/swe4r/swe4r.c +35 -0
  2. metadata +2 -2
@@ -174,6 +174,40 @@ static VALUE t_swe_calc_ut(VALUE self, VALUE julian_ut, VALUE body, VALUE iflag)
174
174
  return arr;
175
175
  }
176
176
 
177
+ /*
178
+ * Compute fixed stars
179
+ * http://www.astro.com/swisseph/swephprg.htm#_Toc354479413
180
+ long swe_fixstar_ut(
181
+ char* star, // The traditional name, nomenclature name, or line number of star in fixstars.cat (see modes below for further details)
182
+ double tjd_ut, // Julian day number, Universal Time
183
+ long iflag, // flag bits
184
+ double* xx, // target address for 6 position values: longitude, latitude, distance, long.speed, lat.speed, dist.speed
185
+ char* serr // 256 bytes for error string
186
+ );
187
+
188
+ * The function has three modes to search for a star in the file fixstars.cat:
189
+ · star contains a positive number ( in ASCII string format, e.g. "234"): The 234-th non-comment line in the file fixstars.cat is used. Comment lines begin with # and are ignored.
190
+ · star contains a traditional name: the first star in the file fixstars.cat is used whose traditional name fits the given name. All names are mapped to lower case before comparison. If star has n characters, only the first n characters of the traditional name field are compared. If a comma appears after a non-zero-length traditional name, the traditional name is cut off at the comma before the search. This allows the reuse of the returned star name from a previous call in the next call.
191
+ · starbegins with a comma, followed by a nomenclature name, e.g. ",alTau": the star with this name in the nomenclature field ( the second field ) is returned. Letter case is observed in the comparison for nomenclature names.
192
+ */
193
+ static VALUE t_swe_fixstar_ut(VALUE self, VALUE star, VALUE julian_ut, VALUE iflag) {
194
+ double results[6];
195
+ char serr[AS_MAXCH];
196
+ VALUE arr = rb_ary_new();
197
+ int id_push = rb_intern("push");
198
+ int i=0;
199
+
200
+ if ( swe_fixstar_ut(StringValuePtr(star), NUM2DBL(julian_ut), NUM2LONG(iflag), results, serr) < 0 )
201
+ rb_raise (rb_eRuntimeError, serr);
202
+
203
+ for ( i = 0; i < 6; i++)
204
+ rb_funcall(arr, id_push, 1, rb_float_new(results[i]));
205
+
206
+ return arr;
207
+
208
+ }
209
+
210
+
177
211
  /*
178
212
  * This function can be used to specify the mode for sidereal computations
179
213
  * http://www.astro.com/swisseph/swephprg.htm#_Toc283735478
@@ -260,6 +294,7 @@ void Init_swe4r()
260
294
  rb_define_module_function(rb_mSwe4r, "swe_julday", t_swe_julday, 4);
261
295
  rb_define_module_function(rb_mSwe4r, "swe_set_topo", t_swe_set_topo, 3);
262
296
  rb_define_module_function(rb_mSwe4r, "swe_calc_ut", t_swe_calc_ut, 3);
297
+ rb_define_module_function(rb_mSwe4r, "swe_fixstar_ut", t_swe_fixstar_ut, 3);
263
298
  rb_define_module_function(rb_mSwe4r, "swe_set_sid_mode", t_swe_set_sid_mode, 3);
264
299
  rb_define_module_function(rb_mSwe4r, "swe_get_ayanamsa_ut", t_swe_get_ayanamsa_ut, 1);
265
300
  rb_define_module_function(rb_mSwe4r, "swe_houses", t_swe_houses, 4);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swe4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-14 00:00:00.000000000Z
12
+ date: 2012-05-10 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: A C extension for the Swiss Ephemeris library (http://www.astro.com/swisseph/)
15
15
  email: andrew.kirk@windhorsemedia.com