Algorithm Component Development

Algorithm Development Header

In the process of developing the components for my final project, I spend a good bit of time developing these algebraic equations that could then be used by themselves or in patterns. The end result is an extremely powerful pair of arrays that I can do just about anything with. Check it out after the link

My goal for the component was to create a set of points that would define the shape and to develop components that would be extremely easy to alter from the outside. If I could do that, it would be really easy to feed any sort of variables into the component and return a pair of arrays of points. Then, that set of points could be used as x and y coordinates to place any sort of vector graphics onto the stage. To start, I wrote down the various kinds of components I wanted to make; a circle, a sine wave, a cosine wave and a spiral. Then I spent time pseudo-coding how to develop the code that would feed into my arrays for each of the different shapes (wikipedia is a great resource for equations!). Finally, I started coding on the computer building what I thought would be the easiest to make; the circle.

Circle

As it turned out, since the circle was the first component I decided to make, it took by far the longest. I also had to build the testing file and testing code. The main necessities for the component are starting rotation (where the first point will be placed), how many points there are (determines the spacing between points) and the radius of the circle. All these variables can be shifted by the external component controller as well as internally depending on what is needed. As the points are plotted, they are fed into an array for x values and one for y values. Thus with the two arrays I have the entire set of points for the circle. Finally, the controller calls the testing function that draws dots based on the x and y coordinates from the array. I was rather happy to see it all working properly!

Logarithmic Spiral

Next, I started working with generating a spiral. While I originally called it just “spiral,” it was actually generating a logarithmic spiral and when I later decided to add in other kinds of spirals, I needed to alter the naming for the function. This component uses mostly the same code from the circle example, except with one exception – the two lines that generate the x and y positions. I used these formulas as my basis for identifying what the x and y values.

//Logarithmic Spiral
// y = a * e ^ (tb) * sin(Theta)
// x = a * e ^ (tb) * cos(Theta)

Archimedean Spiral

Very similar to the Logarithmic Spiral, the Archimedean Spiral has only a single difference; the replacement of a multiplication with an addition as seen below.

//Archimedean Spiral
// y = a * e ^ (tb) + sin(Theta)
// x = a * e ^ (tb) + cos(Theta)

Sine Wave
^Sine

Cosine Wave
^Cosine

The sine wave and cosine wave evolved together, since they are so similar. As seen in the code, the difference is just the addition of PI/2 inside the sine.

Sine
// y = A * sin(wt) + D
Cosine
// y = A * sin(wt+PI/2) + D

After developing the first set of code for the circle, each additional function only took a half-hour to 45 minutes to create, which greatly helped speed up the development time. As a final addition, I made each variable randomly assigned when the component was created, so every time one clicks on a specific function, one will receive a different looking set of points. All in all, I’m very pleased with the way that the components work and look forward to developing uses for them.

View the component tester here

From here, I need to create a few more components (namely a straight line and a spring-like shape) and then start developing concepts for larger shapes that will make usage of these smaller components. I’m also going to look into introducing randomness into the design to produce shapes that, while appearing more random, are still arranged in a shape. Onward!

3 Responses to “Algorithm Component Development”

  1. Deborah MacPherson Says:

    Why did you decide to go from the spiral to the sine/cosine waves? Have you worked with fractals?

  2. Aaron Says:

    Mainly, I wanted to experiment with different mathematical shapes. After creating a circle, a spiral seemed a logical progression, but it was a bit different!

    I did do some work with fractals. If you are interested, check
    http://10-yen.net/wordpress/2007/09/04/generative-interactive-trees/
    or
    http://10-yen.net/wordpress/2007/07/17/fractal-magic/

  3. tree loppers Liverpool Says:

    tree loppers Liverpool

    10 yen | Aaron Bell Design

Leave a Reply

You must be logged in to post a comment.