cart2polar
assumes 0 ,0 origin; I need to know how to change it.
My origin is the x and y
y <- 0.23
x <- 81.05
cart2polar <- function(x, y) {
data.frame(theta = sqrt(x^2 + y^2), r = atan2(x,y))
}
cart2polar
assumes 0 ,0 origin; I need to know how to change it.
My origin is the x and y
y <- 0.23
x <- 81.05
cart2polar <- function(x, y) {
data.frame(theta = sqrt(x^2 + y^2), r = atan2(x,y))
}
You would simply subtract the origin points from the data. However, your current function is wrong. You have the
theta
as a Pythagorean distance andr
as the angle. You also have the arguments inatan2
round the wrong way.The corrected function should be:
In your case you would use it as follows:
For example, polar co-ordinates from the origin would look like this:
But from your new origin would be: