Class: Astromapper::Builder::Star
- Defined in:
- lib/astromapper/builder/star.rb
Constant Summary collapse
- STAR_CHART =
@@stars = {}
{ #type => 0)example, 1)temp, 2)lux, 3)mass, 4)radius 'B0' => ['Becrux', 30000, 16000, 16.0, 5.70], 'B2' => ['Spica', 22000, 8300, 10.5, 5.10], 'B5' => ['Achernar', 15000, 750, 5.40, 3.70], 'B8' => ['Rigel', 12500, 130, 3.50, 2.70], 'A0' => ['Sirius A', 9500, 63, 2.60, 2.30], 'A2' => ['Fomalhaut', 9000, 40, 2.20, 2.00], 'A5' => ['Altair', 8700, 24, 1.90, 1.80], 'F0' => ['Gamma Virginis', 7400, 9.0, 1.60, 1.50], 'F2' => ['.', 7100, 6.3, 1.50, 1.30], 'F5' => ['Procyon A', 6400, 4.0, 1.35, 1.20], 'G0' => ['Alpha Centauri A', 5900, 1.45, 1.08, 1.05], 'G2' => ['The Sun', 5800, 1.00, 1.00, 1.00], 'G5' => ['Mu Cassiopeiae', 5600, 0.70, 0.95, 0.91], 'G8' => ['Tau Ceti', 5300, 0.44, 0.85, 0.87], 'K0' => ['Pollux', 5100, 0.36, 0.83, 0.83], 'K2' => ['Epsilon Eridani', 4830, 0.28, 0.78, 0.79], 'K5' => ['Alpha Centauri B', 4370, 0.18, 0.68, 0.74], 'M0' => ['Gliese 185', 3670, 0.075, 0.47, 0.63], 'M2' => ['Lalande 21185', 3400, 0.03, 0.33, 0.36], 'M4' => ['Ross 128', 3200, 0.0005, 0.20, 0.21], 'M6' => ['Wolf 359', 3000, 0.0002, 0.10, 0.12] }
- INNER_LIMIT =
{ 'O' => [ 16, 13, 10 ], 'B' => [ 10, 6.3, 5.0, 4.0, 3.8, 0.6, 0], 'A' => [ 4, 1, 0.4, 0, 0, 0, 0], 'F' => [ 4, 1, 0.3, 0.1, 0, 0, 0], 'G' => [ 3.1, 1, 0.3, 0.1, 0, 0, 0], 'K' => [ 2.5, 1, 0.3, 0.1, 0, 0, 0], 'M' => [ 2, 1, 0.3, 0.1, 0, 0, 0], 'D' => [ 0 ], }
- BIOZONE =
{ 'O' => [ [790,1190], [630,950], [500,750] ], 'B' => [ [500,700], [320,480], [250,375], [200,300], [180,270], [30,45] ], 'A' => [ [200,300], [50,75], [20,30], [5.0,7.5], [4.0,6.0], [3.1,4.7] ], 'F' => [ [200,300], [50,75], [13,19], [2.5,3.7], [2.0,3.0], [1.6,2.4], [0.5,0.8] ], 'G' => [ [200,300], [50,75], [13,19], [2.5,3.7], [2.0,3.0], [1.6,2.4], [0.5,0.8] ], 'K' => [ [125,190], [50,75], [13,19], [4.0,5.9], [1.0,1.5], [0.5,0.6], [0.2,0.3] ], 'M' => [ [100,150], [50,76], [16,24], [5.0,7.5], [0,0], [0.1,0.2], [0.1,0.1] ], 'D' => [ [0.03, 0.03] ], }
- SPECTRAL =
{ 'O' => [9], 'B' => [0,2,5,8], 'A' => [0,2,5], 'F' => [0,2,5], 'G' => [0,2,5,8], 'K' => [0,2,5], 'M' => [0,2,4,6] }
- MASS =
{ 'O' => [70, 60, 0, 0, 50, 0 ], 'B' => [50, 40, 35, 30, 20, 10], 'A' => [30, 16, 10, 6, 4, 3], 'F' => [15, 13, 8, 2.5, 2.2, 1.9], 'G' => [12, 10, 6, 2.7, 1.8, 1.1, 0.8], 'K' => [15, 12, 6, 3, 2.3, 0.9, 0.5], 'M' => [20, 16, 8, 4, 0.3, 0.2], 'D' => [0.8,0.8,0.8,0.8,0.8,0.8,] }
- COMPANION_SEPARATION =
[[0.05]*2, [0.5]*3, [2.0]*2, [10.0]*3, [50.0] * 10].flatten
- BODE_RATIO =
[[0.3] * 4, [0.35] * 3, [0.4] * 4].flatten
Instance Attribute Summary collapse
-
#biozone ⇒ Object
Returns the value of attribute biozone.
-
#bode_constant ⇒ Object
Returns the value of attribute bode_constant.
-
#companions ⇒ Object
Returns the value of attribute companions.
-
#id ⇒ Object
Returns the value of attribute id.
-
#mass ⇒ Object
Returns the value of attribute mass.
-
#orbit ⇒ Object
Returns the value of attribute orbit.
-
#orbits ⇒ Object
Returns the value of attribute orbits.
-
#primary ⇒ Object
Returns the value of attribute primary.
-
#size_dm ⇒ Object
Returns the value of attribute size_dm.
-
#star_size ⇒ Object
Returns the value of attribute star_size.
-
#type_dm ⇒ Object
Returns the value of attribute type_dm.
-
#volume ⇒ Object
Returns the value of attribute volume.
-
#world ⇒ Object
Returns the value of attribute world.
Attributes inherited from Base
Instance Method Summary collapse
- #au_to_orbit(au) ⇒ Object
- #classification ⇒ Object
- #column ⇒ Object
- #crib ⇒ Object
-
#initialize(volume, primary = nil, ternary = 0) ⇒ Star
constructor
A new instance of Star.
- #inner_limit ⇒ Object
- #kid ⇒ Object
- #limit ⇒ Object
- #location ⇒ Object
- #luminosity ⇒ Object
- #orbit_to_au(o) ⇒ Object
- #orbits_to_ascii ⇒ Object
-
#outer_limit ⇒ Object
Gurps Space 4e p.
-
#prune! ⇒ Object
Ensure last orbits are not empty.
-
#radius ⇒ Object
Gurps Space 4e p.
- #row ⇒ Object
- #sector ⇒ Object
- #size ⇒ Object
- #size=(s) ⇒ Object
-
#snow_line ⇒ Object
Gurps Space 4e p.
- #temperature ⇒ Object
- #to_ascii ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
- #type=(s) ⇒ Object
- #world? ⇒ Boolean
Methods inherited from Base
#config, constitute, #names, #spawn_command, #toss
Constructor Details
#initialize(volume, primary = nil, ternary = 0) ⇒ Star
Returns a new instance of Star.
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 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/astromapper/builder/star.rb', line 71 def initialize(volume, primary=nil,ternary=0) @volume = volume @primary = primary @orbits = [] @companions = [] @world = nil @type_dm = 0 @size_dm = 0 @has_gg = false if primary.nil? @orbit = 0 @type_dm = (toss(2,0) + @volume.star_dm ).max(12) @size_dm = (toss(2,0) + 0 ).max(12) @star_type = %w{B B A M M M M M K G F F F}[@type_dm] @star_size = %w{0 1 2 3 4 5 5 5 5 5 5 6 500}[@size_dm].to_i else separation = (toss(2,0) * COMPANION_SEPARATION[toss(3) + (4 * ternary) - 2]).round(2) # Gurps Space 4e p.105 @orbit = au_to_orbit(separation) - 1 @star_type = %w{X B A F F G G K K M M M M}[(toss(2,0) + primary.type_dm).max(12)] @star_size = %w{0 1 2 3 4 500 500 5 5 6 500 500 500 500}[(toss(2,0) + primary.size_dm).max(12)].to_i end @spectral = @star_type + SPECTRAL[@star_type].sample.to_s @star_size ||= 500 @bode_constant = (@star_type=='M' and @star_size==5) ? 0.2 : BODE_RATIO[toss] if @star_size == 500 @star_subtype = (true) ? 'B' : @star_type @star_type = 'D' end dm = 0 dm += 4 if @star_size == 3 dm += 8 if @star_size < 3 dm -= 4 if @star_type == 'M' dm -= 2 if @star_type == 'K' # Populate Orbits (toss(2,0) + dm).whole.times do |i| @orbits << Orbit.new(self,i).populate unless orbit_to_au(i) > outer_limit @world = @orbits.last if @orbits.last.is_a?(World) end @world.gas_giant = (@orbits.map{|o| o.kid}.include?('G')) ? 'G' : '.' unless @world.nil? prune! end |
Instance Attribute Details
#biozone ⇒ Object
Returns the value of attribute biozone.
4 5 6 |
# File 'lib/astromapper/builder/star.rb', line 4 def biozone @biozone end |
#bode_constant ⇒ Object
Returns the value of attribute bode_constant.
4 5 6 |
# File 'lib/astromapper/builder/star.rb', line 4 def bode_constant @bode_constant end |
#companions ⇒ Object
Returns the value of attribute companions.
4 5 6 |
# File 'lib/astromapper/builder/star.rb', line 4 def companions @companions end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/astromapper/builder/star.rb', line 4 def id @id end |
#mass ⇒ Object
Returns the value of attribute mass.
4 5 6 |
# File 'lib/astromapper/builder/star.rb', line 4 def mass @mass end |
#orbit ⇒ Object
Returns the value of attribute orbit.
4 5 6 |
# File 'lib/astromapper/builder/star.rb', line 4 def orbit @orbit end |
#orbits ⇒ Object
Returns the value of attribute orbits.
4 5 6 |
# File 'lib/astromapper/builder/star.rb', line 4 def orbits @orbits end |
#primary ⇒ Object
Returns the value of attribute primary.
4 5 6 |
# File 'lib/astromapper/builder/star.rb', line 4 def primary @primary end |
#size_dm ⇒ Object
Returns the value of attribute size_dm.
4 5 6 |
# File 'lib/astromapper/builder/star.rb', line 4 def size_dm @size_dm end |
#star_size ⇒ Object
Returns the value of attribute star_size.
4 5 6 |
# File 'lib/astromapper/builder/star.rb', line 4 def star_size @star_size end |
#type_dm ⇒ Object
Returns the value of attribute type_dm.
4 5 6 |
# File 'lib/astromapper/builder/star.rb', line 4 def type_dm @type_dm end |
#volume ⇒ Object
Returns the value of attribute volume.
4 5 6 |
# File 'lib/astromapper/builder/star.rb', line 4 def volume @volume end |
#world ⇒ Object
Returns the value of attribute world.
4 5 6 |
# File 'lib/astromapper/builder/star.rb', line 4 def world @world end |
Instance Method Details
#au_to_orbit(au) ⇒ Object
137 138 139 140 |
# File 'lib/astromapper/builder/star.rb', line 137 def au_to_orbit(au) constant = (@primary.nil?) ? @bode_constant : @primary.bode_constant (Math.log(au / constant) / Math.log(2) ).round(2).abs - inner_limit end |
#classification ⇒ Object
171 172 173 174 |
# File 'lib/astromapper/builder/star.rb', line 171 def classification return @star_type + @star_subtype if (@star_type == 'D') "#{@spectral}#{@star_size.roman}" end |
#column ⇒ Object
179 |
# File 'lib/astromapper/builder/star.rb', line 179 def column; @volume.column; end |
#crib ⇒ Object
163 164 165 166 167 |
# File 'lib/astromapper/builder/star.rb', line 163 def crib stars = [classification] @companions.each { |s| stars << s.classification } "%-17s %-16s" % [stars.join('/'), @orbits.map{|o| o.kid}.join('')] end |
#inner_limit ⇒ Object
187 |
# File 'lib/astromapper/builder/star.rb', line 187 def inner_limit; limit; end |
#kid ⇒ Object
155 |
# File 'lib/astromapper/builder/star.rb', line 155 def kid; 'C'; end |
#limit ⇒ Object
188 189 190 191 |
# File 'lib/astromapper/builder/star.rb', line 188 def limit return 0 if @star_size.nil? INNER_LIMIT[@star_type][@star_size % 10] end |
#location ⇒ Object
182 |
# File 'lib/astromapper/builder/star.rb', line 182 def location; @volume.location; end |
#luminosity ⇒ Object
193 |
# File 'lib/astromapper/builder/star.rb', line 193 def luminosity; STAR_CHART[@spectral][2]; end |
#orbit_to_au(o) ⇒ Object
134 135 136 |
# File 'lib/astromapper/builder/star.rb', line 134 def orbit_to_au(o) inner_limit + (self.bode_constant * (2 ** o)).round(1) end |
#orbits_to_ascii ⇒ Object
159 160 161 162 |
# File 'lib/astromapper/builder/star.rb', line 159 def orbits_to_ascii return '' if @orbits.empty? "\n" + @orbits.map{|o| o.to_ascii}.join("\n") + "\n" end |
#outer_limit ⇒ Object
Gurps Space 4e p. 107
158 |
# File 'lib/astromapper/builder/star.rb', line 158 def outer_limit; 40 * mass; end |
#prune! ⇒ Object
Ensure last orbits are not empty.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/astromapper/builder/star.rb', line 119 def prune! # Ensure last orbits are not empty. @orbits.each_index { |x| @orbits[x] = Orbit.new(self,x) if @orbits[x].nil?} c = @orbits # exit tk = false @orbits = @orbits.sort{|b,a| a.orbit_number <=> b.orbit_number}.map {|o| tk = true unless (o.kid == '.' or tk); o if tk }.reverse.compact # @orbits.each_index { |x| @orbits[x] = Orbit.new(self,x) if @orbits[x].nil?} return if @orbits.size < 2 @orbits.length.times do |i| @orbits[i].orbit_number = i @orbits[i].au = self.orbit_to_au(i) end end |
#radius ⇒ Object
Gurps Space 4e p. 104
156 |
# File 'lib/astromapper/builder/star.rb', line 156 def radius; (155000 * Math.sqrt(luminosity)) ** 2; end |
#row ⇒ Object
180 |
# File 'lib/astromapper/builder/star.rb', line 180 def row; @volume.row; end |
#sector ⇒ Object
181 |
# File 'lib/astromapper/builder/star.rb', line 181 def sector; @volume.sector; end |
#size ⇒ Object
185 |
# File 'lib/astromapper/builder/star.rb', line 185 def size; @star_size; end |
#size=(s) ⇒ Object
186 |
# File 'lib/astromapper/builder/star.rb', line 186 def size=(s); @star_size = s; end |
#snow_line ⇒ Object
Gurps Space 4e p. 106
157 |
# File 'lib/astromapper/builder/star.rb', line 157 def snow_line; 4.85 * Math.sqrt(luminosity); end |
#temperature ⇒ Object
194 |
# File 'lib/astromapper/builder/star.rb', line 194 def temperature; @temperature = STAR_CHART[@spectral][1].around(20) if @temperature.nil?; end |
#to_ascii ⇒ Object
168 169 170 |
# File 'lib/astromapper/builder/star.rb', line 168 def to_ascii classification end |
#to_s ⇒ Object
154 |
# File 'lib/astromapper/builder/star.rb', line 154 def to_s; kid; end |
#type ⇒ Object
183 |
# File 'lib/astromapper/builder/star.rb', line 183 def type; @star_type; end |
#type=(s) ⇒ Object
184 |
# File 'lib/astromapper/builder/star.rb', line 184 def type=(s); @star_type = s; end |
#world? ⇒ Boolean
175 176 177 178 |
# File 'lib/astromapper/builder/star.rb', line 175 def world? return @orbits.join('').include?('W') return false end |