practical_astronomy_rust/
planetdata.rs1pub struct PlanetInfo {
13 pub name: String,
14 pub tp: f64,
15 pub long: f64,
16 pub peri: f64,
17 pub ecc: f64,
18 pub axis: f64,
19 pub incl: f64,
20 pub node: f64,
21 pub theta0: f64,
22 pub v0: f64,
23}
24
25pub fn get_planet_info_vector(planet_name: String) -> (PlanetInfo, String) {
30 let mut planet_vector: Vec<PlanetInfo> = Vec::new();
31
32 planet_vector.push(PlanetInfo {
33 name: "Mercury".to_string(),
34 tp: 0.24085,
35 long: 75.5671,
36 peri: 77.612,
37 ecc: 0.205627,
38 axis: 0.387098,
39 incl: 7.0051,
40 node: 48.449,
41 theta0: 6.74,
42 v0: -0.42,
43 });
44 planet_vector.push(PlanetInfo {
45 name: "Venus".to_string(),
46 tp: 0.615207,
47 long: 272.30044,
48 peri: 131.54,
49 ecc: 0.006812,
50 axis: 0.723329,
51 incl: 3.3947,
52 node: 76.769,
53 theta0: 16.92,
54 v0: -4.4,
55 });
56 planet_vector.push(PlanetInfo {
57 name: "Earth".to_string(),
58 tp: 0.999996,
59 long: 99.556772,
60 peri: 103.2055,
61 ecc: 0.016671,
62 axis: 0.999985,
63 incl: -99.0,
64 node: -99.0,
65 theta0: -99.0,
66 v0: -99.0,
67 });
68 planet_vector.push(PlanetInfo {
69 name: "Mars".to_string(),
70 tp: 1.880765,
71 long: 109.09646,
72 peri: 336.217,
73 ecc: 0.093348,
74 axis: 1.523689,
75 incl: 1.8497,
76 node: 49.632,
77 theta0: 9.36,
78 v0: -1.52,
79 });
80 planet_vector.push(PlanetInfo {
81 name: "Jupiter".to_string(),
82 tp: 11.857911,
83 long: 337.917132,
84 peri: 14.6633,
85 ecc: 0.048907,
86 axis: 5.20278,
87 incl: 1.3035,
88 node: 100.595,
89 theta0: 196.74,
90 v0: -9.4,
91 });
92 planet_vector.push(PlanetInfo {
93 name: "Saturn".to_string(),
94 tp: 29.310579,
95 long: 172.398316,
96 peri: 89.567,
97 ecc: 0.053853,
98 axis: 9.51134,
99 incl: 2.4873,
100 node: 113.752,
101 theta0: 165.6,
102 v0: -8.88,
103 });
104 planet_vector.push(PlanetInfo {
105 name: "Uranus".to_string(),
106 tp: 84.039492,
107 long: 356.135400,
108 peri: 172.884833,
109 ecc: 0.046321,
110 axis: 19.21814,
111 incl: 0.773059,
112 node: 73.926961,
113 theta0: 65.8,
114 v0: -7.19,
115 });
116 planet_vector.push(PlanetInfo {
117 name: "Neptune".to_string(),
118 tp: 165.845392,
119 long: 326.895127,
120 peri: 23.07,
121 ecc: 0.010483,
122 axis: 30.1985,
123 incl: 1.7673,
124 node: 131.879,
125 theta0: 62.2,
126 v0: -6.87,
127 });
128
129 for i in planet_vector {
130 if i.name == planet_name {
131 return (i, "OK".to_string());
132 }
133 }
134
135 return (
136 PlanetInfo {
137 name: planet_name,
138 tp: -99.0,
139 long: -99.0,
140 peri: -99.0,
141 ecc: -99.0,
142 axis: -99.0,
143 incl: -99.0,
144 node: -99.0,
145 theta0: -99.0,
146 v0: -99.0,
147 },
148 "NotFound".to_string(),
149 );
150}