Category: Processing

VE Map Case Study

Here is my completed map project for Virtual Entertainment:

ve-map-small

The goal of the project was a large print with enough detail that it was still interesting when enlarged:

ve-map-detail

The project started out with attempts to import map files into Processing.

After overcoming this hurdle. I created a class for vehicles that “drive” around on the lines that represent roads on an image.  As the vehicles analyze pixels rather than vectors, this actually meant that I could import any black and white image to use for a map, and that the use of .e00 files or shapefiles was not essential (although I still ended up using them).

followpoints

However, these vehicles followed the lines of the map so precisely, that the resulting image was simple the original map, but in different colors.  In order to introduce more variation into the equation, I used these “Follow Points” as the targets for a seeking behavior, and then built a tolerance into the seeking behavior.  What this means is, the new vehicles would try to point to the Follow Points, but would stop changing the direction if they within a certain range.  This produced a great variety in lines, simulating a street where vehicles could drive on any section of the road they wanted, as long as they stayed inside the boundaries of the road.

pict1

I decided the top-down view wasn’t as interesting as I wanted, so I moved the entire thing over to 3D. Before, I had simply had every vehicle leave a trail behind it by never clearing the background.  However, I wanted to be able to rotate the image in 3D.  To do this, I gave every vehicle a history array that would keep track of where it had been, so its entire light trail could be drawn every frame.  The p3D renderer in Processing really started to struggle here, so I switched over to OpenGl, which is much faster.  Rendering the map in 3D did add some visual interest:

pict2-3d-opengl

At this point, I also set the project up so that it would render the entire project out as a PDF, meaning I could print it at any size.  This looked fine when it wasn’t enlarged, but when I rasterized the images at a large size in Photoshop, the strokes began to appear dotted, as apparently Processing doesn’t export strokes as being continously connected, but instead saves them as separate line segments:

pdf = (PGraphicsPDF) beginRaw(PDF, “pdf_lines.pdf”);
pdf.strokeWeight(0.25);

lines1

To remedy this, I set the pdf’s stroke settings in a way that Photoshop and Illustrator would render more nicely.  The following settings:

pdf = (PGraphicsPDF) beginRaw(PDF, “pdf_lines.pdf”);
pdf.strokeJoin(MITER);
pdf.strokeCap(SQUARE);
pdf.strokeWeight(0.25);

resulted in an image that was far less objectionable, unless zoomed to a very high level.

lines2

To make the map even more interesting, I created a simulation that tracked how often vehicles drove by a certain area, thereby creating a map of traffic density, which I figured I could roughly correlate to population in my simulation.

pict3-population

My eventual goal was to use this as a way of generating “cities” to match the “roads” that the simulation already created.  I successfully created a series of dots representing cities, with the size varying by population:

city-lights-small

However, this, when combined with the lines from the roads, became too visually busy.  In fact, I liked the initial rendering with the vertical lines better.  This led me to try a number of other visualizations,a ll of which ended up looking terrible.  I eventually decided that I liked the original version with just the traffic lines better.  Thomas Edison said he didn’t fail a thousand times while trying to make a lightbulb, he instead discovered a thousand ways not to make a lightbulb.  Similarly, I could say I wasted a lot of time trying things out and then coming back to the original, but I’ll try to look at it as discovering ways not to make a map look good. Actually, even when I put it that way it still sounds like kind of a waste of time.

So I decided to refine the original lines image to make it more intersting.  To add a bit more variety, I rendered out several versions with different line settings.  I then combined several of these so that there would be lots of “detail” lines forming the major shapes of the roads, but several thicker and brighter “accent” lines would add visual interest.  I ended up sing three different line weights, which gave a visual variety that I was happy with.

I even ended up using the population circles as a way of varying the lighting on the thinnest lines, creating an interesting effect, and ensuring that my work on the population simulation did not completely go to waste.

line-variation-small

A few more post production tweaks, and I ended up with my final print.

I’ll post the source code once I clean it up a bit.  I realize I’ve said that in several posts and have yet to post any of my code, but I also realize that probably nobody cares.

Strange Attractors Case Study

Final Image

Final Image

My first project for Virtual Entertainment uses Processing to visualize a mathematical system called a strange attractor.  Strange attractors create a cloud of points based on a quadratic map, a series of letters which the program translates into numbers which control its movement.  For example, the final image used the pattern “AMTMNQQXUYGA”.

While there are a huge number of combinations that can be created, most of them seem to move  fairly continuously in one direction, and don’t create an interesting pattern.  A computer program can figure out which patterns work and which don’t, but luckily my atrophied math skills got a break from having to figure this one out, as other people have already done it.

The basic attractor renders out a cloud of points:

Cloud of Points

Cloud of Points

I then explored several options for connecting the points, initially with straight lines:

Lines

Lines

Then with Curves:

Curves

Curves

At the same time, I modified the file to output a PDF, so that everything was in vector and can be scaled to any size.

Finally, I connected all of the points with a continuous spline.  Unfortunately, this narrowed my options for which attractors I could use, as it caused several patterns to look pretty lame:

Boring

Boring

Finally, I added color, by having processing grab colors out of an image file, resulting in the final image at the beginning of the post.  I also ended up with a few other images that I thought were cool.

I also explored some other options for this project, which didn’t turn out badly, but still need some more work.

[Download Processing Code]

References

Other Strange Attractors

Here are some other cool images that came out of my Virtual Entertainment processing project:

VE Project 1 Alternate Idea

I was exploring several options for my first Processing Project in Virtual Entertainment.  This was the other path I was exploring:

I’ll probably add some more info on how I did this soon.

Processing

In Virtual Entertainment this quarter, we are learning how to use the Processing programing language,which is designed specifically for creating interesting visuals ad generative art with code. Here are some of my very basic initial experiments: