Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 815f44e

Browse files
committedMar 30, 2017
after pleroy's review
1 parent 7eeb46e commit 815f44e

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed
 

‎physics/body_centred_body_direction_dynamic_frame.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ class BodyCentredBodyDirectionDynamicFrame
8383
not_null<Ephemeris<InertialFrame> const*> const ephemeris_;
8484
MassiveBody const* const primary_;
8585
not_null<MassiveBody const*> const secondary_;
86+
std::function<Vector<Acceleration, InertialFrame>(
87+
Position<InertialFrame> const& position,
88+
Instant const& t)> compute_gravitational_acceleration_on_primary_;
8689
std::function<not_null<Trajectory<InertialFrame> const*>()> const
8790
primary_trajectory_;
8891
not_null<ContinuousTrajectory<InertialFrame> const*> const

‎physics/body_centred_body_direction_dynamic_frame_body.hpp

+24-16
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,36 @@ using quantities::si::Radian;
2727

2828
template<typename InertialFrame, typename ThisFrame>
2929
BodyCentredBodyDirectionDynamicFrame<InertialFrame, ThisFrame>::
30-
BodyCentredBodyDirectionDynamicFrame(
31-
not_null<Ephemeris<InertialFrame> const*> const ephemeris,
32-
not_null<MassiveBody const*> const primary,
33-
not_null<MassiveBody const*> const secondary)
30+
BodyCentredBodyDirectionDynamicFrame(
31+
not_null<Ephemeris<InertialFrame> const*> const ephemeris,
32+
not_null<MassiveBody const*> const primary,
33+
not_null<MassiveBody const*> const secondary)
3434
: ephemeris_(ephemeris),
3535
primary_(primary),
3636
secondary_(secondary),
37+
compute_gravitational_acceleration_on_primary_(
38+
[this](Position<InertialFrame> const& position, Instant const& t) {
39+
return ephemeris_->ComputeGravitationalAccelerationOnMassiveBody(
40+
primary_, t);
41+
}),
3742
primary_trajectory_([t = ephemeris_->trajectory(primary_)] { return t; }),
3843
secondary_trajectory_(ephemeris_->trajectory(secondary_)) {}
3944

4045
template<typename InertialFrame, typename ThisFrame>
4146
BodyCentredBodyDirectionDynamicFrame<InertialFrame, ThisFrame>::
42-
BodyCentredBodyDirectionDynamicFrame(
43-
not_null<Ephemeris<InertialFrame> const*> ephemeris,
44-
std::function<not_null<Trajectory<InertialFrame> const*>()>
45-
primary_trajectory,
46-
not_null<MassiveBody const*> secondary)
47+
BodyCentredBodyDirectionDynamicFrame(
48+
not_null<Ephemeris<InertialFrame> const*> ephemeris,
Has a conversation. Original line has a conversation.
49+
std::function<not_null<Trajectory<InertialFrame> const*>()>
50+
primary_trajectory,
51+
not_null<MassiveBody const*> secondary)
4752
: ephemeris_(ephemeris),
4853
primary_(nullptr),
4954
secondary_(secondary),
55+
compute_gravitational_acceleration_on_primary_(
56+
[this](Position<InertialFrame> const& position, Instant const& t) {
57+
return ephemeris_->ComputeGravitationalAccelerationOnMasslessBody(
58+
position, t);
59+
}),
5060
primary_trajectory_(primary_trajectory),
5161
secondary_trajectory_(ephemeris_->trajectory(secondary_)) {}
5262

@@ -117,15 +127,13 @@ MotionOfThisFrame(Instant const& t) const {
117127
DegreesOfFreedom<InertialFrame> const secondary_degrees_of_freedom =
118128
secondary_trajectory_->EvaluateDegreesOfFreedom(t);
119129

130+
// TODO(egg): eventually we want to add the intrinsic acceleration here.
120131
Vector<Acceleration, InertialFrame> const primary_acceleration =
121-
// TODO(egg): eventually we want to add the intrinsic acceleration here.
122-
primary_ == nullptr
123-
? ephemeris_->ComputeGravitationalAccelerationOnMasslessBody(
124-
primary_degrees_of_freedom.position(), t)
125-
: ephemeris_->ComputeGravitationalAccelerationOnMassiveBody(primary_,
126-
t);
132+
compute_gravitational_acceleration_on_primary_(
133+
primary_degrees_of_freedom.position(), t);
134+
127135
Vector<Acceleration, InertialFrame> const secondary_acceleration =
128-
ephemeris_->ComputeGravitationalAccelerationOnMassiveBody(secondary_, t);
136+
-ephemeris_->ComputeGravitationalAccelerationOnMassiveBody(secondary_, t);
129137

130138
auto const to_this_frame = ToThisFrameAtTime(t);
131139

0 commit comments

Comments
 (0)
Please sign in to comment.