The math is all done for you by the software. For example, if you create a 3D CAD model in a program like Solidworks, you can use another program like Mastercam to generate the complete program. Mastercam is set up for whatever machine you are running the program on; it knows the tools you have installed, the machine dimensions, etc. because you have to specify that in the setup. You take your 3D CAD model, run the Mastercam software on it, and it generates all the code that runs the machine.
The software is expensive, but for a production shop probably well worth it...