Mega Code Archive

 
Categories / Ruby / Development
 

Convert the Cartesian point (x,y) to polar (magnitude, angle) coordinates

def polar(x,y)   return Math.hypot(y,x), Math.atan2(y,x) end