function ret = calculateCaptureVelocity(this, PositionVector, VelocityVector) VelocityVector = VelocityVector./norm(VelocityVector); UpperLimit = 500; LowerLimit = 0; this.AtomicBeamCollision = false; for Index = 1:500 InitialVelocity = 0.5 * (UpperLimit + LowerLimit) * VelocityVector; [~, FinalDynamicalQuantities] = this.solver(PositionVector, InitialVelocity); FinalPositionVector = FinalDynamicalQuantities(1:3); if rssq(FinalPositionVector) <= this.OvenDistance LowerLimit = 0.5 * (UpperLimit + LowerLimit); else UpperLimit = 0.5 * (UpperLimit + LowerLimit); end if UpperLimit - LowerLimit < 1 ret = InitialVelocity; break; end end end