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.
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!
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.
// y = a * e ^ (tb) * sin(Theta)
// x = a * e ^ (tb) * cos(Theta)
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.
// y = a * e ^ (tb) + sin(Theta)
// x = a * e ^ (tb) + cos(Theta)
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.
// y = A * sin(wt) + D
// 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.
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!