http://weelookang.blogspot.sg/2010/06/ejs-open-source-2-bar-magnets-compass.html