Esempio n. 1
0
keplerian::keplerian(
	const epoch& ref_epoch,
	const array3D& r0,
	const array3D& v0,
	double mu_central_body,
	double mu_self,
	double radius,
	double safe_radius,
	const std::string &name) : base(mu_central_body, mu_self, radius, safe_radius, name), m_r(r0), m_v(v0), m_ref_mjd2000(ref_epoch.mjd2000())
{
	// This line is  singular (small e and small i) in which case the orbital elements are (simply) not defined
	ic2par(r0,v0, get_mu_central_body(), m_keplerian_elements);
	m_keplerian_elements[5] = e2m(m_keplerian_elements[5],m_keplerian_elements[1]);
	m_mean_motion = sqrt(get_mu_central_body() / pow(m_keplerian_elements[0],3));
}
Esempio n. 2
0
planet::planet(const epoch& ref_epoch, const array3D& r0, const array3D& v0, const double & mu_central_body_, const double &mu_self_, const double & radius_, const double & safe_radius_, const std::string &name_)
{
	if (radius_ <= 0) {
		throw_value_error("The planet radius needs to be strictly positive");
	}
	if (mu_central_body_ <= 0) {
		throw_value_error("The central body gravitational parameter needs to be strictly positive");
	}
	if (mu_self_ <= 0) {
		throw_value_error("The gravitational parameter of the planet needs to be strictly positive");
	}
	for (int i = 0; i < 3; ++i) {
		cached_r[i] = 0;
		cached_v[i] = 0;
	}
	array6D orbital_elements;
	ic2par(r0,v0, mu_central_body_, orbital_elements);
	orbital_elements[5] = e2m(orbital_elements[5],orbital_elements[1]);
	planet::build_planet(ref_epoch, orbital_elements, mu_central_body_, mu_self_, radius_, safe_radius_, name_);
}