AltarofScience Posted October 13, 2011 Share Posted October 13, 2011 How do I create a coordinate map in php? I created ordered pairs and I want to plot them on a grid. Grid is about 200000x200000. Quote Link to comment https://forums.phpfreaks.com/topic/249045-coordinate-grid/ Share on other sites More sharing options...
requinix Posted October 13, 2011 Share Posted October 13, 2011 Normally you'd just use a 2D array, but at 40 billion potential points that might not work for you. What do you mean by "create a coordinate map"? What map? What medium? Quote Link to comment https://forums.phpfreaks.com/topic/249045-coordinate-grid/#findComment-1279046 Share on other sites More sharing options...
AltarofScience Posted October 13, 2011 Author Share Posted October 13, 2011 I am making a universe, and I need a map display, so players can navigate it. Technically, you can cut the size down, by displaying only portions of the map, so I think a 2d array might work. You could have the display set to like, show a 10kby10k or 1k by 1k sector of the map. or something. Say you are at a star system and want to see nearby star systems. you would set the display so the coords of that system are at the center, and display: currentx-1000 to currentx+1000 on the x axis and currenty-1000 to currentx+1000 on the y axis. that would only be 4million possible points. and only like, 10 or 20 star systems would actually exist there. i think some people use vrml maps for this kind of thing? when i was googling i got some vrml results. i mean, technically each ordered pair would also have a z coordinate, but i might not use z if it make its too complicated for me to code. Quote Link to comment https://forums.phpfreaks.com/topic/249045-coordinate-grid/#findComment-1279067 Share on other sites More sharing options...
ManiacDan Posted October 13, 2011 Share Posted October 13, 2011 Google does this by only selecting subsets of the data and by storing zoom versions which are calculated periodically. The rest of this post assumes your universe (like the real one) will be very sparsely populated. You will need a sparse matrix setup for one thing. You cannot create 40,000,000,000 empty data points, it just won't work. You will need a table for each zoom level. Start at the bottom. Make a table which contains X, Y, and VALUE (or whatever, I'm just summarizing for effect). Then make a table for the first "zoom out". Write a script that translates every 10x10 grid space on your board to a single pixel. If there is any data inside the range 0 < X < 10, 0 < Y < 10 then put a piece of data in for 1,1 in the first zoom level. Repeat until you have the entire zoom-out map made. Now, repeat this for enough zoom levels to be usable. You will end up with a map where each data point represents "do any of the 1,000,000 data points inside this point have any data at all?" Once you have that, you can print it very easily (as it will fit on a monitor). Now, once the user clicks on this map, figure out where he clicked (simple exercise left up to you) and where in the data he clicked, then load the next zoom level IN for where he clicked, centered around the pixel he clicked on. The pixel he clicked on will now be blown up to a 10x10 area of the next zoom level. Using the above method you'll have 1 "real" data table with X "interpreted" data tables above it representing all the possible zoom levels you support. The users can zoom in and out and even pan through the current zoom level without sacrificing performance. This is nearly exactly the way google maps works, except instead of a single VALUE point (or colored pixel) they obviously have full scale PNG images all knitted together. That's much more difficult, but it's the same theory. They use a lot more calculus to do this than I did. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/249045-coordinate-grid/#findComment-1279071 Share on other sites More sharing options...
AltarofScience Posted October 13, 2011 Author Share Posted October 13, 2011 okay, that is probably enough for me to figure out what i need to do. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/249045-coordinate-grid/#findComment-1279079 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.