Helical Gear tutorial?

I want to share this script by Seghier in this post:

I hope someone takes the effort to improve your script for gears with different number of teeth, and an option for external gear; a rack; and internal gear. My skills in Python are not so good.