-
Notifications
You must be signed in to change notification settings - Fork 0
/
stellar-classification.go
86 lines (79 loc) · 2.9 KB
/
stellar-classification.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
78
79
80
81
82
83
84
85
86
package stargen
import (
"math"
"github.com/dayaftereh/discover/server/utils"
"github.com/dayaftereh/discover/server/mathf"
)
type StellarClass struct {
Class string
Color int64
Mass *mathf.Range
Radius *mathf.Range
Temperature *mathf.Range
Luminosity *mathf.Range
}
// Stellar classification https://en.wikipedia.org/wiki/Stellar_classification
var StellarClassification []*StellarClass = []*StellarClass{
&StellarClass{
Class: "O",
Color: 255, // blue
Mass: mathf.NewRange(16.0, 120.0), // >= 16 M
Radius: mathf.NewRange(6.6, math.MaxFloat64), // >= 6.6 R
Temperature: mathf.NewRange(30, 50), // >= 30 *1000 K
Luminosity: mathf.NewRange(30000, math.MaxFloat64), // >= 30000 L
},
&StellarClass{
Class: "B",
Color: 10079487, // blue white
Mass: mathf.NewRange(2.1, 16.0), // 2.1–16 M
Radius: mathf.NewRange(1.8, 6.6), // 1.8–6.6 R
Temperature: mathf.NewRange(10, 30), // 10 - 30 *1000 K
Luminosity: mathf.NewRange(25, 30000), // 25 - 30000 L
},
&StellarClass{
Class: "A",
Color: 16777215, // white
Mass: mathf.NewRange(1.4, 2.1), // 1.4 - 2.1 M
Radius: mathf.NewRange(1.4, 1.8), // 1.4 - 1.8 R
Temperature: mathf.NewRange(7.5, 10), // 7.5 - 10 *1000 K
Luminosity: mathf.NewRange(5, 25), // 5 - 25 L
},
&StellarClass{
Class: "F",
Color: 16777164, // yellow white
Mass: mathf.NewRange(1.04, 1.4), // 1.04 - 1.4 M
Radius: mathf.NewRange(1.15, 1.4), // 1.15 - 1.4 R
Temperature: mathf.NewRange(6, 7.5), // 6 - 7.5 *1000 K
Luminosity: mathf.NewRange(1.5, 5), // 1.5 - 5 L
},
&StellarClass{
Class: "G",
Color: 16776960, // yellow
Mass: mathf.NewRange(0.8, 1.04), // 0.8 - 1.04 M
Radius: mathf.NewRange(0.96, 1.15), // 0.96 - 1.15 R
Temperature: mathf.NewRange(5.2, 6.0), // 5.2 - 6 *1000 K
Luminosity: mathf.NewRange(0.6, 1.5), // 0.6 - 1.5 L
},
&StellarClass{
Class: "K",
Color: 16761446, // light orange
Mass: mathf.NewRange(0.45, 0.8), // 0.45 - 0.8 M
Radius: mathf.NewRange(0.7, 0.96), // 0.7 - 0.96 R
Temperature: mathf.NewRange(3.7, 5.2), // 3.7 - 5.2 *1000 K
Luminosity: mathf.NewRange(0.08, 0.6), // 0.08 - 0.6 L
},
&StellarClass{
Class: "M",
Color: 13395456, // orange red
Mass: mathf.NewRange(0.08, 0.45), // 0.08 - 0.45 M
Radius: mathf.NewRange(0.0, 0.7), // 0 - 0.7 R
Temperature: mathf.NewRange(2.4, 3.7), // 2.4 - 3.7 *1000 K
Luminosity: mathf.NewRange(0.0, 0.08), // 0.0 - 0.08 L
},
}
func RandStellarClass() *StellarClass {
length := len(StellarClassification)
index := utils.RandIntn(length)
class := StellarClassification[index]
return class
}