<p>I have a bounding area of a contour after the slicing operation. Now to generate the tool-path over the contour, I need to distribute the bounding area into grid space so that each each cell maintain a certain precomputed width.</p>

<p>I am doing the math as follows, but I am not sure if the whole area will be covered as there is floating point values concatenated to integer coordinates.</p>

<pre><code>       short int xDist = std::abs(xMax - xMin);
       short int yDist = std::abs(yMax - yMin);

       short int xCells = (xDist/scanSpacingStep) + 1;
       short int yCells = (yDist/scanSpacingStep) + 1;
</code></pre>

<p>The indexing starts from (0,0). </p>

<p>Thanks</p>

CC BY-SA 3.0
2016-05-31T12:38:14.947Z
Are you doing coding by deferring to stackexhange, perchance?
joojaa
CC BY-SA 3.0
2016-05-31T12:52:12.900Z
I totally missed your last question ?
sajis997
CC BY-SA 3.0
2016-05-31T14:32:39.117Z
if `xMax` and `xMin` are `float`s, why is `xDist` an `int`?
Rotem
CC BY-SA 3.0
2016-05-31T14:47:44.910Z
All the declared variable are in short int . The only floating point issue may arise with xDist/scanSpacingStep.
sajis997
CC BY-SA 3.0
2016-06-01T00:22:07.583Z
I'm not quite sure what you are asking. Are xMax and xMin pixel locations? If so are both inclusive? If xMin=2 and xMax=4, does that cover 2 columns of pixels or 3?
trichoplax is on Codidact now
CC BY-SA 3.0
2016-06-01T11:04:27.273Z
yes , it can be associated with pixel locations. (xMin,yMin) and (xMax,yMax) are inclusive. If xMin = 2 and xMax = 4 , and if both of them are inclusive , it should cover three columns, is not it ?
sajis997
CC BY-SA 3.0
2016-06-07T09:03:19.353Z
Could you explain what "tool-path" and "scanSpacingStep" mean in this context?
trichoplax is on Codidact now
CC BY-SA 3.0
2016-06-07T09:09:47.980Z
The tool-path is basically the path that follows a series of coordinate points over a grid cell. And the scanSpacingStep is the distance between two adjacent lines. Check the link http://imgur.com/NTtPYoB The fractal path in the image could be a tool path that is defined by series of coordinates and the in-between distance of each and every fractal line segments is the scanSpacingStep.
sajis997
<2d-graphics>
distribute the bounding area into grid space
sajis997
# distribute the bounding area into grid space

(Asked by: username_0 on 2016-05-31)

I have a bounding area of a contour after the slicing operation. Now to generate the tool-path over the contour, I need to distribute the bounding area into grid space so that each each cell maintain a certain precomputed width.

I am doing the math as follows, but I am not sure if the whole area will be covered as there is floating point values concatenated to integer coordinates.

```
       short int xDist = std::abs(xMax - xMin);
       short int yDist = std::abs(yMax - yMin);

       short int xCells = (xDist/scanSpacingStep) + 1;
       short int yCells = (yDist/scanSpacingStep) + 1;

```

The indexing starts from (0,0).

Thanks

**Tags:** 2d-graphics

> **Comments:**
> **username_1**: Are you doing coding by deferring to stackexhange, perchance?  
> **username_0**: I totally missed your last question ?  
> **username_2**: if `xMax` and `xMin` are `float`s, why is `xDist` an `int`?  
> **username_0**: All the declared variable are in short int . The only floating point issue may arise with xDist/scanSpacingStep.  
> **username_3**: I'm not quite sure what you are asking. Are xMax and xMin pixel locations? If so are both inclusive? If xMin=2 and xMax=4, does that cover 2 columns of pixels or 3?  
> **username_0**: yes , it can be associated with pixel locations. (xMin,yMin) and (xMax,yMax) are inclusive. If xMin = 2 and xMax = 4 , and if both of them are inclusive , it should cover three columns, is not it ?  
> **username_3**: Could you explain what "tool-path" and "scanSpacingStep" mean in this context?  
> **username_0**: The tool-path is basically the path that follows a series of coordinate points over a grid cell. And the scanSpacingStep is the distance between two adjacent lines. Check the link http://imgur.com/NTtPYoB The fractal path in the image could be a tool path that is defined by series of coordinates and the in-between distance of each and every fractal line segments is the scanSpacingStep.  

---

## 0 answers

