コード例 #1
0
std::unique_ptr<MassiveBody> SolarSystem<Frame>::MakeMassiveBody(
    serialization::GravityModel::Body const& body) {
  CHECK(body.has_gravitational_parameter());
  CHECK_EQ(body.has_j2(), body.has_reference_radius());
  CHECK_EQ(body.has_axis_declination(), body.has_axis_right_ascension());
  MassiveBody::Parameters massive_body_parameters(
                              ParseQuantity<GravitationalParameter>(
                                  body.gravitational_parameter()));
  if (body.has_axis_declination()) {
    // TODO(phl): Parse the additional parameters.
    typename RotatingBody<Frame>::Parameters
        rotating_body_parameters(
            0 * Radian,
            Instant(),
            Bivector<double, Frame>(
                RadiusLatitudeLongitude(
                    1.0,
                    ParseQuantity<Angle>(body.axis_declination()),
                    ParseQuantity<Angle>(body.axis_right_ascension())).
                ToCartesian()) * Radian / Second);
    if (body.has_j2()) {
      typename OblateBody<Frame>::Parameters oblate_body_parameters(
          ParseQuantity<double>(body.j2()),
          ParseQuantity<Length>(body.reference_radius()));
      return std::make_unique<OblateBody<Frame>>(massive_body_parameters,
                                                 rotating_body_parameters,
                                                 oblate_body_parameters);
    } else {
      return std::make_unique<RotatingBody<Frame>>(massive_body_parameters,
                                                   rotating_body_parameters);
    }
  } else {
    return std::make_unique<MassiveBody>(massive_body_parameters);
  }
}
コード例 #2
0
RotatingBody<Frame>::RotatingBody(
    MassiveBody::Parameters const& massive_body_parameters,
    Parameters const& parameters)
    : MassiveBody(massive_body_parameters),
      parameters_(parameters),
      polar_axis_(RadiusLatitudeLongitude(
                      1.0,
                      parameters.declination_of_pole_,
                      parameters.right_ascension_of_pole_).ToCartesian()),
      angular_velocity_(polar_axis_.coordinates() *
                        parameters.angular_frequency_) {}