Calculating the angular velocity from x, y coordinate data

4.6k Views Asked by At

I have some video footage where I'm tracking insects over several hundred to thousand frames, resulting in a list of x, y coordinates for where the insect has been. I've found it pretty straight-forward to calculate the linear velocity of the insect (sum up the distance it has travelled between each frame per second), however I'm not sure how to use this data to calculate the angular velocity. I realise I should smooth out the data and only take a coordinate every second or so (the insect doesn't move that far during between each individual frame), however I'm rather stuck with where to go from here. The way I'm trying to conceptualise this in my head is to think of the angle between every 5th point as part of a circle and then I should calculate the angle from that?

This is an example of what the X and Y coordinates are over the course of a second of footage (25 fps).

1623.5 1861
1623.5 1860.5
1623.5 1861
1623 1860.5
1623.5 1860.5
1623.5 1860.5
1623.5 1860.5
1623 1861
1623.25 1860.75
1622.76 1861.06
1623.5 1861.5
1623.25 1861.75
1623.5 1862
1623.5 1862
1623.5 1861
1623.5 1860.5
1623.5 1860.5
1623.5 1861.5
1623.5 1861
1623.5 1861.5
1623.5 1862
1623.5 1861
1623.5 1861.5
1623 1861
1623.5 1861

1

There are 1 best solutions below

7
On BEST ANSWER

By "angular velocity" do you mean the rate of change of the direction angle of the vector from the origin to the insect?

If so, just use the atan2 function to calculate the direction angle to point $(x,y)$, and find the average rate of change of that quantity between two sample points.

Or do you mean something else by "angular velocity", such as the curvature?

ADDED:

You say you want "how often and sharply the insect is turning as it walks along its path." That could only be determined from your "list of x,y coordinates" if you assume that the insect always walks forward. Under that assumption, you want to find the rate of change of the direction angle of the insect's motion. (This attribute does not use the origin, unlike the other meaning of "angular velocity.")

Here is one quick way to estimate that rate of change. Let $(x_i,y_i)$ be the position where you want to know that rate of turning. $(x_{i-1},y_{i-1})$ and $(x_{i+1},y_{i+1})$ are the previous and next points you sampled, and $t_i$, $t_{i-1}$, and $t_{i+1}$ are the corresponding times. Then you want

$$\frac{\operatorname{atan2}(x_{i+1}-x_i,y_{i+1}-y_i)-\operatorname{atan2}(x_i-x_{i-1},y_i-y_{i-1})}{t_i-t_{i-1}}$$

There are other ways, more accurate and more complicated, to estimate this quantity, which assume a certain amount of smoothness in the path. You also should check that the result is not too large: that would happen in a few cases, and if that happens reduce the numerator in that fraction by a value of $2\pi$ to get it closer to zero.