Skip to content

Instantly share code, notes, and snippets.

@miura
Created September 4, 2014 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miura/8914620f7ab76c4c94da to your computer and use it in GitHub Desktop.
Save miura/8914620f7ab76c4c94da to your computer and use it in GitHub Desktop.
for (i = 0; i < nResults - 1; i++){
trackID = getResult("Trajectory", i);
nexttrackID = getResult("Trajectory", i + 1);
if (trackID == nexttrackID){
x1 = getResult("x", i);
y1 = getResult("y", i);
x2 = getResult("x", i + 1);
y2 = getResult("y", i + 1);
displacement = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
setResult("Displacement", i, displacement);
} else {
setResult("Displacement", i, NaN);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment