Gears banner

Gears

2 devlogs
3h 18m 32s

A simple program that creates an STL of a gear.

Repository

Loading README...

Tree Plate

I did some geometry to determine the outer radius given that the tooth angle matched the angle between the teeth.
At first I got (attachment 1), because I used 180 instead of pi in my angle calculations. Then I still got (attachment 2) because i had an error in my calculations where the sum of angles was 360. and where i was forgetting to multiply something by 2. This got me (attachment 3), which, while better, still had the wrong angles.
Eventually I determined that my math was wrong and in fact it is impossible to do such a thing.

Attachment
Attachment
Attachment
0
Tree Plate

There are two main parts to this project. One is the function that makes a list of triangles that a gear is made of, and the other function converts that to an STL. The triangles -> STL part was easy, just look up the format on wikipedia, and find out that the only hard part (calculating a normal) was really easy with the library i’m using.
The main function was the code that generated the gear. The way I do this is by first making a list of points around the gear that the teeth are made of (these are the points between the pokey triangle bits in the image below). Then I iterate over this list and get each sliding window of two points. For each of these, I make two triangles for the top (tooth and inner part), two for the bottom, two for the left side of the tooth (it’s a quad, which is two triangles), and two for the right side.
My first iteration I had some issues, because I didn’t understand how the rotation function in the library i was using worked (i even filed a bug, and then realized that how i thought it worked doesn’t even make sense). I also was calling angleTo, which it turns out is the absolute value of the angle and I really should be calling angleToSigned. Eventually it looked mostly okay, except some triangles were being shown only from the opposite direction as I wanted. I realized this was due to the fact that my triangles weren’t following the right-hand rule, where the vertices needed to be listed in counter-clockwise order. After doing that it was almost entirely wrong, which it turns out was because I thought Z was up, when in fact it was down. Finally I got a reasonable solid, and after tweaking some settings i got the below gear (60T, inner radius 1, outer radius .1, thickness 0.2).

Attachment
0