starting_angle {mousetRajectory} | R Documentation |
Starting angle
Description
Computes the angle (in degrees) between a line,
defined by two points with coordinates (x0
, y0
)
and (x1
, y1
), and the specified axis.
Usage
starting_angle(x0, x1, y0, y1, swap_x_y = TRUE)
Arguments
x0 |
x-value of the first point. |
x1 |
x-value of the second point. |
y0 |
y-value of the first point. |
y1 |
y-value of the second point. |
swap_x_y |
Whether to compute the angle relative to the x or y axis.
Defaults to |
Details
If the angle is computed relative to the x axis, counterclockwise changes are counted as positive. If the angle is computed relative to the y axis, clockwise changes are counted as positive.
Value
Angle in degrees with -180 <= angle <= 180
.
References
Wirth, R., Foerster, A., Kunde, W., & Pfister, R. (2020). Design choices: Empirical recommendations for designing two-dimensional finger tracking experiments. Behavior Research Methods, 52, 2394 - 2416. doi:10.3758/s13428-020-01409-0
Examples
# Note that not the mathematical definition of angle is used by default:
starting_angle(0, 1, 0, 0)
starting_angle(0, 1, 0, 0, swap_x_y = FALSE)
# angles are clockwise and relative to the y-axis.
# Note that return values are in the range [-180, 180], not [0, 360]:
starting_angle(0, -1, 0, -1)
starting_angle(0, 1, 0, -1, swap_x_y = FALSE)