### [從頭學數學] 第160節 相似

[機器小偉]在[工程師阿偉]的陪同下進入了築基后期的修煉，

[工程師阿偉]正在和[機器小偉]一起研究[相似]。

`<span style="font-size:18px;">//例//相似前if (1) {var r = 20;            config.setSector(1,1,1,1);              config.graphPaper2D(0, 0, r);            config.axis2D(0, 0,180, 1.5);              var triangle = new Triangle();var transform = new Transform();var array_1 = triangle.know2edges([18, 21], 118);array_1 = transform.translate(transform.rotate(array_1, 16/180*Math.PI), -10, 10);shape.angleDraw([].concat(array_1), 'red', 10, 'DAB');var array_2 = triangle.know2angles([83, 360-118-78-83-33.65], 33.47);array_2 = transform.translate(transform.rotate(array_2, 49.65/180*Math.PI), -10, -10);        shape.angleDraw([].concat(array_2), 'orange', 10, 'DBC');}//相似后if (1) {var r = 20;            config.setSector(1,1,1,1);              config.graphPaper2D(0, 0, r);            config.axis2D(0, 0,180, 1.5);              var triangle = new Triangle();var transform = new Transform();var array_1 = triangle.know2edges([18, 21], 118);array_1 = transform.translate(transform.rotate(array_1, 16/180*Math.PI), -10, 10);array_1 = transform.scale(array_1, 24/18);shape.angleDraw([].concat(array_1), 'red', 8, 'DAB');var array_2 = triangle.know2angles([83, 360-118-78-83-33.65], 33.47);array_2 = transform.translate(transform.rotate(array_2, 49.65/180*Math.PI), -10, -10);array_2 = transform.scale(array_2, 24/18);        shape.angleDraw([].concat(array_2), 'orange', 8, 'DBC');}</span>`

`<span style="font-size:18px;">var array_1 = triangle.know2edges([21, 18], 118);array_1 = transform.translate(transform.rotate(array_1, (49.65-28.35)/180*Math.PI), -10, 10);</span>`

`<span style="font-size:18px;">//謝氏三角形if (1) {var r = 20;            config.setSector(1,1,1,1);              config.graphPaper2D(0, 0, r);            config.axis2D(0, 0,180, 1.5);              var level = 5;var array = [[0, 0]];var r0 = 8*r;var len = 0;var tmp = [];var x = y = 0;var colorArray = ['red', 'orange', '#0088FF', 'green', 'cyan', 'blue', '#FF00FF','#888888', 'black'];for (var i = 0; i < level; i++) {len = array.length;for (var j = 0; j < len; j++) {tmp = array.shift();x = tmp[0];y = tmp[1];shape.strokeDraw(shape.nEdge(x, y, r0, 3), colorArray[level%8]);array.push([x, y-r0/2]);array.push([x-r0*0.5*0.866, y+r0*0.25]);array.push([x+r0*0.5*0.866, y+r0*0.25]);}r0/=2;}}</span>`

`<span style="font-size:18px;">//歪個頭看看if (1) {var r = 20;            config.setSector(1,1,1,1);              config.graphPaper2D(0, 0, r);            config.axis2D(0, 0,180, 1.5);              var level = 5;var array = [[0, 0]];var r0 = 8*r;var len = 0;var tmp = [], tmp2 = [];var x = y = 0;var transform = new Transform();var colorArray = ['red', 'orange', '#0088FF', 'green', 'cyan', 'blue', '#FF00FF','#888888', 'black'];for (var i = 0; i < level; i++) {len = array.length;r0/=2;for (var j = 0; j < len; j++) {tmp = array.shift();x = tmp[0];y = tmp[1];tmp2 = shape.nEdge(x, y, r0*2, 3, 0);tmp2 = transform.rotate(tmp2, Math.PI/4);shape.strokeDraw(tmp2, colorArray[level%8]);array.push([x, y-r0]);array.push([x-r0*Math.cos(Math.PI/6), y+r0*Math.sin(Math.PI/6)]);array.push([x+r0*Math.cos(Math.PI/6), y+r0*Math.sin(Math.PI/6)]);}}}</span>`

`<span style="font-size:18px;">if (1) {var r = 20;            config.setSector(1,1,1,1);              config.graphPaper2D(0, 0, r);            config.axis2D(0, 0,180, 1.5);              var level = 10;var array = [[0, 0]];var r0 = 8*r;var len = 0;var tmp = [], tmp2 = [];var x = y = 0;var transform = new Transform();var colorArray = ['red', 'orange', '#0088FF', 'green', 'cyan', 'blue', '#FF00FF','#888888', 'black'];for (var i = 0; i < level; i++) {len = array.length;r0/=2;for (var j = 0; j < len; j++) {tmp = array.shift();x = tmp[0];y = tmp[1];tmp2 = shape.nEdge(x, y, r0*2, 3, 0);tmp2 = transform.rotate(tmp2, Math.PI/3);shape.strokeDraw(tmp2, colorArray[level%8]);array.push([x, y-r0]);array.push([x-r0*Math.cos(Math.PI/6), y+r0*Math.sin(Math.PI/6)]);array.push([x+r0*Math.cos(Math.PI/6), y+r0*Math.sin(Math.PI/6)]);}}}</span>`

`<span style="font-size:18px;">//探索位似性質if (1) {var r = 20;            config.setSector(1,1,1,1);        config.graphPaper2D(0, 0, r);    config.setSector(5,3,4,1);          config.axis2D(0, 0,260, 1.5);              var colorArray = ['red', 'orange', '#0088FF', 'green', 'cyan', 'blue', '#FF00FF','#888888', 'black'];var triangle = new Triangle();var transform = new Transform();var array_1 = triangle.know3edges([10, 8, 5]);array_1 = transform.translate(array_1, 5, 10);shape.strokeDraw([].concat(array_1), colorArray[0], 10);shape.pointDraw([].concat(array_1), colorArray[0], 10, 'ABC');var array_2 = transform.scale(array_1, 2);shape.strokeDraw([].concat(array_2), colorArray[1], 10);shape.pointDraw([].concat(array_2), colorArray[1], 10, ['A\'', 'B\'', 'C\'']);var x = y = 0;for (var i = 0; i < array_2.length; i++) {x = array_2[i][0];y = array_2[i][1];shape.multiLineDraw([[0, 0],[x, y]], colorArray[2], 10);}}</span>`