Analog tilt sensors

Sorry, I don't remember enough about the math to help you out, but you can get the hardware at Sparkfun - they have several models, both bare ICs and breakout boards.

-j