How to make a dent in a gear

44 views
Skip to first unread message

bc a

unread,
Jul 19, 2022, 2:52:26 AM7/19/22
to Glowscript Users
Hi all,
I am a new user of vpython.
I'd like to make a gear with a dent at the edge. Now I just put a black rectangle there to make it looks like a dent. Here is my code:
g  = shapes.gear(radius=20, n=180, addendum=0.1, dedendum=1.5, phi=0, res=4, fradius=0)
rect = shapes.rectangle(width=0.33, height=1.5)
ex=extrusion(path=[vec(0,0,0), vec(0,0,0.2)], shape=g )
ex2=extrusion(path=[vec(0.33,17.8,-0.01), vec(0.33,17.8,0.25)], shape=rect, color=color.black)

Is there any convient way to realize this? I want the dent to be transparent. Thanks in advance.gear with  dent.JPG

Bruce Sherwood

unread,
Jul 19, 2022, 12:07:19 PM7/19/22
to Glowscript Users
I'm puzzled. When I try your code, I get an error concerning "repeated points". In any case, no, there isn't a way to subtract the piece you want to subtract. The extrusion machinery lets you carve holes in a shape but the hole has to be completely inside the outermost shape.

If you really want something that looks like the picture you display, the thing to do is to not use the gear machinery but simply to generate the desired shape yourself.

Bruce

Bruce Sherwood

unread,
Jul 20, 2022, 10:07:52 AM7/20/22
to Glowscript Users
Here's a fairly simple approach to get the result you want:

1) Create the gear shape.
2) Print the gear shape, which is a list of 2D points of the form [x,y].
3) At the start or end of this list, using standard Python list methods, insert 4 additional points to make the slit.
4) Use this modified shape in the extrusion.

Bruce
Reply all
Reply to author
Forward
0 new messages