Tag: Orbits

A Processing Experiment

by anthonyScavarelli on May.10, 2010, under Processing

I always have found mathematics and physics interesting …

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

Source code: Elliptical Orbits
Built with Processing

The fact that abstract equations full of several variables when used in programming can lead to truly beautiful results has always fascinated me ( just try changing any value (x) with sin(x) or cos(x) for example ). In fact using these equations are absolutely necessary when simulating more “realistic” results. The experiment above was a simple experiment ( for an assignment at school ) in creating elliptical orbits using elliptical equations.

float radius = (a * ( 1 - sq(e)))/( 1 + e * cos( angle )); //elliptical equation

The above code coming from the equation obtained from Wolfram MathWorld

where e refers to the “eccentricity” – a parameter that defines the “squished shape” of the ellipse ( a number between 0 and 1 ). An eccentricity of 0 will define a circle whereas an eccentricity of 1 will be so squished as to appear as a line. Go Ahead and play with the code linked above to experiment.

It’s fun to use equations to define motion. Instead of changing the position of an object linearly where each frame adds a discrete value such as one:

float position = position + 1;

changing it to ( for example ):

float position = position + position/sine(position) * 10.0;

can give a unique motion that can be both unexpected and perhaps interesting enough to be different ( I haven’t actually tried this yet haha). Not unlike an artist that sketches several different styles before settling on one in creating a new work it is important to treat this kind of programming as an art as well. Constantly try new things – one line of code can make a huge difference!

————————————————–

References

2 Comments :, more...