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


劇情提要:
[機器小偉]在[工程師阿偉]的陪同下進入了築基后期的修煉,
這次要修煉的目標是[相似]。

正劇開始:

星歷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>


本節到此結束,欲知后事如何,請看下回分解。



注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2020 ITdaan.com