1. var mvdist,dvx,dvy;
  2. mvdist=point_distance(xprevious,yprevious,x,y);
  3. if (mvdist) { // this precaution needs to be taken, in order to avoid a possible "DIVIDE BY ZERO" numeric exception
  4. dvx=(x-xprevious)/mvdist;
  5. dvy=(y-yprevious)/mvdist;
  6. }
  7. else {dvx=0; dvy=0}