Create and export headings

hdg_norm(hdg)

uv(u, v)

uv_norm(uv)

uv_from_hdg(hdg)

hdg_from_uv(uv)

rad_from_hdg(hdg)

hdg_from_rad(rad)

Arguments

hdg

A heading in degrees, where 0 is north, 90 is east, 180 is south, and 270 is west. Values outside the range [0-360) are coerced to this range using hdg_norm().

uv, u, v

A data.frame with columns u (magnitude east) and v (magnitude north).

rad

An angle in radians such that a hdg of 90 is zero radians and a hdg of 0 is pi / 2 radians.

Examples

hdg_norm(-10:10)
#> [1] 350 351 352 353 354 355 356 357 358 359 0 1 2 3 4 5 6 7 8 #> [20] 9 10
hdg_from_uv(uv(1, 0))
#> [1] 90
uv_from_hdg(5:10)
#> u v #> 1 0.08715574 0.9961947 #> 2 0.10452846 0.9945219 #> 3 0.12186934 0.9925462 #> 4 0.13917310 0.9902681 #> 5 0.15643447 0.9876883 #> 6 0.17364818 0.9848078
uv_norm(uv(2, 0))
#> u v #> 1 1 0