from cadlab.scad import *
from solid2 import *
from math import pi, cos, sin
Gear
100) set_global_fn(
A gear is a mechanical device that can be used to transmit rotational motion. It has a flat disk shape, with teeth on the edges and a hole in the center.
The hole is there to place the gear on an axle on which it can freely rotate and the teeth are there to transmit rotational motion to other gears or other mechanical components that also have teeth that are spaced the same way.
Note that the center does not need to be circular. For example, if you wish to attach a leaver, you can use a square hole in order to transmit angular momentum from the leaver to the gear.
Other things are possible too. For example, you might be able to connect the gear directly to a spiraling spring in order to act as an energy storage device.
We start by creating the base.
= 5
gear_height = 8
radius_to_teeth
= cylinder(h = gear_height, r = radius_to_teeth)
base_shape base_shape
Next, we need teeth. Teeth would be placed repeatedly, with spaces between them equal to the teeth width. So, once we are set to the number of teeth we want, we can compute teeth width from
\[ \text{teeth_width} \cdot 2 \cdot \text{n_teeth} = 2 \cdot \pi \cdot \text{radius_to_teeth} \]
= 10
n_teeth
= pi * radius_to_teeth / n_teeth
teeth_width teeth_width
2.5132741228718345
= base_shape
with_teeth for i in range(n_teeth):
+= cylinder(h = gear_height, r = teeth_width/2).translate([radius_to_teeth,0,0]).rotate([0,0,360/n_teeth*i])
with_teeth with_teeth
We have teeth! But they look a bit too short. To create a longer tooth, lets take a hull of two cylinders.
= 0.25 * teeth_width
teeth_offset
= cylinder(h = gear_height, r = teeth_width/2)
tooth_end = tooth_end + tooth_end.translate([teeth_offset,0,0])
tooth tooth
= tooth.hull()
tooth tooth
We can even simplify this further since we don’t need inner side to be circular:
= cylinder(h = gear_height, r = teeth_width/2)
tooth_end = (cube([teeth_width/2, teeth_width, gear_height], center=True).translate([0,0,gear_height/2])
tooth + cylinder(h = gear_height, r = teeth_width/2).translate([teeth_offset,0,0]))
tooth
Now this geometry is simpler, so it will be faster to work with. Note that we don’t even need hull anymore.
Lets try putting this tooth into the gear:
= base_shape
with_teeth for i in range(n_teeth):
+= tooth.translate([radius_to_teeth,0,0]).rotate([0,0,360/n_teeth*i])
with_teeth with_teeth
Lets cut out a hole for an axle:
= 2.5
axle_radius
= cylinder(h=gear_height*4, r=axle_radius, center=True)
axle_hole = with_teeth - axle_hole
gear gear