View source: R/angle_convert.R
car2deg | R Documentation |
Convert Cartesian coordinates x and y to angle degrees
car2deg(x, y)
x |
a numeric vector of x coordinates in the Cartesian plane |
y |
a numeric vector of y coordinates in the Cartesian plane |
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)
a numeric vector of corresponding angle degrees (anticlockwise direction)
x <- c(1, 1, 0, -1, -1, -1, 0, 1) y <- c(0, 1, 1, 1, 0, -1, -1, -1) car2deg(x, y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.