/* The world with CSS3 Transforms. Made by Kevin Jannis (@kevinjannis) View more at www.janniskev.in */ // Generates the world var Point=function(e,t){this.x=e;this.y=t};Point.prototype.rotateAroundOrigin=function(e,t){var n=this;var r=Math.cos(t)*(n.x-e.x)-Math.sin(t)*(n.y-e.y)+e.x;var i=Math.sin(t)*(n.x-e.x)+Math.cos(t)*(n.y-e.y)+e.y;return new Point(r,i)};Point.prototype.distanceTo=function(e){var t=Math.pow(e.x-this.x,2);var n=Math.pow(e.y-this.y,2);return Math.sqrt(t+n)};var Dot=function(e,t,n,r,i){e=e||0;t=t||0;n=n||0;r=r||0;i=i||0;this.x=Math.ceil(e*100)/100;this.y=Math.ceil(t*100)/100;this.z=Math.ceil(n*100)/100;this.angleX=Math.ceil(r*100)/100;this.angleY=Math.ceil(i*100)/100};var World=function(e,t,n){this.detailLevel=Math.max(t,3);this.radius=150;this.diameter=this.radius*2;this.circumference=this.diameter*Math.PI;this.background=n.image;this.backgroundWidth=n.width;this.backgroundHeight=n.height;this.el=document.getElementById(e);this.el.innerHTML="";this.el.style.width=this.el.style.height=this.diameter+"px";this.center=new Dot(0,0,0,Math.PI/2,0);this.top=new Dot(this.center.x,this.center.y-this.radius,this.center.z,Math.PI/2,0);this.bottom=new Dot(this.center.x,this.center.y+this.radius,this.center.z,-Math.PI/2,0);this.prepare();this.render()};World.prototype.prepare=function(){var e=Math.PI/(this.detailLevel-1);this.rows=[];this.rows.push({dots:[this.top],width:0,height:0});for(var t=1;t