[從頭學數學] 第193節 推理與證明

來源:互聯網
上載者:User

標籤:

劇情提要:
[機器小偉]在[工程師阿偉]的陪同下進入了[九轉金丹]之第五轉的修鍊。
這次要研究的是[推理與證明]。

正劇開始:

星曆2016年04月24日 12:16:07, 銀河系厄爾斯星球中華帝國江南行省。
[工程師阿偉]正在和[機器小偉]一起研究[推理與證明]。






<span style="font-size:18px;">>>> 23.5 13.865424623862042#海倫-秦九韶公式  def HQFormula(a, b, c):      p = (a+b+c)/2;      S = math.sqrt(p*(p-a)*(p-b)*(p-c));        return S;#例3def tmp():    #a, b, c = 3, 4, 5    a, b, c = 3, 4, 5    S1= a*b/2    S2 = a*c/2    S3 = b*c/2    S4 = HQFormula((a*a+b*b)**0.5, (a*a+c*c)**0.5, (b*b+c*c)**0.5);    print(S1+S2+S3, S4);</span>




<span style="font-size:18px;">if (1) {var array = new Array();array[0] = [1];array[1] = [1,1];for (var i = 2; i < 10; i++) {array[i] = [1];for (var j = 1; j < i; j++) {array[i].push(array[i-1][j-1]+array[i-1][j]);}array[i].push(1);}var width = 600, height = 400;var x = width/2, y = 30;var measure = 0, s = '';var len = array.length;for (var i = 0; i < len; i++) {s = array[i].join('    ');measure = plot.measureText(s);plot.fillText(s, x-measure/2, y, measure);y += 30;}}</span>






關於求二面角,小偉找到了這個公式:

<span style="font-size:18px;">>>> cos =  0.9218142082600806 角度是: 22.80723538641745 度#[數] dihedral angle;#二面角餘弦def dihedral():    xyz = [-1.2999760,0.0173840,-0.7162670,           1.0107690,1.5229620,-0.0945670,           0.0932470,-1.0086090,1.6265070,           -1.2280340,-1.4934410,1.8123150,           0.0932470,-1.0086090,1.6265070,           1.0734260,-1.5230970,2.5155820]    #六個點    ax1 = xyz[0]    ay1 = xyz[1]    az1 = xyz[2]    bx2 = xyz[3]    by2 = xyz[4]    bz2 = xyz[5]    cx3 = xyz[6]    cy3 = xyz[7]    cz3 = xyz[8]    dx1 = xyz[9]    dy1 = xyz[10]    dz1 = xyz[11]    ex2 = xyz[12]    ey2 = xyz[13]    ez2 = xyz[14]    fx3 = xyz[15]    fy3 = xyz[16]    fz3 = xyz[17]    #面一法線    nx = ((cz3-az1)/(cy3-ay1)-(bz2-az1)/(by2-ay1))/((bx2-ax1)/(by2-ay1)-(cx3-ax1)/(cy3-ay1))    ny = ((cz3-az1)/(cx3-ax1)-(bz2-az1)/(bx2-ax1))/((by2-ay1)/(bx2-ax1)-(cy3-ay1)/(cx3-ax1))    nz = 1    #面二法線    mx = ((fz3-dz1)/(fy3-dy1)-(ez2-dz1)/(ey2-dy1))/((ex2-dx1)/(ey2-dy1)-(fx3-dx1)/(fy3-dy1))    my = ((fz3-dz1)/(fx3-dx1)-(ez2-dz1)/(ex2-dx1))/((ey2-dy1)/(ex2-dx1)-(fy3-dy1)/(fx3-dx1))    mz = 1    cosAngle = (nx*mx+ny*my+nz*mz)/((math.sqrt(nx**2+ny**2+nz**2))*(math.sqrt(mx**2+my**2+mz**2)));    print('cos = ', cosAngle, '角度是:', 180/math.pi*math.acos(cosAngle), '度');</span>

但是在驗證的過程中小偉發現這個演算法好像有問題:

比如對於下面這個例子:



求一下VAB和ABC的二面角

