Module: AstroChart::Planets
- Defined in:
- lib/astro_chart/planets.rb
Class Method Summary collapse
-
.aspects_for(point_pos, point_name, positions) ⇒ Object
Calculate aspects for a given point against all planet positions.
-
.build_details(positions, cusps) ⇒ Object
Build detailed planet info list with zodiac, house, degree.
- .build_ruler_point(label, ruling_planet, pos, cusps, positions) ⇒ Object
-
.calculate_positions(jd) ⇒ Object
Calculate raw ecliptic longitudes for all planets + nodes.
-
.key_points_data(positions, cusps, ascendant) ⇒ Object
Calculate key points data: aspects for major planets + ruler info.
Class Method Details
.aspects_for(point_pos, point_name, positions) ⇒ Object
Calculate aspects for a given point against all planet positions.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/astro_chart/planets.rb', line 35 def self.aspects_for(point_pos, point_name, positions) return [] if point_pos.nil? results = [] positions.each do |planet, pos| next if planet == point_name aspect_type, orb = Aspects.calculate(point_pos, pos) if aspect_type results << { "planet" => planet, "aspect_type" => aspect_type, "orb" => orb, } end end results end |
.build_details(positions, cusps) ⇒ Object
Build detailed planet info list with zodiac, house, degree.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/astro_chart/planets.rb', line 19 def self.build_details(positions, cusps) positions.map do |planet, pos| house = Houses.find_house(pos, cusps) next if house.nil? { "planet" => planet, "zodiac" => Zodiac.sign_name(pos), "house" => house, "degree" => (pos % 30).round(4), "total_degree" => pos.round(4), } end.compact end |
.build_ruler_point(label, ruling_planet, pos, cusps, positions) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/astro_chart/planets.rb', line 110 def self.build_ruler_point(label, ruling_planet, pos, cusps, positions) { "planet" => label, "ruling_planet" => ruling_planet, "zodiac" => Zodiac.sign_name(pos), "house" => Houses.find_house(pos, cusps), "degree" => (pos % 30).round(4), "total_degree" => pos.round(4), "aspects" => aspects_for(pos, ruling_planet, positions), } end |
.calculate_positions(jd) ⇒ Object
Calculate raw ecliptic longitudes for all planets + nodes. Returns Hash: { “太陽” => 123.45, “月亮” => 67.89, … }
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/astro_chart/planets.rb', line 5 def self.calculate_positions(jd) positions = {} Ephemeris::PLANETS.each do |name, planet_id| positions[name] = Ephemeris.calc_ut(jd, planet_id) end # South node = North node + 180 positions["南交點"] = (positions["北交點"] + 180.0) % 360.0 positions end |
.key_points_data(positions, cusps, ascendant) ⇒ Object
Calculate key points data: aspects for major planets + ruler info.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 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 103 104 105 106 |
# File 'lib/astro_chart/planets.rb', line 55 def self.key_points_data(positions, cusps, ascendant) sun_aspects = aspects_for(positions["太陽"], "太陽", positions) moon_aspects = aspects_for(positions["月亮"], "月亮", positions) saturn_aspects = aspects_for(positions["土星"], "土星", positions) venus_aspects = aspects_for(positions["金星"], "金星", positions) north_node_aspects = aspects_for(positions["北交點"], "北交點", positions) south_node_aspects = aspects_for(positions["南交點"], "南交點", positions) additional_points = [] # North Node ruler nn_pos = positions["北交點"] if nn_pos nn_zodiac = Zodiac.sign_name(nn_pos) nn_ruler = Zodiac.ruler(nn_zodiac) nn_ruler_pos = positions[nn_ruler] if nn_ruler_pos additional_points << build_ruler_point("北交點定位星", nn_ruler, nn_ruler_pos, cusps, positions) end end # South Node ruler sn_pos = positions["南交點"] if sn_pos sn_zodiac = Zodiac.sign_name(sn_pos) sn_ruler = Zodiac.ruler(sn_zodiac) sn_ruler_pos = positions[sn_ruler] if sn_ruler_pos additional_points << build_ruler_point("南交點定位星", sn_ruler, sn_ruler_pos, cusps, positions) end end # Ascendant ruler if ascendant asc_zodiac = Zodiac.sign_name(ascendant) asc_ruler = Zodiac.ruler(asc_zodiac) asc_ruler_pos = positions[asc_ruler] if asc_ruler_pos additional_points << build_ruler_point("上升星座定位星", asc_ruler, asc_ruler_pos, cusps, positions) end end { "sun_aspects" => sun_aspects, "moon_aspects" => moon_aspects, "saturn_aspects" => saturn_aspects, "venus_aspects" => venus_aspects, "north_node_aspects" => north_node_aspects, "south_node_aspects" => south_node_aspects, "additional_points" => additional_points, } end |