Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] Re: (PR#4648) how to do wrapping in map_to_canvas_pos?
Home

[Freeciv-Dev] Re: (PR#4648) how to do wrapping in map_to_canvas_pos?

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#4648) how to do wrapping in map_to_canvas_pos?
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Wed, 23 Jul 2003 05:31:21 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Tue, 22 Jul 2003, Jason Short wrote:

> Gregory Berkolaiko wrote:
> > 
> > I do not understand why map_center_[xy] should stay unnormalized?
> > Let them be normalized, it should work just as well.  It would save you 
> > from removing CHECK_MAP_POSs, although you can do that to save time.
> 
> No, the whole point is that you are looking for an absolute (non-wrapped 
> or "unnormalized") position.
> 
> First consider that the center tile might not even be real.  If we do 
> things right, though, this shouldn't happen...
> 
> But consider an 80x50 map with standard wrapping, non-iso tileset.  Say 
> x0=70 and the mapview window is 22 tiles wide.  Now the center tile is 
> at x=81 or x=1 once it's been normalized.
> 
> Now you want to "unnormalize" some coordinates.  Since this example is 
> very simple, it should be easy to see the "unnormalized" values should 
> have X values in the range [70,150).
> 
> Now start with x=1.  It's distance vector has dx=0.  If we use the 
> normalized value of center_map_x this will give us an unnormalized value 
> x=1, giving canvas_x=-69*NORMAL_TILE_WIDTH - way off the screen.  The 
> correct value should be x=81 giving canvas_x=11*NORMAL_TILE_WIDTH.

Err.  I don't quite understand the paragraph above.  OUr goal is to get 
canvas positions, isn't it.  So we get distance verctor dx = 0, therefore
        canvas_x = center_canvas_x + dx*NORMAL_TILE_WIDTH
gives the correct answer.

Another issue is that I am not 100% sure your approach will give the right 
answer for iso tiles.

G.




[Prev in Thread] Current Thread [Next in Thread]