/// <summary> /// Transforms Cartesian coordinates to polar. /// </summary> /// <param name="x">A real number representing the x-coordinate.</param> /// <param name="y">A real number representing the y-coordinate.</param> /// <param name="r">Output parameter, the real number representing the polar radius.</param> /// <param name="theta">Output parameter, the real number representing the polar angle.</param> public static void CartesianToPolar(double x, double y, out double r, out double theta) { r = ExMath.Hypot(x, y); theta = Math.Atan2(y, x); }
/// <summary> /// Transforms Cartesian coordinates to cylindrical. /// </summary> /// <param name="x">A real number representing the x-coordinate.</param> /// <param name="y">A real number representing the y-coordinate.</param> /// <param name="z">A real number representing the z-coordinate.</param> /// <param name="r">Output parameter, the real number representing the radial distance.</param> /// <param name="theta">Output parameter, the real number representing the azimuthal angle.</param> public static void CartesianToCylindrical(double x, double y, double z, out double r, out double theta) { r = ExMath.Hypot(x, y); theta = Math.Atan2(y, x); }