[从头学数学] 第05节 认识图形(一)

来源:互联网 发布:软件开发人员招聘 编辑:程序博客网 时间:2024/04/27 21:24
剧情提要:
[机器小伟]在[工程师阿伟]的陪同下进行着修炼,
本节的主题是[认识图形(一)]。

正剧开始:

星历2015年12月18日 11:10:55, 银河系厄尔斯星球中华帝国江南行省。

[工程师阿伟]正在观看[机器小伟]认识图形。

11:11:40, 小伟看来看去,也只发现了正方体,长方体,圆柱体和球体这四
种图形,好单调啊。


星历2015年12月18日 11:12:52, [机器小伟]说:[阿伟大人]
,这也没什么好玩的啊,说是搭积木,也没什么可搭的,材料太少了,颜色也很单调,
不好玩。


11:13:47, 阿伟给了小伟一个绘图模块,又给了他这些小积木的数据。


<span style="font-size:18px;">//绘制路径function drawPath2(arr, x, y, r, str) {plot.fillText(str, 30, 20, 200);plot.save().setLineWidth(2);var pathArr = new Array();pathArr = arr;x = x ? x : 0;y = y ? y: 0;r = r ? r : 100;//缩放比例,因为路径map是规整在直径100的外接圆里的var scale = Math.round(r / 100);for (var i=0; i < pathArr.length-1; i++) {plot.moveTo(-(pathArr[i][0] * scale+x), (pathArr[i][1]*scale+y)).lineTo(-(pathArr[i][2] * scale+x), (pathArr[i][3]*scale+y));}plot.stroke();plot.restore();}</span>

