Life as Clay

Archive for November 2009

And the flu slowed me down…

with one comment

I’ve been living in a Dayquil haze for the past several days, unable to do much other than look forward to the departure of this cold/flu that I have. I hope it’s H1N1, just to get that out of the way, but who knows? Between bouts of delirium, I’ve managed to update the population generator a little. It now assigns a weight and height to everybody, based on national statistics. Weight and height for children under 18 are assigned based on CDC growth charts, whereby the children are put on a course to achieve a BMI that corresponds with the national average. BMI reads differently for children, so it is not displayed for them. The chart on the lower-left is the distribution of the population based on BMI. It’s not perfect, but comes close to mimicking the US data.

bmi calcs

Written by Clay

November 11, 2009 at 16:01

When random is funny

leave a comment »

I had to chuckle… Continuing the Population Generator, I grabbed lists of the most common names in the United States (1000 for male and female, plus 1000 surnames) and wrote a function to assign a name to everybody in my pseudo populations. On the first test of this, what do I get out of all of the randomness but baby Anthony Hopkins. That’s not to mention Cindy Bird and Heath Byrd… Random isn’t feeling so random.

Anthony HopkinsI encountered an error when trying to import a file into Processing. This silly dialog box popped up, which also made me chuckle, because it reminds me of some of the temp dialog boxes that I used to include in Access apps that I wrote. From time to time I forgot to remove them or change the text and I always had a confused/bemused person calling to ask what it meant.

funny dialogIt lied, though… It deleted the file in place and I had to recreate it.

Written by Clay

November 6, 2009 at 18:15

Population Generator

leave a comment »

Well, I’ve been away, working on a larger project. It’s less artsy but more practical towards my interests in simulation. Interestingly, it takes only mild deviations away from the world of data art to begin to realize the limitations of Processing. (That’s not entirely fair: Processing can import and use Java libraries, so there is more available that I currently am using. I have not, however, played with importing other libraries yet.)

I created a population generator that randomly generates a population of a specified size. It then displays 4 random members of the population above the demographics of the population. Clicking (can’t do it here, on the image….) rotates different members of the population into the slots above the demographics. Age 18 is considered full grown. People under 18 are displayed relative to the size of a full adult, scaled based on their age. Eventually, I will build in variation for height, weight, and other demographics. The colors of their shirts are randomly generated when they are created, but the tone of the skin on their head is randomly chosen from only 3 colors.

The demographics display is a technique used frequently in public health and demography, called a population pyramid. I think mine is upside down, but that’s an easy fix. In fact, I already fixed it in the code, but didn’t want to take a new screenshot. :)

So, why do this? My hope is to be able to create digital populations of people that I can use to simulate a variety of things related to public health, disease, and complex emergencies. That’s a long way down the road, but I think that I’ve done pretty well for the two days that I’ve spent working on it so far — especially for a programming newbie!

This definitely remains a work in progress, but this is what it currently looks like:

Population Generator

Written by Clay

November 5, 2009 at 22:03

Snake-like drawing object

leave a comment »

I’m working through lessons about arrays and object oriented programming. One of the lessons in the book creates a ‘snake’ that looks like a trail that follows the pointer. I reworked it to turn it into an autonomous snake that optionally leaves a trail. Since the bulk of the code is in an object, it’s easy to call as many instances as you want. The best way to view this is to click on this link and go to the OpenProcessing site.

running mandotsdots and square

Written by Clay

November 2, 2009 at 22:19

Posted in Code, Processing

Tagged with , ,

Brain Warmer

leave a comment »

I have a tendency to have ideas that are larger than my implementation capacity. That leads to frustration, which leads to inaction, which leads to surfing the Internet for long periods of time without accomplishing anything. This was a brain warmer, to get me comfortable at the desk and thinking.

random circles smallrandom circles medium

int startX = 0;
int startY = 0;
int maxDiam = 80;
int squareSize = 80;

void setup() {
  background(255);
  size(400,400);
  noStroke();
  smooth();
}

void draw() {
  drawBall(startX, startY, maxDiam);
  
  
  // move to the next start position on the current row
  startX += squareSize;
  
  // Move to the next row
  if (startX >= width) {
    startX = 0;
    startY += squareSize;
  }
}

void drawBall(int startX, int startY, int maxDimension) {
  
  float diam;
  diam = random(maxDimension/10,maxDimension);
  
  fill(random(0,240), random(0,240), random(0,240));
  ellipseMode(CORNER);
  ellipse(startX, startY, diam, diam);
}

Written by Clay

November 2, 2009 at 16:14

Posted in Code, Processing

Tagged with , ,

Orbital Variation

leave a comment »

Long drive today and I’m a bit tired, so I decided to play with the orbital system that I set up the other day. In this instance, the ‘sun’ is the position of the mouse, so moving the mouse around causes the relative positions of the ‘earth’ and ‘moon’ to change. I allowed it to draw on top of itself for a while and thought that the end result looked somewhat like renderings of proteins that I’ve seen, or perhaps a pile of Mardi Gras beads. :)

orbital variation

Written by Clay

November 2, 2009 at 00:58

Posted in Code, Processing

Tagged with , ,