I'm writting CNC simulator for 3-axis milling tool. At first attempt I have represented the material as WxHxD box (W - width, H- height, D - depth) with W and D divisor parameters. So for example W = D = 120, H = 50, W-div = 20, D-div = 20:
At each step the mill is removing material and H coordinate at each division point is adjusted simulating material removal:
This method is OK for started. But to simulate full precision of milling tool the divisors should have hight values, i.e. for material block of 100 mm x 100 mm x 100 mm to have precision of 0.01 mm the divisors should be 10 000 which makes simulation almost impossible. Also setting divisors makes precision fixed and not dependent on mill parameters (radius, height, curvature, etc.).
Working application with current solution runs on PC machine, but next iteration should be able to run on mobile devices utilizing OpenGL ES 3.0 as rendering API.
Keeping this in mind the question arise what is best method to simulate (preferably in real time) material removal from starting block ? Second question is what data structure and algorithms to utilize to achieve this goal.