Code from Game Programming Gems series that might be useful.