Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat are the indicator functions and constraints for complex grid drawing problems?
    primarykey
    data
    text
    <p>If you're looking at an array of pixels, in either 0,1,2,3, or even N dimensions, it's easy to tell if a certain pixel falls on a <em>square or rectangular</em> grid line within it by using an indicator function like so (I'll use imperative pseudocode to make what I'm talking about clear but I'm really only interested in the constraints and the conditionals in the indicator functions for the more general types of grids):</p> <pre><code>/* define the array of pixels in however many dimensions you want */ //define the dimensions of the array int x-dimension-length = &lt;some positive integer&gt;; int y-dimension-length = &lt;some positive integer&gt;; int z-dimension-length = &lt;some positive integer&gt;; [...] //you could keep gong for even higher dimensions /* define CONSTRAINTS (for the square or rectangular case) */ //define the height and width of the grid boxes within the grid (contstraints on a square/rectangular grid) int horizontalSpacingBetweenGridlines = &lt;non-negative integer&gt;; int verticalSpacingBetweenGridlines = &lt;non-negative integer&gt;; /* end definition of CONSTRAINTS */ /* define the arrays to draw the grids on */ // -- assumes that the arrays here are intialised to contain all zeros: //0-dimensional (degenerate) example: int point = 0; //1d example: int [] OneDimensionalArray = int[x-dimension-length]; //(2d example) int [] TwoDimensionalArray = int[x-dimension-length][y-dimension-length]; //(3d example) int [] ThreeDimensionalArray = int[x-dimension-length][y-dimension-length][z-dimension-length]; /* Indicator functions */ /* zero-dimensional (degenerate) case */ //if a point falls on a gridline, degenerate example boolean doesAPointFallOnAGridLine0D() { if (point % horizontalSpacingBetweenGridlines == 0) { return true; } /* one-dimensional case */ //decide if a point in the 1D array at index &lt;x-coordinateFrom1DArray&gt; falls on a gridline boolean doesAPointFallOnAGridLine1D(int x-coordinateFrom1DArray) { if (x-coordinate % horizontalSpacingBetweenGridlines == 0) { return true; } } /* two-dimensional case */ //decide if a point in the 2D array at index &lt;x-coordinateFrom2DArray&gt;,&lt;y-coordinateFrom2DArray&gt; falls on a gridline boolean doesAPointFallOnAGridLine2D(int x-coordinateFrom2DArray, int y-coordinateFrom2DArray) { if((x-coordinateFrom2DArray % horizontalSpacingBetweenGridlines == 0) &amp;&amp; (y-coordinateFrom2DArray % verticalSpacingBetweenGridlines == 0)) { return true; } } /* [and so on for higher-and-higher-dimensional spaces...] */ </code></pre> <p>My question is, in general <em>what do the indicator function and constraints look like for the different types of non-square and non-rectangular-grids</em> (e.g., triangular, hexagonal, octagonal, whatever), and is there a <em>canonical reference work</em> that talks about constructing that sort of indicator function and the constraints it requires for the different shapes of grid? </p> <p><a href="http://www-cs-faculty.stanford.edu/~knuth/taocp.html" rel="nofollow noreferrer">Knuth</a> seems out on this one.</p> <p>This is a very general mathematical problem so it probably has a name/canonical solution.</p> <p>As an aside, I'm most interested in hexagonal grids in n-dimensions, but I don't want to write a kludgy one-off implementation that only works for those <a href="http://aicip.ece.utk.edu/publication/99spie_hex.pdf" rel="nofollow noreferrer">using linear algebra</a> instead of a proper boolean indicator function, and would rather like to know how to solve these problems in general the right way.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload