Here’s the code using the @jb4x suggestion,Thanks It works now. It was locking up trying to println.

```
float[] x = new float[3600];
float[] y = new float[3600];
// double GHA = Math.toRadians(162.3366651);
double GHA = Math.toRadians(-38.6552);
// double dec = Math.toRadians(42);
double dec = Math.toRadians(62);
// double dec = mouseY;
double Be = Math.toRadians(35.4000);
double Le = Math.toRadians(26.452837);
double[]vv = new double[3]; //, vy[3], vyz[3];
double[]vy = new double[3];
double[]vyz = new double[3];
double[]wpt = new double[3600];
float[]WPT = new float[3600];
double[][]My = new double[3][3];
double[][]Mz = new double[3][3];
void setup() {
size(400, 300, P3D);
smooth();
noFill();
}
void draw() {
background(0);
pushMatrix();
dec = map(mouseY,height-height,height,90,-90);
println(dec);
x = new float[3600];
y = new float[3600];
// noLoop();
getPoints();
popMatrix();
}
void getPoints(){
Mz = Rz(Math.toRadians(360.0) - GHA, Mz);
// println(Mz[0][0] + " " + Mz[0][1] + " " + Mz[0][2]);
// println(Mz[1][0] + " " + Mz[1][1] + " " + Mz[1][2]);
// println(Mz[2][0] + " " + Mz[2][1] + " " + Mz[2][2]);
My = Ry(Math.toRadians(90.0) - dec, My);
// println(My[0][0] + " " + My[0][1] + " " + My[0][2]);
// println(My[1][0] + " " + My[1][1] + " " + My[1][2]);
// println(My[2][0] + " " + My[2][1] + " " + My[2][2]);
int w = 0;
for( double L0 = -180.0; L0 <= 180.0; L0 += .1 )
{
//float alt = map(mouseX,width-width,width,0,90);
vv = VectorSpherical2Cartesian(Math.toRadians(62.5),Math.toRadians(L0) );
// vv = VectorSpherical2Cartesian(alt,Math.toRadians(L0) );
vy = MatrixVecProd( My, vv, vy );
vyz = MatrixVecProd( Mz, vy, vyz );
wpt[w] = C2ELat( vyz[0], vyz[1], vyz[2]);
wpt[w+1] = C2ELon( vyz[0], vyz[1], vyz[2]);
WPT = toFloatArray(wpt);
x[w] = map(WPT[w+1],radians(-180) ,radians(180),width, width - width);
y[w] = map(WPT[w],radians(-90),(radians(90)),height,height - height);
point(x[w],y[w]);
noFill();
stroke(0,255,0);
strokeWeight(2);
beginShape();
curveVertex(x[w],y[w]);
curveVertex(x[w],y[w]);
endShape();
}
}
//Funcition to convert double[] to float[]
float[] toFloatArray(double[] arr) {
if (arr == null) return null;
int n = arr.length;
float[] ret = new float[n];
for (int i = 0; i < n; i++) {
ret[i] = (float)arr[i];
}
return ret;
}
// end of function to convert double[] to float[]
double[] VectorSpherical2Cartesian(double B, double L){
double v[] = new double[3];
v[0] = Math.cos(B) * Math.cos(L);
v[1] = Math.cos(B) * Math.sin(L);
v[2] = Math.sin(B);
// println(B);
// println(L);
return(v);
}
public double C2ELat( double x, double y, double z )
{
double[]res = new double[3];
res[0] = Math.sqrt( x*x+y*y+z*z); //R
//*B = ASIN(z/(*R));
res[1] = Math.atan2( z, Math.sqrt(x*x+y*y) ); //B
res[2] = Math.atan2( y, x ); //L
//println("R: " + (res[0]) + " B: " + Math.toDegrees(res[1]) + " L: " + Math.toDegrees(res[2]));
return (res[1]);
//println(R);
}
public double C2ELon( double x, double y, double z )
{
double[]res = new double[3];
res[0] = Math.sqrt( x*x+y*y+z*z); //R
//*B = ASIN(z/(*R));
res[1] = Math.atan2( z, Math.sqrt(x*x+y*y) ); //B
res[2] = Math.atan2( y, x ); //L
//println("R: " + (res[0]) + " B: " + Math.toDegrees(res[1]) + " L: " + Math.toDegrees(res[2]));
return (res[2]);
//println(R);
}
//public double[] E2C( double B, double L, double R, double x, double y, double z )
public double[] E2C( double B, double L, double R )
{
double[]res = new double[3];
res[0] = R*Math.cos((B))*Math.cos((L));
res[1] = R*Math.cos((B))*Math.sin((L));
res[2] = R*Math.sin((B));
// println(res[0] + " " + res[1] + " " + res[0]);
return(res);
}
public double[][] Rx( double a, double[][] M ){
M[0][0] = 1.0;
M[1][0] = 0.0;
M[2][0] = 0.0;
M[0][1] = 0.0;
M[1][1] = Math.cos(a); //Math.cos(Math.toRadians(a));
M[2][1] = Math.sin(a); //Math.sin(Math.toRadians(a));
M[0][2] = 0.0;
M[1][2] = -Math.sin(a); //-Math.sin(Math.toRadians(a));
M[2][2] = Math.cos(a); //Math.cos(Math.toRadians(a));
return(M);
}
public double[][] Ry( double a, double[][] M ){
M[0][0] = Math.cos(a);
M[1][0] = 0.0;
M[2][0] = -Math.sin(a);
M[0][1] = 0.0;
M[1][1] = 1.0;
M[2][1] = 0.0;
M[0][2] = Math.sin(a);
M[1][2] = 0.0;
M[2][2] = Math.cos(a);
return(M);
}
public double[][] Rz( double a, double[][] M ){
M[0][0] = Math.cos(a); //Math.cos(a);
M[1][0] = Math.sin(a);
M[2][0] = 0.0;
M[0][1] = -Math.sin(a);
M[1][1] = Math.cos(a);
M[2][1] = 0.0;
M[0][2] = 0.0;
M[1][2] = 0.0;
M[2][2] = 1.0;
return(M);
}
public double[] MatrixVecProd( double[][] A, double[] v, double[] res ) {
int i,j;
int n = 3;
for( i=0; i<n; i++ ) {
res[i] = 0.0;
for( j=0; j<n; j++ ) {
res[i] += A[i][j]*v[j];
}
}
return (res);
}
```