== Swe4r (Swiss Ephemeris 2.0 for Ruby)
The Swe4r rubygem provides a C extension for the standard functions of the {Swiss Ephemeris API}[http://www.astro.com/swisseph/].
This version has been updated to use the latest (fev/2014) Swiss Ephemeris API.
== Installation
Install the gem as usual:
[sudo] gem install swe4r
== Methods The following functions of the {Swiss Ephemeris API}[http://www.astro.com/swisseph/] are supported...
{swe_calc_ut}[http://www.astro.com/swisseph/swephprg.htm#_Toc283735419] :: Calculation of planets, moon, asteroids, lunar nodes, apogees, fictitious bodies {swe_houses}[http://www.astro.com/swisseph/swephprg.htm#_Toc283735486] :: This function computes house cusps, ascendant, midheaven, etc {swe_set_ephe_path}[http://www.astro.com/swisseph/swephprg.htm#_Toc283735481] :: Set directory path of ephemeris files (not required for Moshier Ephemeris) {swe_julday}[http://www.astro.com/swisseph/swephprg.htm#_Toc283735468] :: Get the Julian day number from year, month, day, hour {swe_set_topo}[http://www.astro.com/swisseph/swephprg.htm#_Toc283735476] :: Set the geographic location for topocentric planet computation {swe_set_sid_mode}[http://www.astro.com/swisseph/swephprg.htm#_Toc283735478] :: This function can be used to specify the mode for sidereal computations {swe_get_ayanamsa}[http://www.astro.com/swisseph/swephprg.htm#_Toc283735479] :: This function computes the ayanamsha, the distance of the tropical vernal point from the sidereal zero point of the zodiac
== Examples The following example demonstrates how to calculate the position of a celestial body such as a planet using the _swe_calcut function
require 'swe4r'
year = 2012 month = 5 day = 14 hour = 10.15
longitude = -112.183333 latitidue = 45.45 altitude = 1468
jd = Swe4r::swe_julday(year, month, day, hour)
Swe4r::swe_set_topo(longitude, latitidue, altitude)
Swe4r::swe_set_sid_mode(Swe4r::SE_SIDM_LAHIRI, 0, 0)
ayanamsha = Swe4r::swe_get_ayanamsa_ut(jd)
body = Swe4r::swe_calc_ut(jd, Swe4r::SE_SUN, Swe4r::SEFLG_MOSEPH|Swe4r::SEFLG_SPEED|Swe4r::SEFLG_TOPOCTR|Swe4r::SEFLG_SIDEREAL)
puts "Longitude: #{body[0]}" puts "Latitude: #{body[1]}" puts "Distance in AU: #{body[2]}" puts "Speed in longitude (deg/day): #{body[3]}" puts "Speed in latitude (deg/day): #{body[4]}" puts "Speed in distance (AU/day): #{body[5]}" puts "Ayanamsha: #{ayanamsha}"
The following example demonstrates how to calculate house cusps, the ascendant, midheaven, and other points on the zodiac using the _swehouses function
require 'swe4r'
year = 2012 month = 5 day = 14 hour = 10.15
longitude = -112.183333 latitidue = 45.45 altitude = 1468
jd = Swe4r::swe_julday(year, month, day, hour)
houses = Swe4r::swe_houses(jd, latitidue, longitude, 'P')
(1..12).each do |i| puts "House ##{i} Cusp: #{houses[i]}" end
puts "Ascendant: #{houses[13]}" puts "Midheaven (MC): #{houses[14]}" puts "ARMC: #{houses[15]}" puts "Equatorial Ascendant: #{houses[16]}" puts "Co-Ascendant (Walter Koch): #{houses[17]}" puts "Co-Ascendant (Michael Munkasey): #{houses[18]}" puts "Polar Ascendant (M. Munkasey) : #{houses[19]}"
== License Swe4r is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Swe4r is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Swe4r. If not, see {http://www.gnu.org/licenses/}[http://www.gnu.org/licenses/].