This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-03-26 02:31:01

thecooltodd
Scratcher
Registered: 2008-03-08
Posts: 75

Help with Pendulum

http://scratch.mit.edu/projects/thecooltodd/127882

Any ideas?  I describe what I need help with on the project notes.

Offline

 

#2 2008-03-26 12:26:54

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Help with Pendulum

I just glanced at the scripts, and haven't figured out specifically what the problem is, but i didn't see any kind of "dt" (time step) variable or wait step, so it could be a case where the equations are going unstable. I may be wrong, though. Looks like a good start of a project.

Offline

 

#3 2008-03-26 12:32:17

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Help with Pendulum

Actually, switch the sin and cos functions used to compute vx1 and vy1, and see how that works...

Offline

 

#4 2008-03-26 15:42:27

thecooltodd
Scratcher
Registered: 2008-03-08
Posts: 75

Re: Help with Pendulum

chalkmarrow wrote:

I just glanced at the scripts, and haven't figured out specifically what the problem is, but i didn't see any kind of "dt" (time step) variable or wait step, so it could be a case where the equations are going unstable. I may be wrong, though. Looks like a good start of a project.

I guess the time variable would just be how long each loop is.

Offline

 

#5 2008-03-26 15:43:31

thecooltodd
Scratcher
Registered: 2008-03-08
Posts: 75

Re: Help with Pendulum

chalkmarrow wrote:

Actually, switch the sin and cos functions used to compute vx1 and vy1, and see how that works...

If I did that then Vy would have a value when it is pointing straight down and Vx would have a value if the pendulum is horizontal.

Offline

 

#6 2008-03-27 06:46:23

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Help with Pendulum

Would you object to using the Rotational Intertial approach?  It turns out to be much simpler.  With that approach, you just look at the gravitational torque that is being applied to the rotational system and use rotational inertial (mR^2) and the rotational form of Newtons second law instead of the usual F=ma. 

If you want to go that way, I can probably get you something working pretty fast.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#7 2008-03-27 13:07:15

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Help with Pendulum

I have just created a project that simulates a pendulum.
http://scratch.mit.edu/projects/archmage/128694

You can check it out if you want. There isn't a lot of code in it.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#8 2008-03-27 19:59:16

thecooltodd
Scratcher
Registered: 2008-03-08
Posts: 75

Re: Help with Pendulum

Cool thanks.  The only thing is that uses angular velocity...  I need a pendulum that breaks down the X and Y components.  Unless you wanna try make a double pendulum without that?

Offline

 

#9 2008-03-27 22:57:22

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Help with Pendulum

You never said you wanted a double pendulum. Are you going to use this for anything specific?


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#10 2008-03-28 02:53:56

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Help with Pendulum

A double pendulum?


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#11 2008-03-28 17:23:38

thecooltodd
Scratcher
Registered: 2008-03-08
Posts: 75

Re: Help with Pendulum

archmage wrote:

You never said you wanted a double pendulum. Are you going to use this for anything specific?

Possibly for my next science fair project.

Offline

 

#12 2008-03-28 17:24:42

thecooltodd
Scratcher
Registered: 2008-03-08
Posts: 75

Re: Help with Pendulum

Mayhem wrote:

A double pendulum?

Search for it on youtube ;D

Offline

 

#13 2008-03-28 19:27:54

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Help with Pendulum

Oh, like this?

http://scratch.mit.edu/projects/Mayhem/129626


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#14 2008-03-29 14:50:05

thecooltodd
Scratcher
Registered: 2008-03-08
Posts: 75

Re: Help with Pendulum

Here's some nice GIFs I found:
http://i144.photobucket.com/albums/r162/thecooltodd/doublepe.gif
http://i144.photobucket.com/albums/r162/thecooltodd/Double-compound-pendulum.gif

Offline

 

#15 2008-03-30 14:57:24

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Help with Pendulum

Yep. That's a pretty non-linear system. I'd be impressed if someone could simulate that in Scratch such that it actually runs at a reasonable rate. The matrix method is pretty straightforward, so that might be a good start...

Offline

 

#16 2008-03-30 20:40:21

thecooltodd
Scratcher
Registered: 2008-03-08
Posts: 75

Re: Help with Pendulum

What's the matrix method?  If it involves a matrix it would be a lot harder to do in Scratch...

Offline

 

#17 2008-03-31 03:20:37

thecooltodd
Scratcher
Registered: 2008-03-08
Posts: 75

Re: Help with Pendulum

Well, this is the closest I can get to one:
http://scratch.mit.edu/projects/thecooltodd/131516

