Public Domain Involute Parameterized Gears

by 3dexplorer, published

Public Domain Involute Parameterized Gears by 3dexplorer Jan 9, 2011

Featured Thing!

2 Share
Download All Files

Thing Apps Enabled

Order This Printed View All Apps



Liked By

View All

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag


Thing Statistics

39986Views 12234Downloads


This is a public domain parametric OpenSCAD script for generating involute spur gears, helical gears, partial gears, and racks. The file defines the module gear(), which makes ordinary gears, helical gears (twisted like a screw), and partial gears (a wedge rather than a full disk). It also defines the module rack(), which creates a bar with teeth that will mesh with the gears, so you can generate a rack and pinion set.

The SCAD file also includes an example gear train. If you use the View/Animate command in OpenSCAD, you can see the gears and rack mesh and rotate together. If you change the number of teeth, the animation still rotates correctly.

This is not as powerful as other gears on Thingiverse, but it's public domain, so you don't have to worry about issues like GPL vs. LGPL. There are lots of missing features. Perhaps someone could build on this to create a public domain gear script with all the bells and whistles.


The given STL file is just an example. In practice, you would use the SCAD file in your own project.

Use the gear() or rack() module. Call the functions defined at the bottom of the file to find out the parameters of the generated gear. Two gears will mesh if they have the same mm_per_tooth and pressure_angle, and if their centers are separated by the sum of their pitch radii. You can find the pitch radius of a gear by calling pitch_radius(). Calling outer_radius() gives the radius of a circle that encloses the entire gear.

All Apps

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

App Info Launch App

Print through a distributed network of 3D printing enthusiasts from across the US, at a fraction of the cost of the competitors. We want to change the world for the better through technology, an...

App Info Launch App

Quickly Scale, Mirror or Cut your 3D Models

App Info Launch App

Treatstock is an online platform that offers decentralized manufacturing services such as 3D printing and CNC machining for business-to-business and business-to-consumer sales all over the world. W...

App Info Launch App

3D print your favourite design with NinjaPrototype, a professional 3D manufacture with consistent quality and speed.

App Info Launch App

fantastic. no way. thanks

Thanks a lot! Exactly what I need.

This is brilliant! Thankyou!

Thanks for this - I've found a couple of issues with the "rack" gear calculations. I think these were spotted earlier, but I've got (I think) the correct fixes. The first issue is with the tooth shape on the rack itself. The pressure calculation angle is wrong - it should be "tan" not "cos" with no constant offset. The second issue is with the rack position on the example view - it should be scaled by the mm_per_tooth rather than the fixed value of 9 (which only works with the example value).

The patch is:

