Construct a spring mass damper system

53 views
Skip to first unread message

Mayank Pandey

unread,
Oct 23, 2021, 2:18:45 PM10/23/21
to Developing Interactive Simulations in HTML5
Hello,

I am trying to develop a simulation to demonstrate the spring mass damper system. I wanted to include a visual representation of it works. I know PhET sims has some simulations on springs (like Hooke's law, Masses and Springs). I was wondering how can I go about developing something like the attached figure in my simulation. It seems a little bit complicated and I am not sure how the animation works for the spring to stretch out and go back to rest. I would appreciate any help!
Screen Shot 2021-10-23 at 2.14.57 PM.png

cmalley

unread,
Oct 25, 2021, 12:31:17 PM10/25/21
to Developing Interactive Simulations in HTML5
You'll want to use scenery-phet.ParametericSpringNode. I was the author of the Hooke's Law sim, and scenery-phet.ParametericSpringNode.  I'm not as familiar with the Masses and Springs simulation, but I see that it also uses ParametericSpringNode. 

I would start by familiarizing yourself with ParametericSpringNode.  The scenery-phet repository has a very nice demo, the "Spring" screen, which looks like the screenshot below.  Each of the sliders in this demo controls a Property of the spring. To animate the spring, you'll probably be most interested in xScaleProperty.

Next, I would look at the mass-and-springs repository, to see how it animates xScaleProperty. Got to masses-and-springs.OscillatingSpringNode, and search for xScaleProperty.  If you need more help with masses-and-springs (e.g. how the animation works), feel free to ask again in this form, and we'll try to get someone who is familiar with that sim to respond.

I hope this helps!

Chris Malley
PixelZoom, Inc.

Spring-screen.png

Reply all
Reply to author
Forward
0 new messages