It is possible to have zero displacement (back to original point) but the distance traveled is not zero.

For 2D case if you wan to calculate distance traveled=d.

define coordinate x,y and xs,ys (xs=x,ys=y, initially).

set d=0 at initialize page.

Assume evolution page is

dx/dt=vx;

dy/dt=vy;

At constraint page add the following lines:

d+= Math.sqrt((x-xs)*(x-xs)+(y-ys)*(y-ys));

xs=x;

ys=y;

Then, d is the distance traveled in 2D plane.