Gravity part deux.

So I’ve been playing around in Python lately, primarily because I’ve been teaching it to a kid I’ve been tutoring. I decided to take the opportunity to port my old C# based gravity simulation to see how hard it would be to implement. I chose to use pygame because it provides the screen update engine and drawing routines out of the box with an easy way to tell how many milliseconds have passed since the last frame update (required for accurate physics). I haven’t really made any tweaks to the physics engine since the mono version, but it’s still pretty cool to watch. One thing I did add to this is a 2×2 box with alpha 10 that simulates a pencil running over paper wherever a ball passes. I liked the visualization so much, I left it turned on in the version I hereby bequeath to you, dear internet. Below are two of the generated images, the lighter the color of the line, the faster the ball was moving at the time.

First image from my gravity simulator
First image from my gravity simulator
Second image from my gravity simulator
Second image from my gravity simulator

Oh, I suppose you’d like to download the current version. It’s sloppy, but you’re welcome to it! Some code borrowed from the python/pygame tutorials, but the physics are all mine.

Download it here.

Update: Almost forgot!!! Left click adds an additional ball, right click saves a screenshot and clears the background.

Update 2:

This one was after about 30 minutes with 6 balls
This one was after about 30 minutes with 6 balls

Just another image, click to enlarge.

Update 4: Put a video up on YouTube showing what it looks like while running:

Wheeeeeeeee Gravity!1!!eleven!

Sooooo…. a few days ago I felt like simulating a bit of gravity. Turns out that was the easy part… Basically I wrote a gravity simulator with accurate(?) collision detection all based on force vectors applied over time. I did all the physics and trig work from the top of my head, and the last time I had a physics or trig class was eight years ago, so I might have forgotten something important. Collisions look right to me right now, but the code driving them relies on some pretty loose interpretations of gravity/time, so any frameskips could cause some rather interesting reflections. Tarball (with source) and Ubuntu deb package (binary only) at their respective links.

I made a half-assed attempt at commenting the source, because I’m a nice guy. You should be able to get an idea of what I was thinking from there.

Update [20081002003930EDT]: Almost forgot, uses Cairo for drawing. XOrg process maxes the cpu at the resolution I’m using for this thing… NO idea why. Any programmers wanna help?

Nag’s Head in 24 hours.

I’ve been in Nag’s Head for just a bit over 24 hours now and thus far it’s been the best Nag’s Head trip yet. Lets start at the beginning… Deer in a bag. Fucking deer in its fucking bag made me have to do a pirouette in my fucking car on the driver’s side tire, then some kind of double hamstring somersault backflip and ended up in the next lane over doing the speed limit. Totally sweet dude. Once we got here shit got real and we got as obliterated as possible for maximum debauchery. There was some crazy girl, but that problem was solved in short order. Today there was a liberal smattering of rock band, outlet mallification, and beachgoing X 2. The first beach trip (among the day walkers) was pretty much a bust, there being a distinct shortage of surfable waves, however the second trip made tonight worthwhile. I got to the beach around 3 am and immediately noticed that I was surrounded by phytoplankton. Every movement, no matter how deep under water, caused a flurry of tiny green luminescent organisms to fire their biochemical caches and illuminate the immediate area, giving a net effect of glowing water. My friend Scott happened to bring a boogie board and was floating, so I became one with the ocean and learned to float too. After a liberal period of stargazing, I began to pay attention to the ocean’s warm embrace and happened to notice a clicking sound underwater. It was probably a good minute before I realized that the rhythmic clicking I was being subjected to wasn’t one of my friends, but was in point of fact dolphins. I was hearing dolphins talk to each other. I know this description doesn’t really convey the beauty I experienced today, but I wanted to record it regardless. Fuck you.

KVM Kernel Virtualization in Ubuntu Hardy

I just tried KVM under Hardy (which I’m loving by the way) and had some notes in case any other early adopters wanted to give it a try.

To install it, you need three packages (at least, I did):
sudo aptitude install kvm virt-manager libvirt-bin

You’ll also need to add yourself to three groups:

  • System -> Administration -> Users and Groups
  • Click “Unlock”
  • Enter password, etc.
  • Click “Manage Groups”
  • Under each of the following groups, make sure your user name is checked:
    • kvm
    • vde2-net
    • libvirtd
  • Reboot!

When you get the system back up, the Virtual Machine Manager is under Applications -> System Tools.

Have fun!!!

I’m at a loss for words

I know I don’t update here often, but I just thought it would be pertinent at this particular junction. This blog is a combination of my personal life (usually just the bad parts for whatever reason) and my technological exploits, and today will only be slightly outside the usual realm of nonsensical debauchery. Today, I am happy. There’s someone beautiful and hilarious and brilliant and amazing who has chosen to grace me with her attention. I can talk to her about the most obscure scientific discovery and she wants to know more about it and how it affects the world. Did I mention amazing? I think I did…

But alas, this wouldn’t be a very good post here at were I not to include something at least remotely technical… This weekend I finished preliminary work on my own thumbdrive based distribution of ubuntu. I wrote my own sexy splash screen and modified the themes a bit. I added all the usual programs that I love, set my defaults the way I like them, and even fixed a few bugs in the latest version (upon which this was based). Since it’s thumbdrive based and I have an amazing thumbdrive (OCZ ATV Turbo), it boots and runs faster than any hard disk install I’ve ever used. Unfortunately desktop effects only work on intel video hardware, but at least I have a persistent partition upon which to store any changes I make to the OS. My 4GB drive should be enough for a year’s worth of work if I stay away from video. All of this is thanks to two wonderful tools. The first of which is remastersys, which I use to turn a virtual machine into a full distribution of linux. Secondly, and just as important to this particular venture of mine is‘s tutorial on turning ubuntu 7.10 in to a pen drive bootable (and usable) distro. Now the tutorial as is has some problems, all of which are in the zip file near the end of the tutorial. Many entries in that file don’t work, and the defaults are not set for a persistent install. Luckily for you, fearless user, I have below the contents of my syslinux.cfg for your internet related needs. Also, you can put anything you want in isolinux.txt.

DEFAULT persistent
LABEL persistent
menu label ^Start Ubuntu in USB persistent mode (saves changes)
kernel vmlinuz
append file=/preseed/ubuntu.seed boot=casper persistent initrd=initrd.gz vga=0x0317 quiet splash --
LABEL live
menu label ^Start Ubuntu in Live mode
kernel vmlinuz
append file=/preseed/ubuntu.seed boot=casper initrd=initrd.gz vga-0x317 quiet splash --
LABEL xforcevesa
menu label Start Ubuntu in safe ^graphics mode
kernel vmlinuz
append file=/preseed/ubuntu.seed boot=casper persistent xforcevesa initrd=initrd.gz quiet splash --
menu label ^OEM install (for manufacturers)
kernel vmlinuz
append file=/preseed/ubuntu.seed boot=casper oem-config/enable=true initrd=initrd.gz quiet splash --
menu label ^Boot from first hard disk
localboot 0x80
append -
DISPLAY isolinux.txt

Have fun. I know I am.

The fight is finished

Well, I finally finished the fight and beat Halo 3 on Legendary. It took much longer than I expected, but was worth every second. I also found all but 1 skull (the last one has yet to be found by anyone) and tomorrow I’ll activate all 7 terminals. I feel so accomplished… and so tired. Hail to the Master Chief.


So, I just saw a preview for the film “Juno” and I can’t wait. It looks fantastic, and has some awesome one-liners in the trailer alone. Same director as “Thank You for Smoking”, which you should also see.