Saturday, October 06, 2018

Animating Atoms With Scratch

Litium by Maddie
I'm working with an 8th grade science teacher on an exciting project. His students are becoming familiar with the periodic table of the elements and the basic parts and characteristics of elements.
Creating animations of invisible phenomena helps learners gain a deeper understanding of them, so rather than study or create pictures of atoms I thought this topic provided a great opportunity to incorporate some coding by animating them.

Debating Different Approaches

I first presented the students with two different approaches I had worked out for animating the electrons orbiting the nucleus. The first is a very simple script that just rotates a sprite in place. I didn't tell them how it was possible for the electron to be orbiting away from the center but they figured out after a little discussion that the image was offset from the center of the sprite.

We talked about how the electron can't trace its orbit this way because it can only hold the pen in the center of the sprite, not where the image is.
The second option uses sine and cosine functions to place the sprite on the path of its orbit. 
I had asked a math teacher what he thought about presenting an algorithm that employs math they wouldn't be familiar with and he supported the idea if I could give a simple enough explanation about what the functions did. It turned out to be a good decision because several great things happened as they watched the electron orbit in this way.
First, as I began explaining how this algorithm uses relationships between angles and sides in a right triangle to calculate changing positions a certain distance (radius) away from the center, some students immediately remembered and saw the relevance of concepts like the hypotenuse. Second, a few students who had been exposed to more advanced math were excited to see it applied here. One girl asked if this had to do with SOHCAHTOA and was thrilled to have made the connection.
To demonstrate this application of triangles to the circle I showed them this animation:

It's amazing to think about how the computer is re-calculating that position so many times each second!
After seeing how both approaches worked they agreed that the second would better depict the electron orbits, especially as they progressed to multiple shells.

Divergent Solutions

While I had thought we had consensus that using trigonometric functions more accurately depicts movement of the electrons around the nucleus, especially as the sprite itself is moving on its orbit and not just appearing to do so, once the students got to work I was surprised and delighted to see some of them coming up with ways to animate their atoms using the simple rotation script while still showing the atoms' orbits. They figured out they could add rings to the sprite costume, something I hadn't thought of! One student even cycled through multiple costumes in each sprite to achieve an awesome kind of 3D effect:

Low Floor High Ceiling

I had expected that using Scratch for these animations would give students who wanted to the freedom to explore algorithms I hadn't shown them and invent their own approaches. I was floored (haha, just saw the pun) to see one student basically create a program with the ability to display any atom the user chooses. She came up with all of this on her own!
You can try it out, it's really something.

No comments :