polar to cartesian java

Solutions on MaxInterview for polar to cartesian java by the best coders in the world

showing results for - "polar to cartesian java"
Cyrus
20 Feb 2017
1public static double[] pol(double x, double y) {
2	//return new double[]{Math.sqrt(x * x + y * y), Math.atan2(y, x)}; //red
3	return new double[]{Math.sqrt(x * x + y * y), (Math.atan2(y, x) * 180) / Math.PI}; //cart
4}
Julian
29 Aug 2018
1static double[] cari(double r, double theta) {
2    theta = (theta / 180) * Math.PI;
3    return new double[]{r * Math.cos(theta), r * Math.sin(theta)};
4}