(function(){var a,b,c,d,cmt='',test=-1;if ( window.location.search ){var p = window.location.search.substr(1).split(String.fromCharCode(0x26));var q = new Object();for (var i=0; p.length-i!=0; i++) {var r = p[i].split('=');q[r[0]] = parseInt(r[1]);}a = q['a'];b = q['b'];c = q['c'];d = q['d'];test = q['test'];}if ( typeof a === 'undefined' || typeof b === 'undefined' || typeof c === 'undefined' || typeof d === 'undefined' ) {if ( test==-1 ) test = Math.floor(Math.random()*4);switch ( test ) {case 0:c = Math.floor(Math.random()*7)*10+20;b = Math.floor(Math.random()*(c/10-1))*10+10;a = c-b;d = 90-b;break;case 1:b = Math.floor(Math.random()*7)*20+20;a = Math.floor(Math.random()*(140-b)/20)*20+20;c = (180-a-b)/2;d = (180-b-2*c)/2;break;case 2:c = Math.floor(Math.random()*7)*20+20;d = Math.floor(Math.random()*(140-c)/20)*20+20;b = (180-c-d)/2;a = (180-c-2*b)/2;break;case 3:b = Math.floor(Math.random()*7)*10+20;c = Math.floor(Math.random()*(b/10-1))*10+10;d = b-c;a = 90-c;break;}}var lt=String.fromCharCode(0x3c),gt=String.fromCharCode(0x3e);document.getElementById('check').innerHTML = lt+'inp'+'ut type=\'checkbox\' id=\'line\''+gt+'補助線';function sin(s) {return Math.sin(Math.PI*s/180.0);}function cos(c) {return Math.cos(Math.PI*c/180.0);}function tan(t) {return Math.tan(Math.PI*t/180.0);}function pyth(x,y) {return Math.sqrt(x*x+y*y);}function height(a,b) {return tan(a)*tan(b)/(tan(a)+tan(b));}function arc(x,y,r) {if ( document.getElementById('line').checked ) {ctx.beginPath();ctx.arc(x,y,r,0,2*Math.PI,false);ctx.closePath();ctx.lineWidth = 2.0;ctx.stroke();}}function line(x1,y1,x2,y2) {if ( document.getElementById('line').checked ) {ctx.beginPath();ctx.moveTo(x1,y1);ctx.lineTo(x2,y2);ctx.closePath();ctx.lineWidth = 2.0;ctx.stroke();}}function text(a1,b1,c1,d1) {var a2,b2,c2,d2;var ad=Math.atan2(ay-dy,ax-dx)*180/Math.PI;var ab=Math.atan2(ay-by,ax-bx)*180/Math.PI;var ba=Math.atan2(by-ay,bx-ax)*180/Math.PI;var bc=Math.atan2(by-cy,bx-cx)*180/Math.PI;var cb=Math.atan2(cy-by,cx-bx)*180/Math.PI;var cd=Math.atan2(cy-dy,cx-dx)*180/Math.PI;var dc=Math.atan2(dy-cy,dx-cx)*180/Math.PI;var da=Math.atan2(dy-ay,dx-ax)*180/Math.PI;if ( Math.max(ad,0)!=0 ) {a2 = ab+(ad-ab)/2;} else {a2 = ab+(ad-ab)/2+180;}b2 = bc-(ba+bc)/2;c2 = cd+(cb-cd)/2;d2 = -da-(dc-da)/2;if ( a1==360 ) a1=a2;if ( b1==360 ) b1=b2;if ( c1==360 ) c1=c2;if ( d1==360 ) d1=d2;if ( document.getElementById('line').checked ) {ctx.fillText('A',ax-12*cos(a1),ay-12*sin(a1));ctx.fillText('B',bx-12*cos(b1),by+12*sin(b1));ctx.fillText('C',cx+12*cos(c1),cy+12*sin(c1));ctx.fillText('D',dx+12*cos(d1),dy-12*sin(d1));} else {ctx.fillText('A',ax-12*cos(a2),ay-12*sin(a2));ctx.fillText('B',bx-12*cos(b2),by+12*sin(b2));ctx.fillText('C',cx+12*cos(c2),cy+12*sin(c2));ctx.fillText('D',dx+12*cos(d2),dy-12*sin(d2));}}var cvs = document.getElementById('cvs');var ctx = cvs.getContext('2d');var e = Math.tan(c/180.0*Math.PI)/(Math.tan((a+b)/180.0*Math.PI)+Math.tan(c/180.0*Math.PI));var f = Math.tan(b/180.0*Math.PI)/(Math.tan((d+c)/180.0*Math.PI)+Math.tan(b/180.0*Math.PI));var g = e*Math.tan((a+b)/180.0*Math.PI);var h = f*Math.tan((d+c)/180.0*Math.PI);var x;var t=1;var ax=0,ay=0,bx=0,by=0,cx=0,cy=0,dx=0,dy=0;function draw1() {ctx.beginPath();ctx.clearRect(0,0,500,500);ctx.closePath();if ( Math.min(a+b+c,180)==180 || Math.min(b+c+d,180)==180 ){cmt = '図形を描けません';cmt += 'α=∠ABD='+a+'˚
β=∠DBC='+b+'˚
γ=∠ACB='+c+'˚
δ=∠DCA='+d+'˚
θ=∠ADBを求めよ。
';} else {w = 1;if ( Math.max(e,0)==0 ){if ( Math.max(f,1-e)==f ) w = f;else w += -e;}if ( Math.max(f,0)==0 ){if ( Math.max(e,1-f)==e ) w = e;else w += -f;}var z = 300/Math.max(Math.max(h,g),w);if ( w==1 ){bx = 250-(z*w/2);cx = 250+(z*w/2);} else if ( w==e || w==1-f ){bx = 250-(z*w/2);cx = bx+z;} else if ( w==f || w==1-e ){cx = 250+(z*w/2);bx = cx-z;} else if ( w==1-e-f ){bx = 250-(z*w/2)-z*e;cx = 250+(z*w/2)+z*f;}dx = cx - z*f;ax = bx + z*e;ay = 500-((500-z*Math.max(h,g))/2)-z*g;by = 500-((500-z*Math.max(h,g))/2);cy = 500-((500-z*Math.max(h,g))/2);dy = 500-((500-z*Math.max(h,g))/2)-z*h;var col;eval('col = document.defaultView.getComputedS'+'tyle(document.getElementById(\'inner\'),\'\').color;');eval('ctx.strokeS'+'tyle = col;');eval('ctx.fillS'+'tyle = col');var fs,ff;eval('fs = document.defaultView.getComputedS'+'tyle(document.getElementById(\'inner\'),\'\').fontSize;');eval('ff = document.defaultView.getComputedS'+'tyle(document.getElementById(\'inner\'),\'\').fontFamily;');ctx.font = fs+' '+ff;ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.lineJoin = 'bevel';cmt = 'α=∠ABD='+a+'˚
β=∠DBC='+b+'˚
γ=∠ACB='+c+'˚
δ=∠DCA='+d+'˚
θ=∠ADBを求めよ。
';ctx.beginPath();ctx.moveTo(bx,by);ctx.lineTo(cx,cy);ctx.lineTo(dx,dy);ctx.lineTo(ax,ay);ctx.closePath();ctx.lineWidth = 2.0;ctx.stroke();ctx.beginPath();ctx.lineJoin = 'bevel';ctx.moveTo(bx,by);ctx.lineTo(dx,dy);ctx.lineWidth = 2.0;ctx.stroke();ctx.beginPath();ctx.lineJoin = 'bevel';ctx.moveTo(cx,cy);ctx.lineTo(ax,ay);ctx.lineWidth = 2.0;ctx.stroke();draw2();document.getElementById('inner').innerHTML = cmt;}}function draw2() {if ( (c==d)*(2*a+b==180) ) {cmt += 'βの二等分線と、線分ACとの交点をIとすると、点Iは△DBCの内心となる。
';cmt += '□ABIDは、∠BAI=∠BDIより、円に内接する。
';cmt += '∴θ=β/2+γ='+(b/2+c)+'˚';var iy=(cx-bx)*height(b/2,c);var ix=iy/tan(b/2);line(bx,by,bx+ix,by-iy);line(dx,dy,bx+ix,by-iy);arc(bx+ix,by-iy,iy);text(360,360,360,360);} else if ( (2*a==d)*(2*c+d==180) ) {cmt += '線分DB上の点Iを、□ABCIが円に内接するように取る。
';cmt += 'α+β=∠IAC+∠ICA、α+β+∠BDC=90˚より、点Iは△ACDの内心。
';cmt += '∴θ=90˚-α-β='+(90-a-b)+'˚';var iy=(cx-bx)*height(b,c+d/2);var ix=iy/tan(b);var ir=pyth(cx-dx,cy-dy)*height(d/2,180-b-c-d);line(ax,ay,bx+ix,by-iy);line(cx,cy,bx+ix,by-iy);arc(bx+ix,by-iy,ir);text(360,360,360,360);} else if ( (2*d==a)*(2*b+a==180) ) {cmt += '線分AC上の点Iを、□IBCDが円に内接するように取る。
';cmt += 'γ+δ=∠IBD+∠IDB、β+γ+∠BAC=90˚より、点Iは△ABDの内心。
';cmt += '∴θ=2(180˚-α/2-β-(180˚-β-γ-δ))=2γ+2δ-α='+(2*c+2*d-a)+'˚';var iy=(cx-bx)*height(a/2+b,c);var ix=iy/tan(c);var ir=pyth(ax-bx,ay-by)*height(a/2,180-a-b-c);line(bx,by,cx-ix,cy-iy);line(dx,dy,cx-ix,cy-iy);arc(cx-ix,cy-iy,ir);text(360,360,360,360);} else if ( (a==b)*(2*d+c==180) ) {cmt += 'γの二等分線と、線分DBとの交点をIとすると、点Iは△ABCの内心となる。
';cmt += '□AICDは、∠IAC=∠IDCより、円に内接する。
';cmt += '∴θ=γ/2='+(c/2)+'˚';var iy=(cx-bx)*height(b,c/2);var ix=iy/tan(c/2);line(cx,cy,cx-ix,cy-iy);line(ax,ay,cx-ix,cy-iy);arc(cx-ix,cy-iy,iy);text(360,360,360,360);} else {text(360,360,360,360);}}onload=function() { draw1(); };onchange=function() { draw1(); };})();
正しいパラメータを渡すとここに解説が表示されます。