Skip to contents

The difference to_angle - from_angle, wrapped to (-pi, pi] so that it is the shorter way round the circle rather than the arithmetic difference. This is the primitive the circular summaries are built on.

Usage

circ_difference(from_angle, to_angle)

Arguments

from_angle

A numeric vector of angles, in radians.

to_angle

A numeric vector of angles, in radians.

Value

Numeric vector of signed angular differences in (-pi, pi], positive anticlockwise.

Examples

# a tenth of a turn, not nine tenths
circ_difference(0.1, 6.1)
#> [1] -0.2831853

circ_difference(c(0, pi / 2), c(pi / 2, 0))
#> [1]  1.570796 -1.570796