<span style="font-size:18px;">>>> [2, 5, 2, 5, 0, 1, 0, 0, 0, 1, 1, 5, 5, 0, 1, 0, 0, 0]cos =  0.4911436350228293 角度是: 60.584222864016645 度#[數] dihedral angle;#二面角餘弦#暫時只能算不垂直或平行於xy, xz, yz任一平面的兩平面的二面角#公式尋找中...def dihedral(points):    #points格式是 []*18, 分六個點,每個點x, y, z座標排列    '''    xyz = [-1.2999760,0.0173840,-0.7162670,           1.0107690,1.5229620,-0.0945670,           0.0932470,-1.0086090,1.6265070,           -1.2280340,-1.4934410,1.8123150,           0.0932470,-1.0086090,1.6265070,           1.0734260,-1.5230970,2.5155820]    '''    if (len(points) != 18):        return 'inf';    xyz = points;    #六個點    ax1 = xyz[0]    ay1 = xyz[1]    az1 = xyz[2]    bx2 = xyz[3]    by2 = xyz[4]    bz2 = xyz[5]    cx3 = xyz[6]    cy3 = xyz[7]    cz3 = xyz[8]    dx1 = xyz[9]    dy1 = xyz[10]    dz1 = xyz[11]    ex2 = xyz[12]    ey2 = xyz[13]    ez2 = xyz[14]    fx3 = xyz[15]    fy3 = xyz[16]    fz3 = xyz[17]    #面一法線    nx = ((cz3-az1)/(cy3-ay1)-(bz2-az1)/(by2-ay1))/((bx2-ax1)/(by2-ay1)-(cx3-ax1)/(cy3-ay1))    ny = ((cz3-az1)/(cx3-ax1)-(bz2-az1)/(bx2-ax1))/((by2-ay1)/(bx2-ax1)-(cy3-ay1)/(cx3-ax1))    nz = 1    #面二法線    mx = ((fz3-dz1)/(fy3-dy1)-(ez2-dz1)/(ey2-dy1))/((ex2-dx1)/(ey2-dy1)-(fx3-dx1)/(fy3-dy1))    my = ((fz3-dz1)/(fx3-dx1)-(ez2-dz1)/(ex2-dx1))/((ey2-dy1)/(ex2-dx1)-(fy3-dy1)/(fx3-dx1))    mz = 1    cosAngle = (nx*mx+ny*my+nz*mz)/((math.sqrt(nx**2+ny**2+nz**2))*(math.sqrt(mx**2+my**2+mz**2)));    print('cos = ', cosAngle, '角度是:', 180/math.pi*math.acos(cosAngle), '度');#求二面角def tmp():    V = [2, 5, 2]    A = [5, 0, 1]    B = [0, 0, 0]    C = [1, 1, 5]    points = V+ A + B+ C+A+B;    #print(len(points));    print(points);        dihedral(points);</span>


再求一下VBC與ABC的,或是VAB與VBC的

<span style="font-size:18px;">>>> [2, 5, 2, 0, 0, 0, 1, 1, 5, 1, 1, 5, 5, 0, 1, 0, 0, 0]cos =  -0.2558139534883721 角度是: 104.82182106205012 度>>> ================================ RESTART ================================>>> [2, 5, 2, 5, 0, 1, 1, 1, 5, 1, 1, 5, 5, 0, 1, 0, 0, 0]cos =  -0.19218663979154185 角度是: 101.08042157684446 度</span>

怎麼都會是100多度呢,看著不像啊,但小偉也說不準是對是錯。

先放著吧。


<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,190);                                      //座標軸設定                var scaleX = 4*r, scaleY = 4*r;                  var spaceX = 2, spaceY = 2;                   var xS = -10, xE = 10;                  var yS = -10, yE = 10;                  config.axisSpacing(xS, xE, spaceX, scaleX, 'X');                    config.axisSpacing(yS, yE, spaceY, scaleY, 'Y');                                                     var array = [[2, 5, 2], [5, 0, 1], [0, 0, 0], [1, 1, 5]];            //array = shape.xyzSort(array);          var size = array.length;                      var array2D = [];          for (var i = 0; i < size; i++) {              array2D.push(shape.point3D(array[i][0], array[i][1], array[i][2]));          }                              //去除重複點            var pointArray = removeDuplicatedPoint(array2D);            //無重複的點的數量            var points = pointArray.length;                        //得到距離陣列            //格式為[[點1序號,點2序號, 距離值], ...]            var distanceArray = distanceSort(pointArray);            //邊的數量            var edges = distanceArray.length;                        //存放需要連通的邊            var linkedArray = [];            //連通的邊的數量            var links = 0;                        //每個頂點相關的邊的集合            var edgeOfVertex = [];                        for (var i = 0; i < points; i++) {                                                //獲得頂點相關的邊的集合                edgeOfVertex = [];                for (var j = 0; j < edges; j++) {                    if (distanceArray[j][0] == i ||                        distanceArray[j][1] == i) {                        edgeOfVertex.push(distanceArray[j]);                    }                }                                //根據起始點尋找最短長度的兩條邊                edgeOfVertex.sort(function(a, b) {                    return a[2] - b[2];                });                                var choice = 4;                if (edgeOfVertex.length > choice) {                    edgeOfVertex = edgeOfVertex.slice(0, choice);                }                                linkedArray = linkedArray.concat(edgeOfVertex);            }                                    //document.write(linkedArray.join(' , ')+'<br/>');            linkedArray = removeDuplicatedPoint(linkedArray);            links = linkedArray.length;                        //document.write(linkedArray.join(' , ')+'<br/>');                            var startPoint, endPoint, x1, y1, x2, y2;            //比例縮放            var scale = 40;                        for (var i = 0; i < links; i++) {                startPoint = linkedArray[i][0];                endPoint = linkedArray[i][1];                x1 = pointArray[startPoint][0];                y1 = pointArray[startPoint][1];                x2 = pointArray[endPoint][0];                y2 = pointArray[endPoint][1];                                shape.vectorDraw([[x1,y1], [x2, y2]], 'red', scale);            }                      shape.pointDraw(pointArray, 'blue', scale, 1, 'VABC');                        plot.setFillStyle('blue');            plot.fillText('向量圖', -270, -170, 300);                  }</span>



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

[從頭學數學] 第193節 推理與證明

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.