User:Tamas Bates/RWRM/HW1: Difference between revisions

From XPUB & Lens-Based wiki
Line 2: Line 2:


A small program written in Javascript to create fractal-like images made of triangles in a user's web browser. The sequence begins with a single "seed" triangle, created and positioned near the center of the viewer's screen as part of the program's initialization. From each of the triangle's corners a new, slightly smaller, triangle grows out along an axis which bisects the corner it was created from. This process is continued for each of the new "child" triangles and their resulting children, with care taken to avoid growing new triangles which overlap any existing triangles. After some time, the resulting final shape is approximately hexagonal (though not all sides are of equal length) and contains many pseudo-hexagonal pockets, some of which are filled with spiralling intrusions of ever-shrinking triangles.
A small program written in Javascript to create fractal-like images made of triangles in a user's web browser. The sequence begins with a single "seed" triangle, created and positioned near the center of the viewer's screen as part of the program's initialization. From each of the triangle's corners a new, slightly smaller, triangle grows out along an axis which bisects the corner it was created from. This process is continued for each of the new "child" triangles and their resulting children, with care taken to avoid growing new triangles which overlap any existing triangles. After some time, the resulting final shape is approximately hexagonal (though not all sides are of equal length) and contains many pseudo-hexagonal pockets, some of which are filled with spiralling intrusions of ever-shrinking triangles.
'''HOW'''
:Rendering and computation of the necessary vector operations for positioning the triangles was handled by a vector graphics library called Paper.js. From each triangle, a child triangle was created at each available corner by duplicating the parent, scaling it down by a constant factor, and then rotating it around the corner it was created from. To avoid creating overlapping triangles every new triangle is inserted into an R-tree (a kind of 2D spatial data structure). Any triangle found to cause a collision in the R-tree is discarded.  The program keeps a list of every triangle which has not produced any children and works through them one by one, creating as many children as possible from a triangle, adding them to the end of the list, then removing the parent from the list and moving on to the next triangle.


===== Booze Bot =====
===== Booze Bot =====

Revision as of 10:43, 18 September 2013

Approximation of Triangular Crystal Growth

A small program written in Javascript to create fractal-like images made of triangles in a user's web browser. The sequence begins with a single "seed" triangle, created and positioned near the center of the viewer's screen as part of the program's initialization. From each of the triangle's corners a new, slightly smaller, triangle grows out along an axis which bisects the corner it was created from. This process is continued for each of the new "child" triangles and their resulting children, with care taken to avoid growing new triangles which overlap any existing triangles. After some time, the resulting final shape is approximately hexagonal (though not all sides are of equal length) and contains many pseudo-hexagonal pockets, some of which are filled with spiralling intrusions of ever-shrinking triangles.


HOW

Rendering and computation of the necessary vector operations for positioning the triangles was handled by a vector graphics library called Paper.js. From each triangle, a child triangle was created at each available corner by duplicating the parent, scaling it down by a constant factor, and then rotating it around the corner it was created from. To avoid creating overlapping triangles every new triangle is inserted into an R-tree (a kind of 2D spatial data structure). Any triangle found to cause a collision in the R-tree is discarded. The program keeps a list of every triangle which has not produced any children and works through them one by one, creating as many children as possible from a triangle, adding them to the end of the list, then removing the parent from the list and moving on to the next triangle.
Booze Bot

An Arduino Uno connected to a bank of relays wired up to the power switches on several small vacuum pumps. Each pump rests in a cardboard frame on top of a milk crate, which has the open side facing the user. A funnel beneath each pump routes fluid into the crate, depositing any liquid into a larger funnel balanced above a drinking glass. The input side of each pump is connected to a length of rubber tubing, which is inserted into a collection of liquors. Pressing a button connected to the Arduino activates the pumps and produces a cocktail for the user.

HOW

The vacuum pumps were taken out of a set of breast pumps which ran on DC power. Each of them had their input voltage line soldered to a relay connected to the arduino. Through experimentation the speed at which liquor could be moved by the pumps was determined and hard coded on the arduino. To fonstruct a cocktail the program loaded a file containing a list of the ingredients available at each pump, and how much of each was required for the drink. It would run each pump corresponding to the needed ingredients for a short interval which was computed from the pumps' measured flow rates to extract the correct amount of each liquid. The button was simply connected to a digital input pin on the arduino which the triggered the program to make a single drink.
Lightning Bolt Generator

A small program written in Lua. It begins by drawing a solid black background on the user's screen. At the top of the screen a clump of colored pixels forms, white at the center and fading to dark purple and black at the edges. These expand downward in an erratic fashion, carving out a jagged path toward the bottom of the screen, occasionally branching out into some smaller paths during the descent. The result is like watching lightning strike in slow motion. At any time the user can restart the process to generate a new and different lightning bolt.