Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 20 in printed book and digital formats -- plus a one-year subscription (beginning with 21.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview

Buy Now

Issue 4.3


Harmonic Motion

The pendulum as an elegant example of harmonic motion

Issue: 4.3 (January/February 2006)
Author: JC Cruz
Author Bio: JC is a freelance engineering consultant currently residing in British Columbia. He develops custom OS X applications and teaches origami at the local district libraries.
Article Description: No description available.
Article Length (in bytes): 32,673
Starting Page Number: 15
Article Number: 4309
Resource File(s):

Download Icon 4309.zip Updated: 2013-03-11 19:07:59

Related Web Link(s):


Excerpt of article text...

In my previous article, I demonstrated how to use the Euler Method to simulate the motion of a projectile. I have introduced a new REALbasic class, rbc_vector, which enables me to solve motion ODEs (Ordinary Differential Equations) using vector quantities. I have also shown a Sprite subclass, rbc_newton, which encapsulates the Euler Method as well as various motion parameters.

The topic for today is the physics of harmonic motion. I will introduce a new algorithm that can solve more complex ODEs with better precision and stability than the Euler Method. I will also discuss the physics behind harmonic motion. Finally, I will demonstrate how to simulate an elegant example of harmonic motion, the simple pendulum.

Basic Concepts

The Runge-Kutta Method

The Euler Method is a quick and simple way of numerically solving ODE equations. However, this algorithm suffers from a number of limitations. One primary limitation is that its accuracy is strongly dependent on the simulation step size. The smaller the step size, the better the accuracy. Consequently, smaller step sizes also translate to longer processing cycles.

Another limitation is that the Euler Method is inherently unstable when solving complex ODEs. Using ballistics.rb, I have demonstrated that changing the simulation size causes the algorithm to generate widely varying results. One way to address these problems is to replace the Euler Method with a different algorithm. Enter the Runge-Kutta Method.

...End of Excerpt. Please purchase the magazine to read the full article.