DiagScan -Basic Algorithm:




Visual Link to java programme

Variable List:



             Space Object                      sp;      // Space object to be scanned

             integer                          dirdir;                   // direction of diagonal scan (left or right)
             integer                        dirfase;                  // phase of scan (up or down)
             integer                     edgefase;                // direction of scan  (clockwise or anti-clockwise along  edges)
             integer                      diractive;              // diagonal movement or edge-step  active at moment
             integer                          curdir;             // current coded direction
             integer                           zigsw;            // determines mode of scan (zigzag or zig)

             integer                         initflag;        // initial coded flag value (starting position)
             integer                        endflag;       // end coded flag value (opposite corner)
             integer                               eos;      // flag signifying end of space (when in "scan" mode)

             integer array (1-D)      tempos;            // stored (temporary) position at begin of zig (for zig only)    
             integer array (1-D)          flags;           // signals identifying position in parameter range
             integer                       flagcode;         // flag coded to identify edges and corners (see diagramme)

             integer array (2-D)      dirtable;                                                                                           // converts code to direction increments
             integer array (2-D)    stepcode = {{3,6},{6,3},{2,1},{2,6},{6,1},{1,2},{3,2},{1,3}};  // sets step direction (along edge)
             integer array (2-D)       dircode = {{7,5},{8,4}};                                                            // coded diagonal directions


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


Visual link to Java Programme

Basic Algorithm:


                Initialize Process
                repeat Main Process

------------------------
      
                Initialize Process:
                                       Set direction of scan clockwize or anti-clockwise
                                       MakeDirTable  (converts code to directional increments)
                                       Create new Space Object (of  specified size)
                                       Set "wrap" or "bounce" option (for Zig or Zigzag)
                                       SetFirstStep
                                               SetFlagcodes (identifying current position on edge or corner )
                                               SetEndCodes (identifying initial and terminal corners)
                                               Depending on <zigsw> Initialise Zig Process or ZigZag Process
                                       Set End of Scan flag to <0> (end of scan not reached)

                                                                                        Initialize Zig
                                                                                             Set <dirdir> (direction of diagonal, / or \ )
                                                                                             Set <dirfase> (phase of diagonal -zig or zag)
                                                                                             Get <curdir> from <stepcode> table (code-1, edgefase)
                                                                                             Convert <curdir> into directional increments for Space Object
                                                                                             Store current (X,Y) position in <tempos>
                                                                                             Set <diractive> flag to <1> (simulating a diagonal movement)

                                                                                        Initialize ZigZag
                                                                                             Set <dirdir> (direction of diagonal, / or \)
                                                                                             Set <dirfase> (phase of diagonal -zig or zag)
                                                                                             Get <curdir> from <stepcode> table (flagcode-1, edgefase)
                                                                                             Convert <curdir> into directional increments for Space Object
                                                                                             Store current (X,Y) position in <tempos>
                                                                                             Set <diractive> flag to <1> (simulating a diagonal movement)

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


                            Main Process
                                         Set End of Scan flag to
<0>   (scan not yet ended)
    
                                    Depending on <zigsw> follow Zig Process or ZigZag Process
                                         Increment
(X,Y) position of Space Object

                                                                  Zig Process
                                                                    
IF  (X,Y) position at an edge or corner (flagcode != 0THEN
                    
                                                                                                      Make edge step Move
                                                                                                             Set
(X,Y) position to <tempos>
                                                                                                             Increment Space Object to new edge position
                                                                                                             Store current (X,Y) position in <tempos>
 
                                                                                                       Prepare diagonal move
 
                                                                                                           Get <curdir> from <dircode> table (dirdir, dirfase)
                                                                                                            Convert <curdir> into directional increments for Space Object
                                                                                                            Set <diractive> flag to <1> (signaling a diagonal movement)


                                                                 
ZigZag Process
                                                                     IF  (X,Y) position at an edge or corner (flagcode != 0THEN
                                                                                                 IF just made diagonal movement (diractive = 1)  THEN
                                                                                                           Prepare Edge step
                                                                                                                   Get <curdir> from <stepcode> table (flagcode-1, edgefase)
                                                                                                                   Convert <curdir> into directional increments for Space Object
                                                                                                                   Reverse phase of <edgefase > (edgefase = 1 -edgefase)
                                                                                                                   Set <diractive> flag to <0> (signaling a step movement)
                                                                                 IF just made step movement (diractive = 0)  THEN
                                                                                                            Prepare Diagonal movement
                                                                                                                  Get <curdir> from <dircode> table (dirdir, dirfase)
                                                                                                                  Convert <curdir> into directional increments for Space Object
                                                                                                                  Set <diractive> flag to <1> (signaling a diagonal movement)
                
------------------------

                                        Increment
                                              
Move Space Object (according to pre-set directional increments)
                                      
Get
< flags> (signals identifying position in parameter range) and code <flagcode>
                                                           IF <
flagcode> equals <endflag> (scan is finished) THEN
                                                                        Reset scanning limits
                                                                       
Reverse phase of <edgefase > (edgefase = 1 -edgefase)
                                                            SetFirstStep

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



Visual link to Coding Diagramme for java Programme                  Visual link to Notes on java
          programme


 Visual link to java
          programme
  

---------------------------------------------------------
click on relevant image to link to notes or Java programmes
---------------------------------------------------------

Creating A Space For Change
Data Space
Klee index




Trevor Batten
Baclayon 2011
home