<span style="font-size:18px;">//3D形状绘制试验function Shape3D() {this.cubic = [[-48,-22,-48,46], [-46,-24,-46,50], [-44,-24,-22,-46], [-44,-20,-18,-46], [-44,-20,-44,50], [-42,-25,-22,-46], [-42,-22,-18,-46], [-42,-22,25,-22], [-42,-22,-42,46], [-42,50,22,50], [-41,-24,-18,-46], [-41,-18,25,-18], [-41,46,25,46], [-39,-25,-18,-46], [-27,-42,35,-42], [-20,-46,44,-46], [18,-20,44,-46], [20,-24,20,50], [22,-24,44,-46], [22,-24,22,50], [24,-25,44,-46], [24,-25,24,42], [24,48,48,24], [25,-16,25,46], [27,-24,48,-44], [27,37,48,16], [27,42,48,22], [27,44,48,24], [42,-39,42,24], [46,-44,46,-22], [46,-18,46,25], [48,-42,48,24]];//<路径数组共有线段32(条)>this.brick = [[-50,-5,-34,-21], [-50,-5,37,-5], [-50,-5,-50,24], [-49,-7,-49,24], [-48,-7,-34,-21], [-48,-3,34,-3], [-48,-3,-48,21], [-48,24,35,24], [-47,-9,-47,22], [-46,-9,-34,-21], [-46,22,37,22], [-45,-4,39,-4], [-37,-23,50,-23], [-35,-24,48,-24], [-35,-21,48,-21], [24,-20,37,-20], [32,23,50,5], [34,-2,34,24], [35,-7,47,-19], [35,20,50,5], [36,-8,36,19], [37,-10,50,-23], [37,18,50,5], [38,-11,50,-23], [38,-8,50,-20], [38,14,50,3], [38,16,50,5], [48,-19,48,8], [50,-21,50,5]];//<路径数组共有线段29(条)>this.pollar = [[-21,-33,-13,-40], [-21,-33,-13,-33], [-21,-33,-16,-28], [-21,-33,-21,37], [-19,-44,-11,-44], [-19,-44,-19,-28], [-19,36,-5,50], [-19,36,-19,42], [-17,-45,-6,-45], [-17,-45,-13,-40], [-17,-45,-17,34], [-17,39,-6,50], [-17,39,-17,44], [-16,-47,16,-47], [-16,-47,-10,-40], [-16,-47,-16,-28], [-16,42,-8,50], [-16,44,-8,44], [-16,45,-5,45], [-14,-34,-5,-25], [-14,-34,-14,-28], [-14,47,13,47], [-13,-31,-6,-25], [-13,-31,-13,-26], [-11,-48,11,-48], [-11,-48,-11,-44], [-11,-28,21,-28], [-11,-26,21,-26], [-10,-50,10,-50], [-10,-50,-10,-45], [-10,-34,0,-25], [-10,-34,-10,-26], [-8,-34,-8,-25], [-8,50,6,50], [-6,-29,21,-29], [-6,-29,-2,-25], [-6,-29,-6,-25], [-5,-25,0,-29], [-5,-25,8,-25], [-5,48,8,48], [2,45,14,45], [2,45,6,50], [2,45,2,50], [3,37,13,47], [5,-39,10,-39], [6,-45,17,-45], [6,-45,11,-40], [6,-33,14,-25], [6,-33,6,-21], [6,42,17,42], [6,42,11,47], [6,42,6,50], [8,40,13,45], [8,40,8,48], [10,-44,17,-44], [10,-44,21,-33], [10,-31,19,-40], [10,-31,21,-31], [10,-31,10,-26], [11,-40,16,-45], [11,-40,19,-40], [11,-33,19,-40], [11,-33,21,-33], [11,-33,21,-23], [11,-33,11,-28], [13,-42,19,-42], [13,-42,21,-34], [13,-25,21,-33], [13,-25,21,-25], [13,36,19,36], [13,36,17,40], [13,36,13,47], [14,-36,19,-40], [14,-36,21,-36], [14,-36,21,-29], [14,-36,14,-25], [14,39,21,33], [14,39,19,39], [14,39,14,45], [16,-20,21,-20], [16,-20,21,-15], [16,-17,21,-21], [16,-17,21,-17], [16,-17,21,-12], [16,28,21,23], [16,29,21,34], [16,37,21,33], [16,37,16,44], [17,-34,17,26], [17,33,17,42], [19,-39,19,-26], [19,34,19,40], [21,-34,21,34]];//<路径数组共有线段93(条)this.sphere = [[-50,-8,-43,-15], [-50,-8,-43,-8], [-50,-8,-50,8], [-48,-14,-39,-23], [-48,-14,-43,-14], [-48,-14,-43,-8], [-48,-14,-48,-3], [-48,3,-43,3], [-48,3,-43,8], [-48,3,-48,14], [-46,-21,-21,-46], [-46,-21,-39,-21], [-46,-21,-46,-10], [-46,8,-46,19], [-46,26,-39,19], [-46,26,-37,26], [-45,-25,-37,-32], [-45,-25,-35,-25], [-45,-25,-45,-6], [-45,5,-45,25], [-43,-28,-26,-45], [-43,-28,-30,-28], [-43,-28,-43,-6], [-43,5,-43,26], [-41,-30,-26,-45], [-41,-30,-28,-30], [-41,-30,-35,-25], [-41,-30,-41,-19], [-41,15,-41,30], [-39,-34,-32,-34], [-39,-34,-34,-28], [-39,-34,-39,-21], [-39,17,-39,30], [-37,19,-37,32], [-35,-37,-23,-37], [-35,-37,-28,-30], [-35,-37,-35,-25], [-35,28,-30,28], [-35,28,-17,46], [-35,28,-35,34], [-34,-32,-19,-46], [-34,-32,-25,-32], [-34,-32,-34,-26], [-34,32,-19,46], [-34,34,-25,34], [-34,34,-21,46], [-34,35,-28,30], [-34,35,-25,35], [-34,35,-25,45], [-32,-39,-26,-45], [-32,-39,-17,-39], [-32,-39,-25,-32], [-32,-39,-32,-30], [-32,30,-14,48], [-32,30,-32,39], [-30,-41,-21,-41], [-30,-41,-25,-35], [-30,-41,-30,-28], [-30,41,-25,35], [-30,41,-17,41], [-26,-43,-10,-43], [-26,-43,-26,-34], [-25,45,-19,39], [-25,45,21,45], [-23,-45,-17,-39], [-23,-45,-23,-37], [-23,37,-12,48], [-23,37,-23,45], [-21,46,19,46], [-17,-46,21,-46], [-17,-46,-17,-39], [-17,39,-6,50], [-17,39,-17,46], [-15,-41,-6,-50], [-15,43,-8,43], [-15,43,-8,50], [-14,-50,12,-50], [-14,-50,-8,-45], [-14,-50,-14,-45], [-14,48,-8,43], [-14,48,12,48], [-12,-45,-6,-50], [-12,-45,26,-45], [-10,-48,15,-48], [-10,-48,-10,-43], [-8,50,-3,45], [-8,50,8,50], [-3,-43,5,-50], [-3,-43,26,-43], [6,41,12,46], [6,41,6,50], [8,-41,15,-48], [10,43,25,43], [10,43,10,48], [15,-41,21,-46], [15,-41,25,-32], [15,-39,21,-45], [15,-39,35,-39], [17,41,28,30], [17,41,28,41], [17,41,17,48], [19,-35,26,-43], [19,-35,35,-35], [19,39,28,30], [19,39,30,39], [19,39,19,46], [21,-41,30,-41], [21,-41,48,-14], [21,-37,26,-43], [21,-37,35,-37], [21,-32,30,-41], [21,34,35,34], [21,34,28,41], [21,34,21,45], [23,37,32,37], [23,37,23,43], [25,-34,30,-39], [25,-34,37,-34], [25,-32,32,-39], [26,25,43,25], [26,35,48,14], [26,35,34,35], [26,35,26,41], [30,-30,35,-35], [30,-30,41,-30], [30,-28,35,-34], [30,-28,43,-28], [30,23,37,30], [30,30,48,12], [30,30,39,30], [30,30,30,39], [32,-32,39,-32], [32,-32,48,-15], [32,28,48,12], [32,28,39,28], [32,28,32,37], [34,-26,39,-32], [34,-26,43,-26], [34,21,48,6], [34,21,45,21], [34,21,39,26], [34,32,46,19], [35,17,46,17], [35,17,43,25], [35,17,35,34], [37,26,46,17], [37,26,37,32], [39,-21,46,-21], [39,-21,48,-12], [39,-5,48,-14], [39,-5,50,-5], [39,-5,48,5], [39,-3,48,-12], [39,-3,50,-3], [39,15,48,6], [39,15,46,15], [39,15,45,21], [39,15,39,30], [41,-25,46,-25], [41,-25,46,-19], [41,-25,41,-12], [41,-6,48,-14], [41,-6,50,-6], [41,-6,50,3], [41,5,50,-5], [41,5,48,5], [41,5,48,12], [41,6,50,-3], [41,6,48,6], [41,6,48,14], [41,8,50,-1], [41,8,48,8], [41,8,46,14], [41,14,48,6], [41,14,48,14], [41,14,46,19], [41,14,41,26], [43,-15,48,-15], [43,-15,50,-8], [43,-14,48,-14], [43,-14,50,-6], [43,12,48,6], [43,12,48,12], [43,12,43,25], [45,-23,45,23], [46,-23,46,-10], [48,-1,48,14], [50,-8,50,3]];//<路径数组共有线段188(条)>}</span>


