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();
}
}
}