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