[从头学数学] 第104节 整理与复习--图形与几何
来源:互联网 发布:软件学校成功案例 编辑:程序博客网 时间:2024/05/16 04:58
剧情提要:
[机器小伟]在[工程师阿伟]的陪同下继续炼化着筑基丹,
这次要炼化的目标是[整理与复习--图形与几何]。
本节到此结束,欲知后事如何,请看下回分解。
[机器小伟]在[工程师阿伟]的陪同下继续炼化着筑基丹,
这次要炼化的目标是[整理与复习--图形与几何]。
正剧开始:
星历2016年02月23日 11:53:25, 银河系厄尔斯星球中华帝国江南行省。
[工程师阿伟]正在和[机器小伟]一起复习着[图形与几何]。
<span style="font-size:18px;">function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); config.setSector(1,1,1,1);config.axis3D(0, 0, 0, 180);var array = [];for (var z = 0; z < 2; z++) {for (var y = 0; y < 3; y++) {for (var x = 0; x < 2; x++) {if (z == 0 && y == 2) {}else {array.push([x, y, z]);}}}}shape.threeView(array);plot.fillText('共有'+array.length.toFixed(0)+'个', 50, 100, 100); }/*** @usage 把三维点阵列按照z, y, x优先级由小到大排列* @author mw* @date 2016年02月23日 星期二 09:38:27 * @param [[x1, y1, z1], [x2,y2, z2], ...]* @return 排序后的[[x, y, z]...]**/this.xyzSort = function(array) {var arr = new Array();arr = array;arr.sort(function(a, b) {if (a[2] != b[2]) {return a[2] - b[2];}else {if (a[1] != b[1]) {return (a[1] - b[1]);}else {return a[0] - b[0];}}});//document.write(arr);return arr;}/*** @usage 三视图* @author mw* @date 2016年02月23日 星期二 09:49:23 * @param* @return**/this.threeView = function(array) {var cubic = this.xyzSort(array);plot.save();plot.setTransform(1, 0, 0, 1, 0, 0) .translate(300, 200); //三维图和三视图 var r = 50; var style = 'red'; var len = cubic.length; for (var i = 0; i < len; i++) { this.drawCubic(cubic[i][0], cubic[i][1], cubic[i][2], r, style); } var height = 400; r = r/3; plot.setTransform(1, 0, 0, 1, 0, 0); plot.fillText('左视图', 20, 20, 100); plot.fillText('主视图', 20, 20+1*height/3, 100); plot.fillText('俯视图', 20, 20+2*height/3, 100); plot.setFillStyle(style) .setStrokeStyle('white'); //左视图 plot.translate(100, 80); for (var i = 0; i < len; i++) { //y, z两坐标,z坐标变为x坐标 this.fillRect(cubic[i][2]*r, -cubic[i][1]*r, r, r); this.strokeRect(cubic[i][2]*r, -cubic[i][1]*r, r, r); } //主视图 plot.translate(0, 130); for (var i = 0; i < len; i++) { //x, y两坐标 this.fillRect(cubic[i][0]*r, -cubic[i][1]*r, r, r); this.strokeRect(cubic[i][0]*r, -cubic[i][1]*r, r, r); } //俯视图 plot.translate(0, 100); for (var i = 0; i < len; i++) { //x, z两坐标,z坐标变为y坐标 this.fillRect(cubic[i][0]*r, cubic[i][2]*r, r, r); this.strokeRect(cubic[i][0]*r, cubic[i][2]*r, r, r); } plot.restore();}</span>
<span style="font-size:18px;">#15Scubic = lambda a : a*a;Vcubic = lambda a : a*a*a;Scylinder = lambda d, h : 3.1416/4*d*d*2+3.1416*d*h;Vcylinder = lambda d, h : 3.1416/4*d*d*h;>>> Scubic = lambda a : a*a*6;>>> Vcubic = lambda a : a*a*a;>>> Scylinder = lambda d, h : 3.1416/4*d*d*2+3.1416*d*h;>>> Vcylinder = lambda d, h : 3.1416/4*d*d*h;>>> S = Scubic(20)*5/6+Scylinder(20, 20)/2;>>> S2942.48>>> V = Vcubic(20)+Vcylinder(20, 20)/2;>>> V11141.6</span>
<span style="font-size:18px;">//16题function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); config.setSector(1,1,1,1);config.axis3D(0, 0, 0, 180);var array = [];for (var z = 0; z < 3; z++) {for (var y = 0; y < 1; y++) {for (var x = 0; x < 3; x++) {if (z == 0 && x == 2) {}else {array.push([x, y, z]);}}}}array.push([0, 1, 0]);array.push([0, 1, 1]);shape.threeView(array, 'green');plot.fillText('共有'+array.length.toFixed(0)+'个', 50, 100, 100); }</span>
<span style="font-size:18px;">[0, 0, 0]有3面涂色。[1, 0, 0]有4面涂色。[0, 0, 1]有2面涂色。[1, 0, 1]有2面涂色。[2, 0, 1]有4面涂色。[0, 0, 2]有4面涂色。[1, 0, 2]有3面涂色。[2, 0, 2]有4面涂色。[0, 1, 0]有4面涂色。[0, 1, 1]有4面涂色。总计两面涂色的有2个, 三面涂色的有2个,四面涂色的有6个。#16 正方体着色统计def tmp(): a = []; for z in range(3): for y in range(1): for x in range(3): if z == 0 and x == 2: pass; else: a.append([x, y, z]); a.append([0, 1, 0]); a.append([0, 1, 1]); #print(a); size = len(a); b = [6]*size; #print(b); for i in range(size): for j in range(i, size): xdiff = abs(a[i][0] - a[j][0]); ydiff = abs(a[i][1] - a[j][1]); zdiff = abs(a[i][2] - a[j][2]); #对于相邻的立方体只有一个坐标相差1,其余都相同。 if (xdiff + ydiff + zdiff == 1): b[i]-=1; b[j]-=1; #统计n面涂色的数量。 b2 = 0; b3 = 0; b4 = 0; for i in range(size): if (b[i] == 2): b2+=1; elif (b[i] == 3): b3+=1; elif (b[i] == 4): b4+=1; print('{0}有{1}面涂色。'.format(a[i], b[i])); print('总计两面涂色的有{0}个, 三面涂色的有{1}个,四面涂色的有{2}个。'.format(\ b2, b3, b4));</span>
<span style="font-size:18px;">//19题function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); config.setSector(1,1,1,1);config.axis3D(0, 0, 0, 180);var array = [];for (var z = 0; z < 2; z++) {for (var y = 0; y < 3; y++) {for (var x = 0; x < 2; x++) {if (x == 1 && y == 2) {}else if (x == 1 && y == 1 && z == 1) {}else {array.push([x, y, z]);}}}}shape.threeView(array, 'green');plot.fillText('共有'+array.length.toFixed(0)+'个', 50, 100, 100); }</span>
<span style="font-size:18px;">//题3(1)function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); config.setSector(1,1,1,1);config.axis2D(0, 0, 180);var r1 = 100, r2 = r1/2;var a = [[1,1], [1,-1], [-1,-1], [-1,1]];plot.setStrokeStyle('red');for (var i = 0; i < 4; i++) {shape.strokeCircle(a[i][0]*r2*0.707, a[i][1]*r2*0.707, r2);}shape.strokeCircle(0, 0, r1); }</span>
<span style="font-size:18px;">//题3(2)function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); config.setSector(1,1,1,1);config.axis2D(0, 0, 180);var r1 = 100;plot.setStrokeStyle('red');shape.strokeCircle(0, 0, r1);shape.strokeDraw(shape.nEdge(0, 0, r1, 6), 'red');shape.strokeDraw(shape.nEdge(0, 0, r1, 3, -Math.PI/2), 'red');var x1, y1, x2, y2, thita = 0;for (var i = 0; i < 3; i++) {x1 = r1*Math.cos(thita-Math.PI), y1 = r1*Math.sin(thita-Math.PI);x2 = r1*Math.cos(thita), y2 = r1*Math.sin(thita);plot.beginPath().moveTo(x1, y1).lineTo(x2, y2).closePath().stroke();thita += Math.PI*2/3;} }</span>
<span style="font-size:18px;">//题3(3)function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); config.setSector(1,1,1,1);config.axis2D(0, 0, 180);var r1 = 100, r2 = r1/2;plot.setStrokeStyle('red');shape.strokeCircle(0, 0, r1);var sAngle = Math.PI/2, eAngle = sAngle-Math.PI;plot.beginPath().arc(0, r2, r2, sAngle, eAngle, 1).moveTo(0,0).closePath().stroke();sAngle = -Math.PI/2, eAngle = sAngle+Math.PI;plot.beginPath().arc(0, -r2, r2, sAngle, eAngle, 1).moveTo(0,0).closePath().stroke();}</span>
<span style="font-size:18px;">>>> import math;>>> dis = lambda x1, y1, x2, y2 : math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));>>> dis(5,0,8,9)*50474.3416490252569>>> angle = lambda x1, y1, x2, y2 : math.atan((y1-y2)/(x1-x2))*180/3.1416;>>> 90-angle(5,0,8,9)18.435116172750895>>> dis(5,0,10,3);5.830951894845301>>> _*50291.54759474226506>>> angle(5,0,10,3);30.963684125510934>>> 90-_59.03631587448906</span>
本节到此结束,欲知后事如何,请看下回分解。
0 0
- [从头学数学] 第104节 整理与复习--图形与几何
- [从头学数学] 第106节 整理与复习--数学思考
- [从头学数学] 第103节 整理与复习--数与代数
- [从头学数学] 第105节 整理与复习--统计与概率
- [从头学数学] 第107节 整理与复习--综合与实践
- [从头学数学] 第13节 分类与整理
- [从头学数学] 第276节 [计算几何] 中心点与顶点的凹凸性
- [从头学数学] 第127节 数据的收集、整理与描述 小结与复习题
- [从头学数学] 第126节 数据的收集、整理与描述
- [从头学数学] 第72节 平均数与条形统计图
- [从头学数学] 第83节 因数与倍数
- [从头学数学] 第100节 圆柱与圆锥
- [从头学数学] 第109节 有理数 小结与复习题
- [从头学数学] 第113节 一元一次方程 小结与复习题
- [从头学数学] 第116节 相交线与平行线
- [从头学数学] 第119节 实数 小结与复习题
- [从头学数学] 第124节 不等式与不等式组
- [从头学数学] 第129节 三角形 小结与复习题
- init dealloc理解
- PyQt4入门教程(4)_布局管理
- Redis缓存Session
- Java笔记20:迭代器模式
- sparseArray 遍历
- [从头学数学] 第104节 整理与复习--图形与几何
- 返回单链表的倒数第n个节点
- intent
- .net 星期(星期几)的取得
- 转:java读文件时判断其编码格式(亲测可用)
- iOS 最新版 CocoaPods 的安装流程
- ASP.NET的三层架构(DAL,BLL,UI)
- 吉宁博士说:时间管理——找出浪费员工个人时间的罪魁祸首
- 第二份测试实习——三个月的总结