Losing points when zooming?!

Hi - new here be gentle!

So I’ve just started out on Processing.
I have ~10000 GPS positions (airports etc) which I wanted to covert to points and display it in a 3D Vector.

All works well. However, when I Zoom in and out points fail to render/or suddenly render.

Any suggestions

Current (messy code below)

import toxi.geom.;
import peasy.
;

PeasyCam jCam;

PrintWriter output;

int Cols = 100;
int Rows = 100;
int ignoreFirstXRowsOfPoints = 1;
//float gridSize = 1;

Point grid[][] = new Point [Cols][Rows];

String [] data;
float x =0 ;
float y =0 ;
float z =0 ;
float maxx =0 ;
float minx =0 ;
float maxy =0 ;
float maxz=0 ;

void setup()
{
size(1000, 1000, P3D); //Size of window

jCam = new PeasyCam(this, 2000); //inital level of zoom

data = loadStrings("\data\points.csv"); //file to read in

int countX = 0;
int countY = 0;

//NEED TO OPEN FILE CHECKS ETC

println(data[0]); //Check first line of file data
for (int i=ignoreFirstXRowsOfPoints; i < data.length; i++) //data is an array of test, containing all coloums/rows
{
//println(data[i]);//print every line of data
String [] fields = split(data[i], ‘,’);
float lat = float(fields[0]);
float lon = float(fields[1]);
float alt = float(fields[2]);
float rad = float(fields[3]);

GPSto3axis(lat, lon, alt, rad);
println(x +", " + y + ", " + z);
if (x > maxx) maxx=x;
if (x < minx) minx=x;
if (y > maxy) maxy=y;
if (z > maxz) maxz=z;


Vec3D pointLoc = new Vec3D(x, y, z);  //add this item to the list of Vector points 

grid[countX][countY] = new Point(pointLoc);

countX++;
if (countX == Cols)
{
  countY++;
  countX=0;
}

}
println(“Max Values: X:” + maxx + “, Y:” + maxy + “, Z:” + maxz);
println(“Min Values: X:” + minx + “, Y:” + maxy + “, Z:” + maxz);
}

void GPSto3axis(float lat, float lon, float alt, float rad)
{
float f = 0;
float ls = atan(((1 - f)*(1 - f)) * tan(lat)); //this should be **2
x = rad * cos(ls) * cos(lon) + alt * cos(lat) * cos(lon);
y = rad * cos(ls) * sin(lon) + alt * cos(lat) * sin(lon);
z = rad * sin(ls) + alt * sin(lat);
}

void draw()
{
background(0);
stroke(255);
noFill();
box(1000);
for (int i=ignoreFirstXRowsOfPoints; i<Cols; i++)
{
for (int j=0; j<Rows; j++)
{
grid[i][j].run();
}
}
}

Please format your code :blush:

It consist on these two steps:

  1. In your code editor (PDE, VS code, Eclipse, etc) ensure you execute the beautifier function. This function automatically indents your code. Auto-indenting makes your code easier to read and helps catching bugs due to mismatch parenthesis, for instance. In the PDE, you use the key combination: ctrl+t
  2. You copy and paste your code in the forum. Then you select the code and you hit the formatting button aka. the button with this symbol: </>

That’s it! Please notice you do not create a new post in case you need to format something you already posted. You can edit your post, copy the code to the PDE, indent the code properly there and then past it back here, format the code and >> save << the edits.

Extra info:

Formatting your code makes everybody’s life easier, your code looks much better plus it ensures your code integrity is not affected by the forum’s formatting (Do you know the forum processes markup code?) Please visit the sticky posts or the FAQ section/post to learn about this, other advantages and super powers you can get in this brand new forum.

Kf

Like kj said, please format your code.

As for the question, can I ask about this line near the end:

grid[i][j].run();

Is this defined in toxi.geom? What exactly does it do?