Turn Angle¶
-
class
ollin.movement_analyzers.turn_angle.
Analyzer
(movement)[source]¶ Turn Angle analyzer.
Turn angle refers to the angle formed by two successive steps of an individual motion.
Hence if \(p(t_0) = (x_0, y_0)\), \(p(t_1) = (x_1, y_1)\) and \(p(t_2) = (x_2, y_2)\) are the positions of an individual at times \(t_0, t_0\) and \(t_2\) then the turn angle at time \(t_1\) is defined by:
\[ \begin{align}\begin{aligned}d_1 = (x_1 - x_0, y_1 - y_0)\\d_2 = (x_2 - x_1, y_2 - y_1)\\ta = \arccos\left(\frac{d_1 \cdot d_2}{||d_1|| \cdot ||d_2||}\right)\end{aligned}\end{align} \]Here \(ta\) is turn angle.
-
analyze
(movement)[source]¶ Extract turn angles from movement data.
Get the turn angles of all individuals in movement data at every time step. Will result in an array of size [num_individuals, time_steps - 2] so that:
turn_angle = results[i, k]
Means that the
i
-th individual had a turn angle ofturn_angle
at thek
-th time step.Parameters: movement ( Movement
) – Movement data to analyzeReturns: results – Array of shape [num_individuals, time_steps - 1] containing the turn angles of all individuals at every time step. Return type: array
-
plot
(ax=None, figsize=(10, 10), num_individual=0, bins=20, width=None, cmap='Reds', alpha=0.8, log=True)[source]¶ Plot distribution of turning angles.
Parameters: - ax (
matplotlib.axes.Axes
, optional) – Axes object in which to plot. - figsize (tuple or list, optional) – Size of figure to create if no axes are provided.
- num_individual (int or tuple or list or array, optional) – Selection of individuals from which to draw turning angle information. If num_individual=’all’, all information will be plotted.
- bins (int, optional) – Number of bins to use in histogram of turn angle distribution. Defaults to 20.
- width (float, optional) – Width of bars in histogram. If none is given, width will be maximum possible before overlap.
- cmap (str, optional) – Colormap to use to assign colors to histogram bars. Defaults to ‘Reds’.
- alpha (float, optional) – Alpha value of plot. Defaults to 0.8.
- ax (
-