Page 1 of 1

Error in custom scene map formula?

PostPosted: Sat Dec 13, 2003 7:39 pm
by Rovastar
When calculating the map grids the grid alignment is slightly off and does go correctly

for (y=0;y<24;y=y+1)
for (x=0;x<32;x=x+1) {
dx = 16-x;
dy = 12-y;
d = mag(dx,dy)/5500;
m.x[y][x] = (dx*d);
m.y[y][x] = (dy*d);
m.r[y][x] = 0.95;
m.g[y][x] = 0.9;
m.b[y][x] = 0.6;
}

you are numbering from dx and dy witch are 16-x and 12-y now this doesn't give an grid as in.

from x=0 dx (16+) = 16 x = (16-) 31 (max value) = -15

this leads to a grid snapped to one corner.

If you slow down the traffic.

m.x[y][x] = 0.2*(dx*d);
m.y[y][x] = 0.2*(dy*d);

it is more apparent.

(think of this in a smaller grid. 8x6 consider the y values where dy = 3-y

y = ...0..1..2..3..4..5
dy =..3..2..1..0..-1..-2

It is more apparent there.)

For gridding in this situation it is better IMHO to use the gridline cross points to be equal to 0,0 not the meshsize snap which is misaligned.

So you need to have

dx = 15.5-x;
dy = 11.5-y;


15.5 to -15.5;
11.5 to -11.5;

for the above example.

You seem to have done this a few times in your code.

It seems to be a common mistake as Ryan Geiss did a similar thing with milkdrop alignment that I found a few years ago but in a more complex way. :)

PostPosted: Thu Dec 18, 2003 5:17 pm
by rabidhamster
yep, thanks. In a few scenes i have used 15.5 instead of 16, but i know some are still off - hopefully in the ones that are like this its not going to be too apparent.

Anyway, i'll make the effort in future :)

- Gordon