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).


  • $\begingroup$ Are you doing coding by deferring to stackexhange, perchance? $\endgroup$ – joojaa May 31 '16 at 12:38
  • $\begingroup$ I totally missed your last question ? $\endgroup$ – sajis997 May 31 '16 at 12:52
  • $\begingroup$ if xMax and xMin are floats, why is xDist an int? $\endgroup$ – Rotem May 31 '16 at 14:32
  • $\begingroup$ All the declared variable are in short int . The only floating point issue may arise with xDist/scanSpacingStep. $\endgroup$ – sajis997 May 31 '16 at 14:47
  • $\begingroup$ 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? $\endgroup$ – trichoplax Jun 1 '16 at 0:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.