More efficient implementatin of LinearTrajectory.