本文整理汇总了C++中not_null::EvaluateDegreesOfFreedom方法的典型用法代码示例。如果您正苦于以下问题:C++ not_null::EvaluateDegreesOfFreedom方法的具体用法?C++ not_null::EvaluateDegreesOfFreedom怎么用?C++ not_null::EvaluateDegreesOfFreedom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类not_null
的用法示例。
在下文中一共展示了not_null::EvaluateDegreesOfFreedom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trajectory
void Ephemeris<Frame>::ComputeApsides(not_null<MassiveBody const*> const body1,
not_null<MassiveBody const*> const body2,
DiscreteTrajectory<Frame>& apoapsides1,
DiscreteTrajectory<Frame>& periapsides1,
DiscreteTrajectory<Frame>& apoapsides2,
DiscreteTrajectory<Frame>& periapsides2) {
not_null<ContinuousTrajectory<Frame> const*> const body1_trajectory =
trajectory(body1);
not_null<ContinuousTrajectory<Frame> const*> const body2_trajectory =
trajectory(body2);
typename ContinuousTrajectory<Frame>::Hint hint1;
typename ContinuousTrajectory<Frame>::Hint hint2;
// Computes the derivative of the squared distance between |body1| and |body2|
// at time |t|.
auto const evaluate_square_distance_derivative =
[body1_trajectory, body2_trajectory, &hint1, &hint2](
Instant const& t) -> Variation<Square<Length>> {
DegreesOfFreedom<Frame> const body1_degrees_of_freedom =
body1_trajectory->EvaluateDegreesOfFreedom(t, &hint1);
DegreesOfFreedom<Frame> const body2_degrees_of_freedom =
body2_trajectory->EvaluateDegreesOfFreedom(t, &hint2);
RelativeDegreesOfFreedom<Frame> const relative =
body1_degrees_of_freedom - body2_degrees_of_freedom;
return 2.0 * InnerProduct(relative.displacement(), relative.velocity());
};
std::experimental::optional<Instant> previous_time;
std::experimental::optional<Variation<Square<Length>>>
previous_squared_distance_derivative;
for (Instant time = t_min(); time <= t_max(); time += parameters_.step()) {
Variation<Square<Length>> const squared_distance_derivative =
evaluate_square_distance_derivative(time);
if (previous_squared_distance_derivative &&
Sign(squared_distance_derivative) !=
Sign(*previous_squared_distance_derivative)) {
CHECK(previous_time);
// The derivative of |squared_distance| changed sign. Find its zero by
// bisection, this is the time of the apsis. Then compute the apsis and
// append it to one of the output trajectories.
Instant const apsis_time = Bisect(evaluate_square_distance_derivative,
*previous_time,
time);
DegreesOfFreedom<Frame> const apsis1_degrees_of_freedom =
body1_trajectory->EvaluateDegreesOfFreedom(apsis_time, &hint1);
DegreesOfFreedom<Frame> const apsis2_degrees_of_freedom =
body2_trajectory->EvaluateDegreesOfFreedom(apsis_time, &hint2);
if (Sign(squared_distance_derivative).Negative()) {
apoapsides1.Append(apsis_time, apsis1_degrees_of_freedom);
apoapsides2.Append(apsis_time, apsis2_degrees_of_freedom);
} else {
periapsides1.Append(apsis_time, apsis1_degrees_of_freedom);
periapsides2.Append(apsis_time, apsis2_degrees_of_freedom);
}
}
previous_time = time;
previous_squared_distance_derivative = squared_distance_derivative;
}
}