[Freeciv-tickets] [freeciv] #43665: Torus colatitude formula documentation

Back to archive index
OSDN Ticket System norep****@osdn*****
Tue Feb 1 12:17:14 JST 2022


#43665: Torus colatitude formula documentation

  Open Date: 2022-01-20 17:18
Last Update: 2022-02-01 05:17

URL for this Ticket:
    https://osdn.net//projects/freeciv/ticket/43665
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=43665

---------------------------------------------------------------------

Last Changes/Comment on this Ticket:
2022-02-01 05:17 Updated by: cazfi
 * Status Update from Open to Closed
 * Owner Update from (None) to cazfi
 * Resolution Update from Accepted to Fixed


---------------------------------------------------------------------
Ticket Status:

      Reporter: alienvalkyrie
         Owner: cazfi
          Type: Patches
        Status: Closed
      Priority: 1 - Lowest
     MileStone: 3.0.0
     Component: Documentation
      Severity: 3
    Resolution: Fixed
---------------------------------------------------------------------

Ticket details:

The map_colatitude() function in server/generator/mapgen_topology.c contains a formula for torus topologies (permalink) documented only with the comment
 /* This projection makes poles with a shape of a quarter-circle along  * "P" and the equator as a straight line along "/".  *  * This is explained more fully in RT 8624; the discussion can be found at  * http://thread.gmane.org/gmane.games.freeciv.devel/42648 */ return MAX_COLATITUDE * (1.5 * (x * x * y + x * y * y)                          - 0.5 * (x * x * x + y * y * y)                          + 1.5 * (x * x + y * y));Since the referenced bug tracker is long dead (and not in the Wayback Machine), the Gmane link out of date (and the HTTP frontend doesn't seem to exist anymore), and – as far as I can discern – there's no actual explanation of the formula in what's left of the original discussion (at least none that I could find), this comment needs an update. For the sake of future-proofing, it would probably be prudent to put the explanation directly into a comment next to the formula this time (or at least somewhere within the repository itself).
I was able to reverse engineer the formula (with a bit of luck and a lot of trial and error):
The formula is lerp(1.5 (x2 + y2), (x+y)2, (x+y)), where lerp(a,b,t) = a * (1-t) + b * t is the linear interpolation function.
The first interpoland is 1.5 times the squared pythagorean distance from the pole
This gives circular lines of latitude
I don't know where the factor of 1.5 comes from / what it's for – I'm assuming it's compensating for something
The second interpoland is the squared manhattan distance from the pole
This gives straight lines of latitude parallel to the equator
The interpolation factor is the manhattan distance from the pole
This goes from 0 at the pole, where the pythagorean distance wins out and we get a circular polar region...
...to 1 at the equator, where the manhattan distance wins out and we get straight tropics
The colatitude grows with the square of the distance to the poles (rather than linearly, as it does for other topologies)
The area within a certain distance of a pole also grows with the square of that distance (on torus maps), so the colatitude grows with the area
This keeps areas within a given range of colatitudes (i.e. with a given climate) relatively consistent with non-torus maps, where both colatitude and area grow linearly with distance to the pole
This leaves open two questions:
Do we know where exactly the formula, in particular the factor 1.5, comes from? The only thing I found in the original discussion was a text document in a weird encoding that looked promising, but didn't lead anywhere.
Where should we best put this documentation? I'm gravitating toward "comment in the code right next to the formula".


-- 
Ticket information of Freeciv project
Freeciv Project is hosted on OSDN

Project URL: https://osdn.net/projects/freeciv/
OSDN: https://osdn.net

URL for this Ticket:
    https://osdn.net/projects/freeciv/ticket/43665
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=43665



More information about the Freeciv-tickets mailing list
Back to archive index