import java.util.*;
import java.lang.*;

public class sphereMesh
{
    
    
    double mesh[][][];
    
    public sphereMesh(int M,int N)
    {
	mesh = new double[M][N][3];
	double u =  0.0;
	double v =  0.0;
	double theta;
	double phi;

        for (int i = 0; i < M; i++)
            for (int j = 0; j < N; j++) {
                u = i / (M - 1.0);
                v = j / (N - 1.0);

                theta = 2 * u * Math.PI;
                phi = (Math.PI * v) - (Math.PI / 2);

                mesh[i][j][0] = Math.cos(theta) * Math.cos(phi);
                mesh[i][j][1] = Math.sin(theta) * Math.cos(phi);
                mesh[i][j][2] = Math.sin(phi);
            }


    }

}

