Adding custom map projections

Adding custom map projections

Return to topic list

Sat Aug 8 18:06:48 2020   by   ostensiblyCreative
I would like to add the Azimuthal Equidistant projection to this program for personal use. I have some experience with a few languages, specifically Python, C++, and Java. What language is this coded in, and how feasible would it be to add a new map projection option to the code?
 
Mon Aug 10 11:00:01 2020   by   Torben
The program is coded in C.  It is not terribly difficult yo add new projections if you know the formulae for converting latitude and longitude into 3D coordinates.  You need to add a case for the command-line parameter selecting projections, and you need to add a procedure for the projection.  You can use the procedures for the stereographic, orthographic, and area-preserving azimuthal projections for inspiration.

You can download the source code from http://hjemmesider.diku.dk/~torbenm/Planet/

If you do add this, please mail me a copy of your code, so I can merge it into the official version.
 
Fri Aug 14 02:20:28 2020   by   ostensiblyCreative
I've been reading through and experimenting with the code of the planet generator, and I'm having some trouble comprehending exactly what the Azimuthal rendering and projection loops are doing with each step, so I've had some trouble adjusting the parameters in any way other than by modifying the variables slightly and seeing what that changes on the output. If you have time, could you explain what is going on with those?
 
Fri Aug 14 10:41:25 2020   by   Torben
Sure.

The loops are over the pixels: j vertically, and i horisontally.  x and y are scaled versions of i and j, so y ranges from -1/scale to 1/scale and x is scaled by the same factor.  z is calculated to determine if x and y refer to a point outside the planet, in which case the background colour is used.

Otherwise, 3D coordinates are calculated.  It uses slo/clo = sine/cosine of the longitude for the center, sla/cla = sine/cosine of the center latitude.  I don't remember where I got the formulae for this, but Wolfram Mathworld has formulae for most projections (but they may be calculated differently). See https://mathworld.wolfram.com/MapProjection.html

 
Sat Aug 15 07:30:01 2020   by   ostensiblyCreative
Okay, having read over the math and experimented a bit with the code, I think that this may be a long-term project, as C is a little too different from what I know and the projection math is a little higher in complexity than I ever went in school, so I wouldn't hold my breath waiting for me to add the equidistant projection. It's a really fun learning experience though

This is really elegant code, I have to say, especially for something that seems like you might not be expecting it to be looked at
 
Mon Aug 17 09:39:56 2020   by   Torben
This is really elegant code, I have to say

Not really.  The code has been added to and tweaked over several decades, and this shows.  If I had to start over, I would a lot of things differently.
 

Return to topic list



New message:
Topic:
Posted by:

Type the values of the dice shown below:

Return to topic list