# Coordenate Cartesian to Polar
cart2polar = function(x, y, rad = TRUE)
{
toRad = pi/180
x = x #* toRad
y = y #* toRad
r = sqrt(x^2 + y^2) #/ toRad
if(rad) theta = (atan2(y, x) + (2*pi)) %% (2*pi)
else theta = (atan2(y, x) / toRad + 360) %% 360
out = data.frame("rho" = r, "theta" = theta)
return(out)
}#end cart2polar
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.