car2deg_N: Cartesian x, y to angle degrees from the North (compass...

View source: R/angle_convert.R

car2deg_NR Documentation

Cartesian x, y to angle degrees from the North (compass direction)

Description

Convert Cartesian coordinates x and y to angle degrees from the North direction, i.e. the compass direction

Usage

car2deg_N(x, y)

Arguments

x

a numeric vector of x coordinates in the Cartesian plane

y

a numeric vector of y coordinates in the Cartesian plane

Details

By approaching the problem with the use of complex numbers (strange enough but it's easier!) If z = x + i*y with real x and y r = Mod(z) = sqrt(x^2 + y^2) phi = Arg(z) x = r * cos(phi) y = r * sin(phi)

Value

a numeric vector of corresponding angle degrees direction from the North (compass direction)

Examples

x <- c(1, 1, 0, -1, -1, -1,  0,  1)
y <- c(0, 1, 1,  1,  0, -1, -1, -1)
car2deg_N(x, y)

maxbre/rfunctions documentation built on Nov. 19, 2022, 5:46 p.m.