限制性三体问题的方程为
其中
前两个解分量是微小物体的坐标,因此针对一个分量绘制另一个分量可以得到物体的轨迹。
orbitode.m 中嵌套的事件函数将搜索两个事件。一个事件查找距离起点最远的点,另一个事件查找宇宙飞船返回到起点的点。即使积分器使用的步长并非通过事件位置确定,也会准确定位事件。在此示例中,指定过零方向的功能非常重要。返回到起点的点和距离起点最远的点具有相同的事件值,并由交叉方向来区分这两个点。为此行为编码的事件函数为
function [value,isterminal,direction] = orbitEvents(t,y)
% dDSQdt is the derivative of the equation for current distance. Local
% minimum/maximum occurs when this value is zero.
dDSQdt = 2 * ((y(1:2)-y0(1:2))' * y(3:4));
value = [dDSQdt; dDSQdt];
isterminal = [1; 0]; % stop at local minimum
direction = [1; -1]; % [local minimum, local maximum]
end
键入 orbitode 以运行该示例。
orbitode
This is an example of event location where the ability to
specify the direction of the zero crossing is critical. Both
the point of return to the initial point and the point of
maximum distance have the same event function value, and the
direction of the crossing is used to distinguish them.
Calling ODE45 with event functions active...
Note that the step sizes used by the integrator are NOT
determined by the location of the events, and the events are
still located accurately.