Water splashing

This is a simulation of water splashing.

A C program applies the wave equations to a grid and creates the three wave effects: a sinusoidal source on the left, a circling point, and a raised rectangle that disappears after part of the frames.

The program displays a preview of dots using OpenGL, and can output heightfields, which I had POV-Ray render, here.

I want an effect close to this one for the liquid in the wine bottle in another project.

Serial foot pedals

Here are some pedals for controlling the mpd (music player daemon) for easier transcribing of lectures. Play the audio with any mpd client, then run this to use pedals for pause and rewind-2-secs.


Uses pyserial and py-libmpdclient.

#!/usr/local/bin/python

import serial,time,mpdclient

class RetryingMpdController:
    def __init__(self,**kw):
        self.mpd_kw = kw
        self.reconnect()

    def reconnect(self):
        self.mpd = mpdclient.MpdController(**self.mpd_kw)
        print "connecting to mpd"

    def __getattr__(self,attr):
        def retrying_method(*args):
            func = getattr(self.mpd,attr)
            try:
                func(*args)
            except mpdclient.MpdError:
                self.reconnect()
                func(*args)
        return retrying_method

class Pedals:
    """
    connect RTS to DSR and CTS like so (pin numbers are for 9-pin
    serial port):

    pin 7 RTS -->-----------+
                            |
                left   /    |
    pin 6 DSR <-------/ o---+ 
                            |
                right  /    |
    pin 8 CTS <-------/ o---+
    """
    def __init__(self,*actions):
        self.ser = serial.Serial(port="/dev/ttyS0",rtscts=1)
    self.ser.setRTS(1)
        self.prev = False,False
        self.actions = actions

    def poll(self):
        pedals = self.ser.getDSR(),self.ser.getCTS()
        for which in range(2):
            if pedals[which] and not self.prev[which]:
                self.actions[which]()
        self.prev = pedals

class Playback:
    def __init__(self):
        self.mpd = RetryingMpdController(host='localhost',port=6600)

    def rewind(self,secs=2):
        pos,length,frac = self.mpd.getSongPosition()
        self.mpd.seek(seconds=pos-secs)

    def pause(self):
        self.mpd.pause()

play = Playback()

ped = Pedals(play.rewind, play.pause)

print "monitoring pedals (press ctrl-c to exit)..."
while 1:
    ped.poll()
    time.sleep(.01)

Lego

My face on Lego!

->->

I morph into Lego

First movement test

Lego visits my friend John in his dorm room.

Lego rides a motorcycle (two frames of video stitched together over a picture of Highway 1)

Lego sees his own reflection in a pitcher at Anna's house. You can see some reflections of her dad taking the picture.

Lego sees his reflection in water

Calibration experiment

I took a scanned photo; an HP DeskJet 820Cse inkjet printer; an Olympus C-3030Z digital camera; a Umax Astra 600S scanner; and a NEC FE1250 monitor and compared their colors as follows.

The monitor is casually calibrated for good black/white points, and there seems to be a gamma of about 2.3 between application color value and monitor output. I created 16-point gamma curves for R, G, and B for the printer by comparing printed colors and screen colors. I imagine I did a horrible job. The scanner and camera are not calibrated past whatever their Linux drivers do by default.

In this demo picture, I took a scanned photograph that looked good on the screen and printed it out. Then I scanned the print, photographed the print, and photographed the monitor. I quickly adjusted the black/gamma/white points of the scan and the photo of the scan. Those adjustments are shown to the right of their raw sources.