Module: AstroChart::Ext
- Defined in:
- ext/astro_chart/astro_chart_ext.c
Constant Summary collapse
- SUN =
Planet ID constants
INT2NUM(SE_SUN)
- MOON =
INT2NUM(SE_MOON)
- MERCURY =
INT2NUM(SE_MERCURY)
- VENUS =
INT2NUM(SE_VENUS)
- MARS =
INT2NUM(SE_MARS)
- JUPITER =
INT2NUM(SE_JUPITER)
- SATURN =
INT2NUM(SE_SATURN)
- URANUS =
INT2NUM(SE_URANUS)
- NEPTUNE =
INT2NUM(SE_NEPTUNE)
- PLUTO =
INT2NUM(SE_PLUTO)
- TRUE_NODE =
INT2NUM(SE_TRUE_NODE)
Class Method Summary collapse
-
.calc_ut(jd, planet_id) ⇒ Object
AstroChart::Ext.calc_ut(jd, planet_id) -> Float.
-
.houses(jd, lat, lon, hsys) ⇒ Object
AstroChart::Ext.houses(jd, latitude, longitude, system) -> Hash.
-
.julday(year, month, day, hour) ⇒ Object
AstroChart::Ext.julday(year, month, day, hour) -> Float.
Class Method Details
.calc_ut(jd, planet_id) ⇒ Object
AstroChart::Ext.calc_ut(jd, planet_id) -> Float
Calculate planet ecliptic longitude using Moshier ephemeris. Returns the longitude in degrees (0-360).
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'ext/astro_chart/astro_chart_ext.c', line 28 static VALUE rb_calc_ut(VALUE self, VALUE jd, VALUE planet_id) { double tjd = NUM2DBL(jd); int ipl = NUM2INT(planet_id); double xx[6]; char serr[256]; int32 ret = swe_calc_ut(tjd, ipl, SEFLG_MOSEPH, xx, serr); if (ret < 0) { rb_raise(rb_eRuntimeError, "swe_calc_ut failed: %s", serr); } return DBL2NUM(xx[0]); /* ecliptic longitude */ } |
.houses(jd, lat, lon, hsys) ⇒ Object
AstroChart::Ext.houses(jd, latitude, longitude, system) -> Hash
Calculate house cusps and ascendant/MC. system: ASCII code for house system (e.g. ‘P’ = 80 for Placidus)
Returns a Hash with:
"cusps" => Array of 12 house cusp degrees
"ascendant" => Ascendant degree
"mc" => MC degree
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'ext/astro_chart/astro_chart_ext.c', line 53 static VALUE rb_houses(VALUE self, VALUE jd, VALUE lat, VALUE lon, VALUE hsys) { double tjd = NUM2DBL(jd); double geolat = NUM2DBL(lat); double geolon = NUM2DBL(lon); int system = NUM2INT(hsys); double cusps[13]; /* cusps[0] unused, cusps[1..12] */ double ascmc[10]; swe_houses(tjd, geolat, geolon, system, cusps, ascmc); VALUE result = rb_hash_new(); VALUE cusps_ary = rb_ary_new_capa(12); int i; for (i = 1; i <= 12; i++) { rb_ary_push(cusps_ary, DBL2NUM(cusps[i])); } rb_hash_aset(result, rb_str_new_cstr("cusps"), cusps_ary); rb_hash_aset(result, rb_str_new_cstr("ascendant"), DBL2NUM(ascmc[0])); rb_hash_aset(result, rb_str_new_cstr("mc"), DBL2NUM(ascmc[1])); return result; } |
.julday(year, month, day, hour) ⇒ Object
AstroChart::Ext.julday(year, month, day, hour) -> Float
Convert a date/time to Julian Day number using Gregorian calendar.
12 13 14 15 16 17 18 19 20 |
# File 'ext/astro_chart/astro_chart_ext.c', line 12 static VALUE rb_julday(VALUE self, VALUE year, VALUE month, VALUE day, VALUE hour) { int y = NUM2INT(year); int m = NUM2INT(month); int d = NUM2INT(day); double h = NUM2DBL(hour); double jd = swe_julday(y, m, d, h, SE_GREG_CAL); return DBL2NUM(jd); } |