Distance vs displacement: handling zero-velocity crossings in JavaScript
A physics graphing widget can report correct displacement yet an incorrect distance if each trapezoid's absolute value is taken when the interval crosses zero velocity. Area above and below the axis cancels within such a trapezoid, hiding the true distance. The article illustrates this with a 4-second interval moving from +3 m/s to −1 m/s, where displacement is 4 m but distance is 5 m. It presents a JavaScript function that splits crossing segments at the zero point and sums the two parts separately. Summing signed displacements and unsigned distances across sampled points yields exact results for piecewise-linear graphs, though curved segments only give approximations.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in