标签:
剧情提要:正剧开始:
星历2016年04月04日 09:54:11, 银河系厄尔斯星球中华帝国江南行省。
[工程师阿伟]正在和[机器小伟]一起研究[相似]。
来求一下长度吧:
<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>
本节到此结束,欲知后事如何,请看下回分解。
标签:
原文地址:http://blog.csdn.net/mwsister/article/details/51055337