A Processing Experiment

I always have found mathematics and physics interesting and had fun creating this small Processing experiment …

Source code: Elliptical Orbits, see it here
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

Comments

  • 黑帽SEO

    May 12, 2010 at 1:06 pm

    very good information you write it very clean. I’m very lucky to get

    this info from you.

  • Christian Louboutin Shoes

    May 16, 2010 at 4:58 pm

    great share, great article, very usefull for me…thank

    you

Your email address will not be published. Required fields are marked *