Computes the angle (in degrees) between a line,
defined by two points with coordinates (x0
, y0
)
and (x1
, y1
), and the specified axis.
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.
References
Pfister, R., Tonn, S., Schaaf, M., Wirth, R. (2024). mousetRajectory: Mouse tracking analyses for behavioral scientists. The Quantitative Methods for Psychology, 20(3), 217-229. doi:10.20982/tqmp.20.3.p217
Examples
# Note that not the mathematical definition of angle is used by default:
starting_angle(0, 1, 0, 0)
#> [1] 90
starting_angle(0, 1, 0, 0, swap_x_y = FALSE)
#> [1] 0
# 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)
#> [1] -135
starting_angle(0, 1, 0, -1, swap_x_y = FALSE)
#> [1] -45