Below is some code that numerically solves a 2D lossless ballistic flight. r[t] is essentially {x[t],y[t]} as a 2-vector. I try to stop integration when the projectile hits the ground as given by r[t][[2]]<0, but WhenEvent does not seem to recognize the syntax. Is there something wrong with my code?
Thank you, Ivan. But I think the domain I get for the interpolating function solution is {0,8}, which is the full extent of the integration time, without stopping at t=6, where r[t][[2]] becomes negative from above.
Yes! Thank you, Ivan. That works fine. And the plot is correct if plotted {t,0,tf}.
The mistake was mine in thinking a semicolon could separate parts of a compound statement as actions for WhenEvent. The documentation says actions in a list are evaluated sequentially.