--- publicDomainGearV1.1.scad   2017-04-18 13:49:27.501990000 +0100
+++ publicDomainGearV1.1-changes.scad   2017-04-19 19:17:33.465643092 +0100
@@ -115,7 +115,7 @@
 ) {
    assign(pi = 3.1415926)
    assign(a = mm_per_tooth / pi) //addendum
-   assign(t = a*cos(pressure_angle)-1)         //tooth side is tilted so top/bottom corners move this amount
+   assign(t = a*tan(pressure_angle))         //tooth side is tilted so top/bottom corners move this amount
        for (i = [0:number_of_teeth-1] )
                linear_extrude(height = thickness, center = true, convexity = 10)
@@ -169,6 +169,6 @@
 translate([ d13,  0, 0]) rotate([0,0,-($t-n3/4+n1/4+1/2)*360/n3]) color([0.75,0.75,1.00]) gear(mm_per_tooth,n3,thickness,hole);
 translate([ d13,  0, 0]) rotate([0,0,-($t-n3/4+n1/4+1/2)*360/n3]) color([0.75,0.75,1.00]) gear(mm_per_tooth,n3,thickness,hole);
 translate([-d14,  0, 0]) rotate([0,0,-($t-n4/4-n1/4+1/2-floor(n4/4)-3)*360/n4]) color([1.00,0.75,0.50]) gear(mm_per_tooth,n4,thickness,hole,0,n4-3);
-translate([(-floor(n5/2)-floor(n1/2)+$t+n1/2-1/2)*9, -d1+0.0, 0]) rotate([0,0,0]) color([0.75,0.75,0.75]) rack(mm_per_tooth,n5,thickness,height);
+translate([mm_per_tooth*(-floor(n5/2)-floor(n1/2)+$t+n1/2-1/2), -d1+0.0, 0]) rotate([0,0,0]) color([0.75,0.75,0.75]) rack(mm_per_tooth,n5,thickness,height);

I believe the rack module ist still brocken. I changed it in the following way and added some more parameters. Now it works for me.

// The module InvoluteGear_rack() gives a involute gear rack, which is a bar with teeth.
// A rack can mesh with any gear that has the same mm_per_tooth and pressure_angle.
// The "pitch circle" is a line along the X axis.
// mm_per_tooth     this is the "circular pitch", the circumference of the pitch circle
//                  divided by the number of teeth
// number_of_teeth  total number of teeth along the rack
// thickness        thickness of rack in mm
// height           height of rack in mm, from tooth top to far side of rack
// pressure_angle   controls how straight or bulged the tooth sides are, in degrees
// clearance        gap between top of a tooth on one gear and bottom of valley
//                  on a meshing gear, in millimeters
// backlash         gap between two meshing teeth, in the direction along the circumference
//                  of the pitch circle

module InvoluteGear_rack (
    mm_per_tooth    = 3,
    number_of_teeth = 11,
    thickness       = 6,
    height          = 4,
    pressure_angle  = 28,
    clearance       = 0.0,
    backlash        = 0.0

    // addendum - tooth height above pitch line
    assign(addendum =        InvoluteGear_module_value(mm_per_tooth) - clearance)

    // dedendum - tooth height below pitch line
    assign(dedendum = 1.25 * InvoluteGear_module_value(mm_per_tooth)            )

    for (i = [0:number_of_teeth-1] )
            linear_extrude(height = thickness, center = true, convexity = 10)
                        [-1/2 * mm_per_tooth,                                              addendum-height],
                        [-1/2 * mm_per_tooth,                                             -dedendum],
                        [-1/4 * mm_per_tooth + backlash - dedendum * tan(pressure_angle), -dedendum],
                        [-1/4 * mm_per_tooth + backlash + addendum * tan(pressure_angle),  addendum],
                        [ 1/4 * mm_per_tooth - backlash - addendum * tan(pressure_angle),  addendum],
                        [ 1/4 * mm_per_tooth - backlash + dedendum * tan(pressure_angle), -dedendum],
                        [ 1/2 * mm_per_tooth,                                             -dedendum],
                        [ 1/2 * mm_per_tooth,                                              addendum-height],

I ran this code verbatim on my MacBook Air running OpenSCAD 2013.06 and got square teeth on all gears. How to I get the involute shape on the teeth?

I tried creating a rack with mm_per_tooth=3 and I get a weird looking teeth. In fact if I change your example with mm_per_tooth=3, and I also divide the other length type variable by 3, I get the same weird result.

I think it's down to line 118:

assign(t = a*cos(pressure_angle)-1)

the -1 is outside the multiplication. I don't really know what this all means, I just tried to change it to:

assign(t = a*(cos(pressure_angle)-1))

but that only made it bad for all mm_per_tooth. Since I don't know what this all means, I don't know how to fix it.
Can you help?

I noticed the rendering of the example gear set was kind of time-consuming on my machine, so I made the following patch to speed it up.

Compiling and rendering the example gear set took somewhere around 3:40 on my 6-Core AMD machine under OpenSCAD 2013.06 . I moved the order in which the linear extrusion occurred in this script, and it dropped compile and render time down to less than a second.

Here's a patch for anyone who might find it useful:

< for (i = [0:number_of_teeth-teeth_to_hide-1] )

> linear_extrude(height = thickness, center = true, convexity = 10, twist = twist) for (i = [0:number_of_teeth-teeth_to_hide-1] )
< linear_extrude(height = thickness, center = true, convexity = 10, twist = twist)
< for (i = [0:number_of_teeth-1] )

> linear_extrude(height = thickness, center = true, convexity = 10) for (i = [0:number_of_teeth-1] )
< linear_extrude(height = thickness, center = true, convexity = 10)

It seems like line 118 should be:
        assign(t = a/2*cos(pressure_angle))         //tooth side is tilted so top/bottom corners move this amount

Rather than what it is.

You're right. I'll fix that, and give an attribution in the comments.

It would be great if there were a function to create a outer ring gear, ie the barrell of a epicyclic gearbox. I'm no coder, any thoughts and i'd be very greatful.

This is trivial to do with openscad! Make a cylinder that's the right size and thickness for the gear you want, then subtract a gear from it:

difference() {

that would give you a gear with 20 teeth, 1.8cm inner-diameter, and a wall thickness of about 1mm, 1cm high. Modify as you please.

I think I'll probably add an internal gear ring in the future, so it can do planetary gears. But I think it will have to be slightly more complicated than the above code. It looks to me like there are at least 3 things that need to change if we want to create an internal gear as the difference of a disk and gear: swap the addendum and dedendum, negate the backlash, and change the fillet on the subtracted gear (so it's a removal from the tooth tip, rather than an addition to the tooth base). I'll have to think about whether there are any other changes, or if those 3 are enough.

WOW, amazing stuff. Thank you.

This is very good!! I do love the faceting of the teeth, almost even. Thanks a lot!

I just enclosed between comments the last lines of the script (to disable the example) and then played a little some code like:



pitch_d=0; // Pitch diameter for the 1st gear
// set as zero and will be computed from "circular_p" parameter.
circular_p=4; // Circular pitch for the 1st gear
n1 = 17; // 1st gear number of teeth
n2 = 9; // 2nd gear number of teeth

mm_per_tooth=pitch_d != 0 ? pitch_d*PI/n1 : circular_p;

thickness = 5;
hole = 3.5;
clearance = 0.0;
backslash = 0.0;

d12=pitch_radius(mm_per_tooth,n1) + pitch_radius(mm_per_tooth,n2);

echo("Distance between gears axes:", d12);





Try to run the animation (i.e. FPS
amp; Steps set to 25)

Thanks a lot for sharing !!

here is an unfinished project that incorporates a modified version of your code:


thanks for making it public domain!

alpha parts of three speed bicycle hub
by donb

There are other gear libraries, but I really like this because you've made it public domain. I, or anyone, might like to just take a snippet from here and there, and this will accelerate innovation.

I've been considering making some of my own wandering designs public domain for similar reasons. So, this is very inspirational.

Double involute worm gearing?

I probably won't add more to it, now that it does everything the Rhombot needs. But if you'd like to use it to make a script with more features, that would be great.

OK, thanks very much for this. Haven't actually started working with OpenSCAD yet though so likely nothing in the near future, but... :) You wouldn't happen to have the mathematical description of a proper worm-gear interface kicking around as a starting point would you?

That's awesome! I was wondering where this thing went to. (Thanks for the rack!)

No problem. I hope you find it useful.