(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
$.extend(KhanUtil,{Polygon:function(r){function a(r,a,n){var t=findIntersection([r,a],[[0,0],n]),e=t[0],i=t[1];return Math.sqrt(e*e+i*i)}function n(r,a){var n=a[0]-r[0],t=a[1]-r[1];return Math.sqrt(n*n+t*t)}function t(r){var a=KhanUtil.currentGraph,n=l.length;a.style({stroke:KhanUtil.ORANGE,"stroke-width":3}),a.line(l[r%n],l[(r+1)%n]),a.line(l[(r+1)%n],l[(r+2)%n]),a.line(l[(r+2)%n],l[r%n])}function e(r){t(r),t(r+l.length-2)}function i(r){switch(r%4){case 0:return KhanUtil.BLUE;case 1:return KhanUtil.ORANGE;case 2:return KhanUtil.GREEN;case 3:return KhanUtil.PINK}}var h=[],l=[],o=[];!function(){for(var n,t,e=KhanUtil.currentGraph,i=1,o=5,c=1,s=0;r-2>s;s++){var u=180/r,p=KhanUtil.randRange(-10,10)/40;h.push(u*(1+p))}for(;l.length!==h.length+2;)n=0,l=[[0,0],e.polar(KhanUtil.randRange(i,o),n)],$.each(h,function(r,h){if(n+=h,0===r)t=KhanUtil.randRange(i,o);else{var s=a(l[l.length-2],l[l.length-1],e.polar(i,n));if(Math.floor(s)<=i+c)return;s=Math.min(Math.floor(s)-c,o),t=KhanUtil.randRange(i,s)}l.push(e.polar(t,n))})}(),this.draw=function(){var r=KhanUtil.currentGraph;r.style({stroke:KhanUtil.BLUE}),l.push([0,0]),r.path(l),l.pop()},this.drawDiagonals=function(r){var a=KhanUtil.currentGraph,n=l[r%l.length];$.each(l,function(t,e){r!==t&&a.line(n,e)}),e(r)},this.drawRadialDiagonals=function(){var r=KhanUtil.currentGraph,a=0,n=0;$.each(l,function(r,t){a+=t[0],n+=t[1]}),a/=l.length,n/=l.length,r.style({stroke:KhanUtil.ORANGE},function(){$.each(l,function(t,e){r.line([a,n],e)})}),r.circle([a,n],.3)},this.drawExteriorAngles=function(){var r,a=KhanUtil.currentGraph,t=0;a.style({"stroke-dasharray":"-"}),l.push([0,0]),$.each(l,function(e,i){if(0!==e){var h,l=n(r,i),c=i[0]-r[0],s=i[1]-r[1],u=180*Math.acos(c/l)/Math.PI;0>s&&(u=360-u),h=a.polar(l+2,u),h[0]+=r[0],h[1]+=r[1],a.line(r,h),1!==e&&a.style({"stroke-dasharray":""},function(){o.push(a.arc(r,.5,t,u))}),t=u}r=i}),a.style({"stroke-dasharray":""},function(){o.push(a.arc(r,.5,t,360))}),l.pop()},this.animateExteriorAngles=function(r){var a=KhanUtil.currentGraph,n=a.scalePoint(l[r]);l.push([0,0]),o.unshift("dummy");for(var t=1;t<o.length;t++){var e=o[t],h=l[t],c=a.scalePoint(h),s=e.attr("stroke",i(t)).clone();s.animate({translation:[n[0]-c[0],n[1]-c[1]]},1e3)}l.pop(),o.shift()},this.clone=function(){return $.extend(!0,{},this)},this.ex=function(){return o}},Circle:function(r,a){function n(r,a,n){return a%=360,n%=360,a>n?n>r||r>a:r>a&&n>r}function t(r,a){var n=Math.atan2(a,r);return 0>n&&(n+=2*Math.PI),n=180*n/Math.PI}a=a||[0,0];var e=.1;!function(){var n=KhanUtil.currentGraph;n.style({stroke:KhanUtil.BLUE}),n.circle(a,r)}(),this.drawPoint=function(a,n){var t=KhanUtil.currentGraph,i=t.polar(r,a);if(n){var h=t.polar(r+.4,a);t.label(h,n,"center",{color:KhanUtil.BLUE})}return t.circle(i,e)},this.drawCenter=function(r,n){var t=KhanUtil.currentGraph;if(t.style({fill:KhanUtil.BLUE},function(){t.circle(a,e)}),r){var i=t.polar(.4,n);t.label(i,r,"center",{color:KhanUtil.BLUE})}},this.drawRadius=function(n){var t=KhanUtil.currentGraph,e=t.polar(r,n);return t.line(a,e)},this.drawChord=function(a,n){var t=KhanUtil.currentGraph,e=t.polar(r,a),i=t.polar(r,n);return t.line(e,i)},this.drawLabel=function(a,n){var t=KhanUtil.currentGraph,e=t.polar(r+.4,n);return t.label(e,a)},this.drawMovablePoint=function(a,e,i){var h=KhanUtil.currentGraph,l=h.polar(r,a);e=e||0,i=i||360,h.graph.movable={vertex:KhanUtil.bogusShape,arc:KhanUtil.bogusShape,chords:[KhanUtil.bogusShape,KhanUtil.bogusShape],label:KhanUtil.bogusShape},h.graph.inscribedPoint=h.addMovablePoint({coordX:l[0],coordY:l[1]}),h.graph.inscribedPoint.onMove=function(a,l,o){var c=t(a,l);return n(c,e,i)?(h.style({stroke:KhanUtil.INTERACTIVE,color:KhanUtil.INTERACTIVE}),h.graph.movable.arc.remove(),h.graph.movable.chords[0].remove(),h.graph.movable.chords[1].remove(),h.graph.movable.vertex.remove(),h.graph.movable.label.remove(),h.graph.movable=h.graph.circle.drawInscribedAngle(c,i,e,o),h.polar(r,c)):!1}},this.drawCentralArc=function(r,n,t){var e,i=KhanUtil.currentGraph;return t=t||.5,i.style({fill:""},function(){e=i.arc(a,t,r,n)}),e},this.drawCentralAngle=function(r,a,n){var t={radii:[]};return t.radii.push(this.drawRadius(r)),t.radii.push(this.drawRadius(a)),t.arc=this.drawCentralArc(r,a,n),t},this.drawInscribedArc=function(a,n,e,i){var h,l=KhanUtil.currentGraph,o=l.polar(r,a),c=l.polar(r,n),s=l.polar(r,e),u=t(c[0]-o[0],c[1]-o[1]),p=t(s[0]-o[0],s[1]-o[1]);return i=i||.5,l.style({fill:""},function(){h=l.arc(o,i,u,p)}),h},this.drawInscribedAngle=function(r,a,n,t,e){var i=[this.drawChord(r,a),this.drawChord(r,n)],h=this.drawPoint(r),l=this.drawInscribedArc(r,a,n,t),e=this.drawLabel(e,r);return{chords:i,vertex:h,arc:l,label:e}}}});
},{}]},{},[1]);
