CalcReorientAngle.m 831 B

123456789101112131415161718192021222324252627282930
  1. function beta = CalcReorientAngle(vtheta, moves_indx)
  2. %CALCREORIENTANGLE
  3. % Usage: beta = CalcReorientAngle(vtheta, moves_indx)
  4. %
  5. % This function calculates the reorientation angle, or the change in angle
  6. % of progression after the fly stops. The inputs are the angle of the
  7. % velocity vector, vtheta, and an index of all the frames where the fly was
  8. % moving, moves_indx.
  9. %Written by Dan Valente
  10. %modified November 2007
  11. m = 1;
  12. before = 0;
  13. for i = 1:length(moves_indx)-1
  14. if (moves_indx(i)+1 ~= moves_indx(i+1))
  15. beta(m) = 180*(vtheta(moves_indx(i))-before)/pi;
  16. if (beta(m) > 180)
  17. beta(m) = beta(m)-360;
  18. elseif (beta(m) < -180)
  19. beta(m) = beta(m)+360;
  20. end
  21. before = vtheta(moves_indx(i+1));
  22. m = m+1;
  23. end
  24. end
  25. return;