The basic lerp formula was fine, I wrote it out quickly.
Start by writing the simple linear interpolation function for two points, then explain how to extend it to a polyline by finding the correct segment and interpolating within it. Finally, discuss handling t outside [0,1] via clamping or extrapolation, and mention floating-point precision strategies like using epsilon comparisons and stable arithmetic.
Pro tip: Mention that for polylines, precomputing cumulative segment lengths enables arc-length parameterization, which is often more useful in ML applications like trajectory prediction. Also, note that clamping t is common but extrapolation might be needed for animation or forecasting.
Write a function that takes P0, P1, and t, and returns P0 + t*(P1 - P0). This works for any dimension, including 3D.
For N points, compute the total number of segments (N-1). Map t to a segment index and local parameter, then interpolate within that segment.
Decide whether to clamp t to [0,1] or allow extrapolation. Clamping is typical for interpolation; extrapolation extends the first/last segment linearly.
Use epsilon-based comparisons when mapping t to segments, and consider using double precision or compensated summation for cumulative lengths to avoid drift.
Mention uniform vs. arc-length parameterization, and how this relates to ML tasks like motion prediction or data augmentation.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.