星历2015年12月18日 11:14:19, [机器小伟]说:[阿伟大人]
,既然有了数据,我还是来搭一下试试吧。


11:14:49, 于是得到了这样的一些结果。


星历2015年12月18日 11:19:40, [机器小伟]说:[阿伟大人],我是这样搭的。

<span style="font-size:18px;">function picData() {plot.init();setPreference();setSector(1,1,1,1);plot.scale(0.8, 0.8);var _3d = new Shape3D();plot.translate(0, 180);drawPath2(_3d.pollar_2, 0, 0, 100);plot.translate(0, -60);drawPath2(_3d.brick_1, 0, 0, 100);plot.translate(0, -60);drawPath2(_3d.cubic, 0, 0, 50);for (var i = 0; i < 3; i++) {plot.translate(0, -40);drawPath2(_3d.brick_2, 0, 0, 60);}for (var i = 0; i < 3; i++) {plot.translate(0, -35);drawPath2(_3d.brick_3, 0, 0, 30);}plot.translate(0, -40);drawPath2(_3d.sphere, 0, 0, 40);}</span>

11:21:05, 小伟看到了一个连一连,就玩了一把



11:21:42, 小伟又搭了一回积木。



次是这样搭的:

<span style="font-size:18px;">function picData() {plot.init();setPreference();setSector(1,1,1,1);plot.translate(150,100).scale(1.5, 1.5);var _3d = new Shape3D();//左上角开始画,两个球,一个正方体,一个长方体plot.save();plot.translate(-200, -150);drawPath2(_3d.sphere, 0,0, 30);plot.translate(20,20);drawPath2(_3d.sphere, 0,0, 30);plot.translate(150,-20);drawPath2(_3d.cubic, 100, 0, 60);plot.restore();plot.save().translate(-150, -120).scale(1, 0.4);drawPath2(_3d.brick, 0, 0, 180);plot.restore();//两个圆柱plot.save().translate(-150, -80).scale(1.5, 1);drawPath2(_3d.pollar, 0,0, 60);plot.restore();plot.save().translate(0, -80).scale(1.5, 1);drawPath2(_3d.pollar, 0,0, 60);plot.restore();//三块板plot.save().translate(-100, -50).scale(1, 0.2);drawPath2(_3d.brick, 0, 0, 300);plot.restore();plot.save().translate(-140, -20).scale(1, 0.6);drawPath2(_3d.brick, 0, 0, 100);plot.restore();plot.save().translate(-180, 0).scale(1, 0.6);drawPath2(_3d.brick, 0, 0, 100);plot.restore();//右下角两个圆柱plot.save().translate(-20, -15);drawPath2(_3d.pollar, 0,0, 60);plot.translate(20, 5);drawPath2(_3d.pollar, 0,0, 60);plot.restore();}</span>

星历2015年12月18日 11:23:16, [机器小伟]说:[阿伟大人],好没劲,不好玩,

我去看会电视了。


本节到此结束,欲知后事如何,请看下回分解。


0 0