Esempio n. 1
0
void planet::get_eph(const epoch& when, array3D &r, array3D &v) const{
	if(when.mjd2000() != cached_epoch.mjd2000() || cached_epoch.mjd2000() == 0) {
		double elements[6];
		std::copy(keplerian_elements.begin(), keplerian_elements.end(), elements);
		double dt = (when.mjd2000() - ref_mjd2000) * ASTRO_DAY2SEC;
		elements[5] += mean_motion * dt;
		elements[5] = m2e(elements[5],elements[1]);
		par2ic(elements, mu_central_body, cached_r, cached_v);
		cached_epoch = when;
	}
	r = cached_r;
	v = cached_v;
}
Esempio n. 2
0
array6D planet::get_elements(const epoch& when) const{
	array6D elements(keplerian_elements);
	double dt = (when.mjd2000() - ref_mjd2000) * ASTRO_DAY2SEC;
	elements[5] += mean_motion * dt;
	elements[5] = fmod(elements[5],2*M_PI);
	if (elements[5] < 0) elements[5] = 2*M_PI + elements[5];
	return ( elements );
}
Esempio n. 3
0
void planet::build_planet(const epoch& ref_epoch, const array6D& orbital_elements_, const double & mu_central_body_, const double &mu_self_, const double & radius_, const double & safe_radius_, const std::string &name_)
{
	keplerian_elements = orbital_elements_;
	ref_mjd2000 = ref_epoch.mjd2000();
	radius = radius_;
	safe_radius = safe_radius_;
	mu_self = mu_self_;
	mu_central_body = mu_central_body_;
	m_name = name_;
	mean_motion = sqrt(mu_central_body / pow(keplerian_elements[0],3));
}
Esempio n. 4
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. 5
0
/**
* Constructs a planet from its elements and its phyisical parameters
* \param[in] ref_epoch epoch to which the elements are referred to
* \param[in] elem A STL vector containing the keplerian parameters (a,e,i,Om,om,M). (SI units)
* \param[in] mu_central_body The gravitational parameter of the attracting body (SI units)
* \param[in] mu_self The gravitational parameter of the planet (SI units)
* \param[in] radius radius of the planet (SI units)
* \param[in] safe_radius mimimual radius that is safe during a fly-by of the planet (SI units)
* \param[in] name C++ string containing the planet name. Default value is "Unknown"
*/
keplerian::keplerian(
	const epoch& ref_epoch,
	const array6D& keplerian_elements,
	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_keplerian_elements(keplerian_elements), m_ref_mjd2000(ref_epoch.mjd2000())
{
	if (keplerian_elements[0] <=0) {
		throw_value_error("The planet semi-major axis needs to a positive number");
	}
	if (keplerian_elements[1] < 0 || keplerian_elements[1] >=1) {
		throw_value_error("The planet eccentricity needs to be in [0,1)");
	}
	m_mean_motion = sqrt(mu_central_body / pow(keplerian_elements[0],3));
	par2ic(m_keplerian_elements, get_mu_central_body(), m_r, m_v);
}