Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double[] Rec2Sph(double x, double y, double z) {
        double[] sph = new double[3];
        sph[0] = Math.sqrt(x * x + y * y + z * z);
        sph[1] = x == 0 ? 0 : Math.atan(Math.abs(y / x));
        if (x < 0)
            sph[1] = Math.PI - sph[1];
        if (y < 0)
            sph[1] *= -1;
        sph[2] = Math.asin(z / sph[0]);
        return sph;
    }
}