lol

Offline

 

#18 2008-03-31 23:45:28

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Help with Pendulum

It turns out to be pretty complicated. Maybe something only paddle2see or canthiar could do  smile  Here's a good link for the governing equations:

http://www.myphysicslab.com/dbl_pendulum.html

Offline

 

#19 2008-04-01 02:32:15

thecooltodd
Scratcher
Registered: 2008-03-08
Posts: 75

Re: Help with Pendulum

Thanks.  I found several websites like that as well.  How fast could scratch calculate these though?
θ1'' =        −g (2 m1 + m2) sin θ1 − m2 g sin(θ1 − 2 θ2) − 2 sin(θ1 − θ2) m2 (θ2'2 L2 + θ1'2 L1 cos(θ1 − θ2))
L1 (2 m1 + m2 − m2 cos(2 θ1 − 2 θ2))
θ2'' =       2 sin(θ1 − θ2) (θ1'2 L1 (m1 + m2) + g(m1 + m2) cos θ1 + θ2'2 L2 m2 cos(θ1 − θ2))
L2 (2 m1 + m2 − m2 cos(2 θ1 − 2 θ2))

Offline

 

#20 2008-04-01 02:34:01

thecooltodd
Scratcher
Registered: 2008-03-08
Posts: 75

Re: Help with Pendulum

Btw, here are some other links:
http://scienceworld.wolfram.com/physics/DoublePendulum.html
http://www.maths.surrey.ac.uk/explore/michaelspages/Double.htm

Offline

 

#21 2008-04-01 02:47:57

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Help with Pendulum

thecooltodd wrote:

Thanks.  I found several websites like that as well.  How fast could scratch calculate these though?
θ1'' =        −g (2 m1 + m2) sin θ1 − m2 g sin(θ1 − 2 θ2) − 2 sin(θ1 − θ2) m2 (θ2'2 L2 + θ1'2 L1 cos(θ1 − θ2))
L1 (2 m1 + m2 − m2 cos(2 θ1 − 2 θ2))
θ2'' =       2 sin(θ1 − θ2) (θ1'2 L1 (m1 + m2) + g(m1 + m2) cos θ1 + θ2'2 L2 m2 cos(θ1 − θ2))
L2 (2 m1 + m2 − m2 cos(2 θ1 − 2 θ2))

As g, and the mass of the two pendulems, and the lengths are constant, you can simplify the equations a lot before putting them into scratch.

EG, taking G as 10, and both pendulems as mass 1 and length 1, you get:

θ1'' =        −30 sin θ1 − 10 sin(θ1 − 2 θ2) − 2 sin(θ1 − θ2) 10 (θ2'2 + θ1'2 cos(θ1 − θ2))
(3 − cos(2 θ1 − 2 θ2))L1 (3 − cos(2 θ1 − 2 θ2))
(I think)

(though shouldn't there be a "t" for time in there somewhere?)


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#22 2008-04-01 02:52:46

thecooltodd
Scratcher
Registered: 2008-03-08
Posts: 75

Re: Help with Pendulum

T is actually not required for time because I'm not sure if you're familiar with calculus or not, but when it has a quotation mark that is suppose to mean second derivative, which is acceleration.  So I simply make the rotational speed change by the rotational acceleration and have a separate script always changing the position by the rotational speed.

Offline

 

#23 2008-04-01 02:55:42

thecooltodd
Scratcher
Registered: 2008-03-08
Posts: 75

Re: Help with Pendulum

Anyways, does anyone understand the Lagrangian equation?  Because actually I believe I may be able to simplify (by my definition of simplify) the overall angular acceleration equation.  But I need to be sure how to use Lagrangian equations to do that...

Offline

 

#24 2008-04-03 09:15:54

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Help with Pendulum

But surely the acceleration changes as time passes... I would have thought time would be one of your basic variables in such an equation.  The only variable, in a given set up, in fact.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#25 2008-04-03 10:01:30

Canthiar
Scratcher
Registered: 2007-05-16
Posts: 100+

Re: Help with Pendulum

I haven't been checking the website for a while and Chalkmarrow pointed me to this thread.

Regarding time.  Normally in physics simulations you don't have to calculate the second derivative because you don't do the simulations using absolute time, it's normally done using delta times.  Then you only calculate the movement made during that delta time.

Is this just to do a simulation or is it to create an equation for the path of the pendulums?  If it is just for simulation I would do it using impulses and moments of inertia.  Then it wouldn't matter how many pendulums were linked to one another.  I think I will take a look at that approach some time today.

Offline

 

Board footer