mapping latitude/longitude to a textured sphere
in
Programming Questions
•
1 years ago
I'm trying to do a quick sketch mapping the top 100 to a globe. I'm using the textured sphere example to draw the globe but I cant get the lat/lon to map to the sphere. I know this has been asked before but I cant find what I'm doing wrong. I uploaded the sketch here www.ekeneijeoma.com/processing/Globe_Test.zip and pasted the code I'm using to do the mapping below... Thanks!
- public void drawMarkers() {
- for (int i = 0; i < cities.length; i++) {
- Marker m = cities[i];
- pushMatrix();
- // Vec3D v = new Vec3D(globeRadius - 50, radians(c.lat) - PI,
- // radians(c.lon)).toCartesian();
- // translate(v.x, v.y, v.z);
- float radius = 150.0f;
- float lat = radians(m.lat);
- float lon = radians(m.lon);
- float x = radius * sin(lat) * cos(lon);
- float y = radius * sin(lat) * sin(lon);
- float z = radius * cos(lat);
- // float y = -radius * sin(lat);
- // float x = -radius * cos(lat) * cos(lon);
- // float z = radius * sin(lon) * cos(lat);
- translate(x, y, z);
- noStroke();
- fill(255, 0, 0);
- sphere(5);
- popMatrix();
- }
- }
1