@technobuddha/library
Version:
A large library of useful functions
12 lines (11 loc) • 355 B
JavaScript
import { normalizeAngle } from '../normalizeAngle';
/**
* Convert cartesian coordinates to polar
*
* @param __namedParameters see {@link Cartesian}
* @returns polar coordinated
*/
export function toPolar({ x, y }) {
return { radius: Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)), angle: normalizeAngle(Math.atan2(y, x)) };
}
export default toPolar;