SHM

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

SHM

Caddiy
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
Reply | Threaded
Open this post in threaded view
|

Re: SHM

doug.moen
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
Reply | Threaded
Open this post in threaded view
|

Re: SHM

Caddiy
Thanx Doug - that looks a lot better and is easier to handle!
 
Just perfect with a little tweaking:

rotate([0,0,-73])
translate([sin($t*360)*105,0,0])

But odd that clockwise rotation is negative?
 


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);
}}}





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: SHM

MichaelAtOz
Administrator
Caddiy wrote
> But odd that clockwise rotation is negative?

Right-Hand-Rule
<http://forum.openscad.org/file/t359/220px-Right-hand_grip_rule.png>



-----
OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.