正剧开始:
星历2016年03月19日 14:40:16, 银河系厄尔斯星球中华帝国江南行省。
[工程师阿伟]正在和[机器小伟]一起研究[勾股定理 小结与复习题]。
<span style="font-size:18px;"> var triangle = new Triangle(); var a = triangle.know2edges([200, 300]); var tmp = [].concat(a); config.setSector(2,3,1,1); shape.angleDraw(tmp, 'red', 0.5); a = triangle.know2edges([Math.sqrt(7*7-2*2), 2]); tmp = [].concat(a); config.setSector(2,3,1,2); shape.angleDraw(tmp, 'green', 20); a = triangle.know2edges([Math.sqrt(234*234-77*77), 77]); tmp = [].concat(a); config.setSector(2,3,2,1); shape.angleDraw(tmp, 'orange', 1); a = triangle.know2edges([3, 1.5]); tmp = [].concat(a); config.setSector(2,3,2,2); shape.angleDraw(tmp, 'cyan', 50); </span>
<span style="font-size:18px;">function myDraw(xGlobal, yGlobal) { var config = new PlotConfiguration(); config.init(); config.setPreference(); var r = 50; config.setSector(1,1,1,1); config.graphPaper2D(0, 0, r/2); config.axis2D(0, 0,180); var triangle = new Triangle(); var a = triangle.know2edges([200, 300]); var tmp = [].concat(a); config.setSector(2,3,1,1); shape.angleDraw(tmp, 'red', 0.5); a = triangle.know2edges([7, 2], -90); tmp = [].concat(a); config.setSector(2,3,1,2); shape.angleDraw(tmp, 'green', 20); a = triangle.know2edges([234, 77], -90); tmp = [].concat(a); config.setSector(2,3,2,1); shape.angleDraw(tmp, 'orange', 1); a = triangle.know2edges([3, 1.5]); tmp = [].concat(a); config.setSector(2,3,2,2); shape.angleDraw(tmp, 'cyan', 50); /* array = triangle.know3edges([13, 14, 15]); config.setSector(2,3,1,2); tmp = [].concat(array); shape.angleDraw(tmp, 'green', 10); */ /* var mathText = new MathText(); var s = [ 'AE = DB', 'AD^[2]+DB^[2] = AB^[2]', 'AB^[2] = AC^[2]+BC^[2] = 2*AC^[2]' ]; var x =40, y=40; var r1 = 40; var len = s.length; for (var i = 0; i < len; i++) { if (s[i] == '') { if (x < 100) { x += 300; y-=r1*3; } else { x = 20; y += r1; } } else { mathText.print(s[i], x, y); y+=r1; } } */ } </span>
进化后的根据两边求三角形元素值:
<span style="font-size:18px;"> //已知2条边和夹角 this.know2edges = function(edges, angle) { this.edges = []; this.angles = []; //如果没有指定两边的夹角,默认为90度 angle = angle ? angle : 90; var edgeC = 0; if (angle == -90) { //设定当输入角度为-90时指已知斜边和一条直角边的直角三角形 var swap; if (edges[0] < edges[1]) { swap = edges[0]; edges[0] = edges[1]; edges[1] = swap; } edgeC = Math.sqrt(edges[0]*edges[0]-edges[1]*edges[1]); angle = Math.asin(edgeC/edges[0]); } else { angle = angle ? angle/180*Math.PI : Math.PI/2; edgeC = Math.sqrt(edges[0]*edges[0]+edges[1]*edges[1]-2*edges[0]*edges[1]*Math.cos(angle)); } this.edges = [edges[0], edges[1], edgeC]; var edgeA = this.edges[0], edgeB = this.edges[1]; //角度为弧度单位 //a边对应角 this.angles.push(Math.acos((edgeB*edgeB + edgeC*edgeC-edgeA*edgeA)/(2*edgeB*edgeC))); //b边对应角 this.angles.push(Math.acos((edgeA*edgeA + edgeC*edgeC-edgeB*edgeB)/(2*edgeA*edgeC))); //c边对应角 this.angles.push(angle); var x0 = 0, y0 = 0; var x1 = x0 + this.edges[0], y1 = y0; var x2 = x0 + this.edges[1] * Math.cos(-this.angles[2]), y2 = y0 + this.edges[1] * Math.sin(-this.angles[2]); var retArray = new Array(); retArray.push([x0, y0]); retArray.push([x1, y1]); retArray.push([x2, y2]); return retArray; }</span>
<span style="font-size:18px;"> //题5 a = triangle.know3edges([1, 1.732, 2]); tmp = [].concat(a); config.setSector(2,3,1,1); shape.angleDraw(tmp, 'red', 100); //题7 a = triangle.know2edges([2*1.732+1, 2*1.732-1]); tmp = [].concat(a); config.setSector(2,3,1,2); shape.angleDraw(tmp, 'green', 50); </span>
<span style="font-size:18px;"> //题9 a = [[2,0], [0,4], [4,1], [5,5]] tmp = [].concat(a); config.setSector(2,3,2,1); shape.angleDraw(tmp, 'red', 30); //题10 a = triangle.know3edges([4.55, 5.45, 3]); tmp = [].concat(a); config.setSector(2,3,1,2); shape.angleDraw(tmp, 'green', 50); </span>
本节到此结束,欲知后事如何,请看下回分解。