Here is a thread in this forum about it:
http://arduino.cc/forum/index.php/topic,58048.0.html
Search FreeIMU on google and download the library. The fused algorithm there is completely open-source so you can try to decipher it yourself. It does not include code to calculate position though, so you will need to look elsewhere for position sensing.