# SHM

4 messages
Open this post in threaded view
|

## SHM

 Hi,   I am a newbie to CAD but have always found it fascinating. I recently got myself OpenScad to show a novel mechanism animated in 3D.   Part of the mechanism moves back and forth with SHM, which I have achieved by juggling with a combination of 3 command pairs of translate and rotate, but surely there is a much more elegant way of doing it.   Surely it can be done in one line with translate, \$t, sin or cos and an i=360 somewhere, but how? It doesn't seem to figure in the internet and tutorials.   This is how I did it:   translate([0,0,0]) rotate([0,0,\$t*-360]) translate([0,50,0]) rotate([0,0,-146+\$t*720])   translate([0,-50,0]) rotate([0,0,73+\$t*-360]) color("blue") { difference() { translate([-200,-30,0]) cube([400,60,20]);   hull () { translate([105,0,-1]) cylinder(h=22, r=17); translate([-105,0,-1]) cylinder(h=22, r=17); }}}   That works, but can anyone clean it up? _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: SHM

 Something like this maybe?translate([sin(\$t*1000)*100,0,0])color("blue"){difference(){translate([-200,-30,0])cube([400,60,20]);hull (){translate([105,0,-1])cylinder(h=22, r=17);translate([-105,0,-1])cylinder(h=22, r=17);}}}On Sat, Aug 15, 2020, at 1:41 AM, [hidden email] wrote:Hi, I am a newbie to CAD but have always found it fascinating. I recently got myself OpenScad to show a novel mechanism animated in 3D. Part of the mechanism moves back and forth with SHM, which I have achieved by juggling with a combination of 3 command pairs of translate and rotate, but surely there is a much more elegant way of doing it. Surely it can be done in one line with translate, \$t, sin or cos and an i=360 somewhere, but how? It doesn't seem to figure in the internet and tutorials. This is how I did it: translate([0,0,0]) rotate([0,0,\$t*-360]) translate([0,50,0]) rotate([0,0,-146+\$t*720])   translate([0,-50,0]) rotate([0,0,73+\$t*-360])color("blue"){ difference() { translate([-200,-30,0]) cube([400,60,20]); hull () {translate([105,0,-1]) cylinder(h=22, r=17); translate([-105,0,-1]) cylinder(h=22, r=17); }}} That works, but can anyone clean it up?_______________________________________________OpenSCAD mailing list_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org