(function(){var a,b,c,d,cmt='テスト';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'];} else {switch ( Math.floor(Math.random()*4) ) {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()*6)*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()*6)*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 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 cvs = document.getElementById('cvs');var ctx = cvs.getContext('2d');ctx.beginPath();ctx.clearRect(0,0,400,400);ctx.closePath();if ( Math.min(a+b+c,180)==180 || Math.min(b+c+d,180)==180 ){cmt = '図形を描けません';} 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);var px, qx, rx, sx;if ( w==1 ){px = 200-(z*w/2);qx = 200+(z*w/2);} else if ( w==e || w==1-f ){px = 200-(z*w/2);qx = px+z;} else if ( w==f || w==1-e ){qx = 200+(z*w/2);px = qx-z;} else if ( w==1-e-f ){px = 200-(z*w/2)-z*e;qx = 200+(z*w/2)+z*f;}rx = qx - z*f;sx = px + z*e;var py = 400-((400-z*Math.max(h,g))/2);var qy = 400-((400-z*Math.max(h,g))/2);var ry = 400-((400-z*Math.max(h,g))/2)-z*h;var sy = 400-((400-z*Math.max(h,g))/2)-z*g;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';cmt = 'α=∠ABD='+a+'˚
β=∠DBC='+b+'˚
γ=∠ACB='+c+'˚
δ=∠DCA='+d+'˚
θ=∠ADBを求めよ。
';if ( (a+b==c)*((180-a-b-c)==2*(180-b-c-d)) ) {cmt += 'α+β=γより、△ABCはAを頂角とする二等辺三角形。
';cmt += '∠BAC='+(180-a-b-c)+'˚、∠BDC='+(180-b-c-d)+'˚、∠BAC=2×∠BDCより、点Aは△DBCの外心で、AB=AC=AD。
';cmt += '∴θ=δ-(180˚-β-γ-δ)=δ-(90˚-γ)=δ+γ-90˚='+(d+c-90)+'˚';var sr=Math.sqrt((sx-px)*(sx-px)+(sy-py)*(sy-py));ctx.beginPath();ctx.arc(sx,sy,sr,0,2*Math.PI,false);ctx.closePath();ctx.lineWidth = 2.0;ctx.stroke();ctx.fillText('A',sx-12,sy-12);ctx.fillText('B',sx+(px-sx)*(sr+12)/sr,sy+(py-sy)*(sr+12)/sr);ctx.fillText('C',sx+(qx-sx)*(sr+12)/sr,sy+(qy-sy)*(sr+12)/sr);ctx.fillText('D',sx+(rx-sx)*(sr+12)/sr,sy+(ry-sy)*(sr+12)/sr);ctx.lineJoin = 'bevel';} else if ( (a+b+2*c==180)*(b+2*c+2*d==180) ) {cmt += 'α+δ+2γ=180より、△ABCはBを頂角とする二等辺三角形。
';cmt += 'δ+2γ+2δ=180より、△DBCはBを頂角とする二等辺三角形。
';cmt += 'BA=BD=BCより、点Bは△ACDの外心で、△ABDもBを頂角とする二等辺三角形。
';cmt += '∴θ=(180˚-α)/2='+((180-a)/2)+'˚';var pr=Math.sqrt((px-sx)*(px-sx)+(py-sy)*(py-sy));ctx.beginPath();ctx.arc(px,py,pr,0,2*Math.PI,false);ctx.closePath();ctx.lineWidth = 2.0;ctx.stroke();ctx.fillText('A',px+(sx-px)*(pr+12)/pr,py+(sy-py)*(pr+12)/pr);ctx.fillText('B',px-12,py+12);ctx.fillText('C',px+(qx-px)*(pr+12)/pr,py+(qy-py)*(pr+12)/pr);ctx.fillText('D',px+(rx-px)*(pr+12)/pr,py+(ry-py)*(pr+12)/pr);ctx.lineJoin = 'bevel';} else if ( (2*a+2*b+c==180)*(2*b+c+d==180) ) {cmt += '2α+2δ+γ=180より、△ABCはCを頂角とする二等辺三角形。
';cmt += '2β+γ+δ=180より、△DBCはCを頂角とする二等辺三角形。
';cmt += 'CB=CA=CDより、点Cは△ABDの外心で、△ACDもCを頂角とする二等辺三角形。
';cmt += '∴θ=(180˚-δ)/2-β='+((180-d)/2-b)+'˚';var qr=Math.sqrt((qx-sx)*(qx-sx)+(qy-sy)*(qy-sy));ctx.beginPath();ctx.arc(qx,qy,qr,0,2*Math.PI,false);ctx.closePath();ctx.lineWidth = 2.0;ctx.stroke();ctx.fillText('A',qx+(sx-qx)*(qr+12)/qr,qy+(sy-qy)*(qr+12)/qr);ctx.fillText('B',qx+(px-qx)*(qr+12)/qr,qy+(py-qy)*(qr+12)/qr);ctx.fillText('C',qx+12,qy+12);ctx.fillText('D',qx+(rx-qx)*(qr+12)/qr,qy+(ry-qy)*(qr+12)/qr);ctx.lineJoin = 'bevel';} else if ( (c+d==b)*((180-b-c-d)==2*(180-a-b-c)) ) {cmt += 'γ+δ=βより、△DBCはDを頂角とする二等辺三角形。
';cmt += '∠BAC='+(180-a-b-c)+'˚、∠BDC='+(180-b-c-d)+'˚、2×∠BAC=∠BDCより、点Dは△ABCの外心でDA=DB=DC。
';cmt += '∴θ=180˚-2α='+(180-2*a)+'˚';var rr=Math.sqrt((rx-px)*(rx-px)+(ry-py)*(ry-py));ctx.beginPath();ctx.arc(rx,ry,rr,0,2*Math.PI,false);ctx.closePath();ctx.lineWidth = 2.0;ctx.stroke();ctx.fillText('A',rx+(sx-rx)*(rr+12)/rr,ry+(sy-ry)*(rr+12)/rr);ctx.fillText('B',rx+(px-rx)*(rr+12)/rr,ry+(py-ry)*(rr+12)/rr);ctx.fillText('C',rx+(qx-rx)*(rr+12)/rr,ry+(qy-ry)*(rr+12)/rr);ctx.fillText('D',rx+12,ry-12);ctx.lineJoin = 'bevel';} else {ctx.fillText('A',sx-12,sy-12);ctx.fillText('B',px-12,py+12);ctx.fillText('C',qx+12,qy+12);ctx.fillText('D',rx+12,ry-12);ctx.lineJoin = 'miter';}ctx.beginPath();ctx.moveTo(px,py);ctx.lineTo(qx,qy);ctx.lineTo(rx,ry);ctx.lineTo(sx,sy);ctx.closePath();ctx.lineWidth = 2.0;ctx.stroke();ctx.beginPath();ctx.lineJoin = 'bevel';ctx.moveTo(px,py);ctx.lineTo(rx,ry);ctx.lineWidth = 2.0;ctx.stroke();ctx.beginPath();ctx.lineJoin = 'bevel';ctx.moveTo(qx,qy);ctx.lineTo(sx,sy);ctx.lineWidth = 2.0;ctx.stroke();}document.getElementById('inner').innerHTML = cmt;})();
正しいパラメータを渡すとここに解説が表示されます。