# Coordinate Mapping?

I saw the Twingly.com screensaver the other day, and I thought about making a QC clone of it, but I have no idea how to map geographic coordinates to the sphere patch, and to the appropriate points on whatever map texture I use. Does anyone have any suggestions?

## Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

### UV

UV corresponds to the longitude and latitude of the sphere. So depending on the conversion direction, it's a polar to cartesian, or cartesian to polar conversion (actually, spherical rather than polar, but the math is very similar, just 3d instead of 2d).

Google "Cartesian spherical conversion", or visit http://www.gamedev.net/community/forums/topic.asp?topic_id=309804 or hit up any math text book worth its salt.

### Unfortunately the portion of

Unfortunately the portion of my brain responsible for math has atrophied to a small grayish lump that rattles around in my head, and doesn't do much.

I understand the fundamentals of what you're saying, and I've read a ton of stuff on Google today regarding it, I just don't quite get the implementation. Not to mention I'm not quite sure what UV is, but I'll take your word for it :D

I thought about trying it out in Javascript (was helpful, sortof), but then I realized I know absolutely nothing about Javascript.

I think I probably should have paid more attention in math class, instead of drawing all over things.

### maths

(UV are the texture coordinates, sort of like X and Y, but spread across a surface, instead of on a plane)

So, your inputs are longitude/latitude? And what are the outputs? Are you going to render to a texture that gets placed on a sphere? If that's the case, you need to convert lat/lon (spherical coords) to cartesian (XY or UV coords, for a flat texture).

I can't figure out how to get meaningful data from twingly (only spent 5 seconds looking at the website though), so I can't really test to make sure that's the conversion you need.

Here's a sample compo that shows the general idea.

PreviewAttachmentSize
latlon.qtz177.91 KB

### Ah that's exactly it, thank

Ah that's exactly it, thank you. I've been hammering on it tonight, trying to figure out the distortions in the map, testing various latitude and longitude. I realized that the Mercator projection that I've been using is distorted. As you get farther away from the Equator, there's a larger degree of distortion.

I originally wanted to use this for Twingly, but I didn't see any sort of API to use with it. So I'm going to try Flickr or maybe Twitter (once they turn on their "firehose" functionality) using their geolocation data, perhaps I could pull something from Yahoo's Fire Eagle project.

I think a few people could get some use out of this. I seem to remember a QC/Cocoa project someone was working on that plotted flight paths from airport to airport. I'll have to see if I can find that, and figure out how the author over came this issue.