ScratchData LogoScratchData
Back to gtoal's profile

Fast globe draw attempt (*** WIP ***)

GTgtoal•Created June 29, 2016
Fast globe draw attempt (*** WIP ***)
13
8
203 views
View on Scratch

Instructions

STILL EDITING WIP. Don't use this yet. (I probably shouldn't have shared this until I had got it working, but I was hoping for a little help with the spherical triginometry ;-) ) I thought the Y-projection distortion was pre-built into the 360x180 map, but it looks like it is not. For now I've patched it in the display code but the proper place to fix it is in the 'make lookup table' code. We have a 360x180 map of the Earth, which we'ld like to use to draw a globe on the fly. It's not as fast as I would like, but it's getting there. There area a couple of graphical glitches to be worked on. If you want it pretter, draw at a scale of 2X using a larger pen. Image extracted from Wes64's project. Code rewritten to use a lookup table that maps a screen X/Y coordinate onto a 180x180 window on the map. Globe rotation is done by adding the x component of that mapping to the rotation angle. Fast shading and specular reflection hacks will follow after the basic globe drawing works reliably.

Description

Still not finished with the mapping algorithm: I need to map Y vertically same as I'm mapping x horizontally And I'm not convinced that the edge distortion is correct. We take a 180 degree window on the Mercator projected map (360x180) and we reverse the projection back to one half of a sphere, and then re-project the face of that sphere onto a 2D circle of radius 90 pixels. Except that instead of drawing those pixels directly, we generate a lookup table to map from the screen pixels to the original map pixels. Then a filled-circle drawer uses that lookup to draw the actual image. Although multiple locations on the Mercator map will project on to a single pixel on the circle, we only keep one of them - this is part of what gives us a speed up, because we only ever draw pixels that we can see - the others are skipped. Rotating the earth becomes trivial, by adding the rotation angle to the looked-up x coordinate within the map (mod 360).

Project Details

Project ID115140282
CreatedJune 29, 2016
Last ModifiedJuly 1, 2016
SharedJune 29, 2016
Visibilityvisible
CommentsAllowed

Remix Information

Parent ProjectView Parent
Root ProjectView Root