Archive for July, 2010

Welcome to Isla Nublar

When I was a lad, I used to spend hours writing programs on the family Commodore. Generally they consisted of some top-secret security clearance screens (with flashing lights and passwords and everything. Completely uncrackable, usually even for me, but trivial to bypass if you had some familiarity with the List command) followed by many screens of text. I used BASIC as the world’s least practical word processor. I never took the time (nor, possibly, had the aptitude, but I cleverly avoided having to look that question head-on by not taking the time) to dig deeper into BASIC’s capabilities.  I left that to my brother, and now he writes software for a living and I think it’s neat that my blog has its own URL, so things seem to have worked out as they were meant to.

Still, though, I spent many an hour typing out BASIC code numbered line by numbered line, so when I got caught up in a conversation at work about Sierpinksi triangles I thought it might be fun to write a program to make one myself.

Sierpinski triangles are formed by designating three points of a triangle, then picking a random point within those points.  From that random point, move halfway to a randomly chosen vertex, and then from that point move halfway to a randomly chosen vertex, and so on.  They’re used as chaos theory illustrations – order developing as iterations increase.  I learned about them in Jason, Mark, and Julie’s science capstone presentation at Wartburg, and you can check out the Wikipedia page if you’re interested.

Finding a BASIC compiler and learning its particular nomenclature ended up taking far more time than actually writing the program did; turns out that even a far-from-expert like me can write a Sierpinski Triangle maker in a dozen lines of code.  It’s crazy to watch unfold on the screen, though.  All those random points end up looking like this:

Triangle-y

Cool, huh?  That’s a million points (which brings up an incidental point: modern computers are much faster than Commodore 128′s).  If you look about halfway up to the left of the triangle you can see the first few points.  I didn’t bother limiting the first random point to the triangle – it could pick any point within the full square.  So it picked a point a little outside, and then chose to go halfway to the upper left vertex for its next two dots.  Then the next 999,998 are correctly within the triangle boundaries.

Kind of fun to relive some childhood nerdish tendencies.  Go, BASIC!  (No criticism allowed from any professional programmers who read this (there used to be at least 2, but maybe they’ve cleared their RSS feeds and moved on).)

States of the Union

(Is this really my first post of 2010? Huh.)

A couple of months ago I found myself involved in a conversation about the heights of various states. The topic was triggered, if memory serves, by talking about scenic Northern Minnesota. Lovely country, we said, but man alive is it a long way across Minnesota going North. Stupid Minnesota – why is it such a tall state? From there we moved on to wondering whether it was, in fact, the tallest state. Alaska probably wins, we agreed, but after Alaska, Minnesota and California must be in a tight race for #2.

This, I thought, is the sort of conundrum that the Internet, and more specifically the good folks at Google (forever may they query), exists to help solve. But I came up empty. I couldn’t find any listing of state by latitude or longitude dimensions. I did, however, notice that the Wikipedia entries for states included their farthest North, South, East, and West dimensions. All that was needed was for some nerdlish soul to compile it into one document and calculate what those dimensions meant in terms of distance.

It turned into a fun project. I learned that a degree of latitude is 69.046767 miles and plugged that into a spreadsheet to start calculating state height. Width was a trickier proposition – a degree of longitude isn’t a consistent size. It’s (69.046767 miles)x(cosine of latitude), but which latitude to pick? Accurate width measurement would require determining where the wider part of the sate was and adjusting the formula state by state – northier latitude for Florida, southier latitude for Louisiana, etc. The main purpose of this project being to determine state height, that was more work than I was interested in doing, so I worked off the assumption that all states are shaped like Iowa or Texas (two of my native lands) and widest in the middle – I used (69.046767 miles)x(cosine(average of N and S latitudes)). I added another column of data that I call “IIWAS” (“If It Was A Square”), which is just the product of the height and width, because what the hey, Excel’s doing the work anyway. Hawaii becomes almost twice the size of Texas if you assume both are squares from their furthest cardinal direction points.

The data is from Wikipedia and you found this posted on some guy’s blog, so take it for what it’s worth. I doubt, for instance, that Nevada and Idaho are actually exactly the same height, down to the tenth of a mile. I find it interesting, though, and I enjoy having plugged a hole in the completeness of the random trivia available on the Internet. Turns out Minnesota is way down at #9, too. Well played, Florida. Well played.

Here’s a pdf version of the results, organized by height, and here’s the Excel spreadsheet if you’d like to play with the data or make fun of my formulas. Drop a comment and let me know if you find any use for this; I’d be curious to know.