glob2-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[glob2-devel] "tabClose", "deltaOne" and the "diagonal length aberration


From: Nuage
Subject: [glob2-devel] "tabClose", "deltaOne" and the "diagonal length aberration"
Date: Fri, 25 Nov 2005 19:34:25 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20051102

> Also, you use perpendicular iterators in some places - for example, the
> "deltaOne" array in Map.cpp.  Is there any particular reason for the
> order of iteration?  If so, (how) would the algorithm generalise to an
> iterator of arbitrary length and width?  (I ask this so I can write
> such a general iterator)

Well, "tabClose" is meant to make a fastest transformation of an indexed
direction (0 to 7) into a delta-position (dx, dy), each into {-1, 0, 1}. I found
it to be a very good trade-off between speeed an clarity.

I don't see where a generic one would be helpful, nor how it would help things
to be more clear. The 3x3 one is the smallest one, and where would we use a
bigger one?



And "deltaOne" is the same as "tabClose" but in another order. It starts with
the right-angles, and then goes the diagonals. The goal is to make the glob2
"diagonal length aberration" to be visually reduced.

Explanation:
For a globule, walking from one square to another takes 1 step, whichever this
is a diagonal or not. Despite the fact that in euclidean (==natural) space, the
diagonal of a square is 1.41 when the side is 1. All glob2 topology is based on
this, and we basically don't mind.

But this allow the globule to use very unnatural way to go from a point to
another when it can goes in a straight line. Imagine the unit, going from left
to right, following the # in this ASCII Example:

case 1, natural way, 15 steps:
-------------->
###############
^start     end^


case 2, possible way, 15 steps:
-------------->
       #
      # #
     #   #
    #     #
   #       #
  #         #
 #           #
#             #
^start     end^

So, if you replace "deltaOne" by "tabClose" into the gradients following
algorithms, then the unit will be most likely to use "case-2-like" ways, instead
of "case-1-like" ways.


This is related to the ">" (strictly greater than), like in:
if (g>max)
of this sample code:

// search all directions
for (int d=0; d<8; d++)
{
        int ddx = deltaOne[d][0];
        int ddy = deltaOne[d][1];
        Uint8 g = gradient[((vx+ddx)&wMask)+(((vy+ddy)&hMask)<<wDec)];
        if (g>max)
        {
                max = g;
                vddx = ddx;
                vddy = ddy;
                ound = true;
        }
}

When the (g>max) is satisfied, another equal solution will not replace it,
hence, favoring the right-angles directions in case of equality.

If we did use ">=" (greater or equal) then we would need to use another order
then "deltaOne", like starting with the diagonals, and ending with the 
right-angles.

Luc-Olivier




reply via email to

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