### [從頭學數學] 第162節 銳角三角函數

[機器小偉]在[工程師阿偉]的陪同下進入了築基后期的修煉，

[工程師阿偉]正在和[機器小偉]一起研究[銳角三角函數]。

`<span style="font-size:18px;">if (1) {config.setSector(1,1,1,1);var r = 20;config.graphPaper2D(0, 0, r);config.axis2D(0, 0, 180);//繪制三角形var triangle = new Triangle();var array = triangle.know2edges([10, 6], -90);var scale = r;shape.angleDraw([].concat(array), 'red', scale, 'ABC');//求角的三角函數值var angle = 36.87 / 180*Math.PI;var sinA = Math.sin(angle), cosA = Math.cos(angle), tanA = Math.tan(angle);//打印結果var x = -200, y = -170;var result = [];result.push(['sinA = ', sinA]);result.push(['cosA = ', cosA]);result.push(['tanA = ', tanA]);for (var i = 0; i < 3; i++) {plot.fillText(result[i][0]+result[i][1].toFixed(3), x, y, 100);y += 30;}}</span>`

`<span style="font-size:18px;">//第1題if (1) {config.setSector(1,1,1,1);var r = 20;config.graphPaper2D(0, 0, r);config.axis2D(0, 0, 180);//繪制三角形var triangle = new Triangle();var array = triangle.know2edges([13, 12], -90);var scale = r;shape.angleDraw([].concat(array), 'red', scale, 'BAC');//求角的三角函數值var angle = 22.62 / 180*Math.PI;var sinA = Math.sin(angle), cosA = Math.cos(angle), tanA = Math.tan(angle);//打印結果var x = -200, y = -170;var result = [];result.push(['sinA = ', sinA]);result.push(['cosA = ', cosA]);result.push(['tanA = ', tanA]);for (var i = 0; i < 3; i++) {plot.fillText(result[i][0]+result[i][1].toFixed(3), x, y, 100);y += 30;}//求角的三角函數值angle = Math.PI/2- angle;sinA = Math.sin(angle);cosA = Math.cos(angle);tanA = Math.tan(angle);//打印結果x = -200, y = 30;result = [];result.push(['sinB = ', sinA]);result.push(['cosB = ', cosA]);result.push(['tanB = ', tanA]);for (var i = 0; i < 3; i++) {plot.fillText(result[i][0]+result[i][1].toFixed(3), x, y, 100);y += 30;}}</span>`

`<span style="font-size:18px;">if (1) {config.setSector(1,1,1,1);var r = 20;config.graphPaper2D(0, 0, r);config.axis2D(0, 0, 180);//繪制三角形var triangle = new Triangle();var array = triangle.know2edges([2, 3], 90);var scale = 3*r;shape.angleDraw([].concat(array), 'red', scale, 'ACB');//求角的三角函數值var angle = 56.31 / 180*Math.PI;var sinA = Math.sin(angle), cosA = Math.cos(angle), tanA = Math.tan(angle);//打印結果var x = -200, y = -170;var result = [];result.push(['sinA = ', sinA]);result.push(['cosA = ', cosA]);result.push(['tanA = ', tanA]);for (var i = 0; i < 3; i++) {plot.fillText(result[i][0]+result[i][1].toFixed(3), x, y, 100);y += 30;}//求角的三角函數值angle = Math.PI/2- angle;sinA = Math.sin(angle);cosA = Math.cos(angle);tanA = Math.tan(angle);//打印結果x = -200, y = 30;result = [];result.push(['sinB = ', sinA]);result.push(['cosB = ', cosA]);result.push(['tanB = ', tanA]);for (var i = 0; i < 3; i++) {plot.fillText(result[i][0]+result[i][1].toFixed(3), x, y, 100);y += 30;}}</span>`

`<span style="font-size:18px;">>>> import math;>>> math.sin(18)-0.750987246771676>>> math.sin(18/180*math.pi)0.3090169943749474>>> math.tan(30.6/180*math.pi)0.5913983513994712</span>`

`<span style="font-size:18px;">>>> math.asin(0.5018);0.5256784866432485>>> _*180/math.pi30.119158665482352>>> a = _;>>> (a-math.floor(a))*60;7.149519928941146>>> b = _;>>> (b-math.floor(b))*60;8.971195736468758</span>`

`<span style="font-size:18px;">#### @usage   三角函數調用封裝# @author  mw# @date    2016年04月05日  星期二  09:36:50 # @param# @return####def triFun():    #需要計算的任務    #輸入量為角度制，依次為度，分，秒    #可輸出顯示度、分、秒的表達式    #用於計算銳角三角函數    #對於角度變換，還沒有經過測試    #以后可擴展添加其它多種數學函數    task = [        ['sin', 20],        ['cos', 70],        ['sin', 35],        ['cos', 55],        ['sin', 15, 32],        ['cos', 74, 28],        ['tan', 3, 8],        ['tan', 80, 25, 43],        ['asin', 0.6275],        ['asin', 0.0547],        ['acos', 0.6252],        ['acos', 0.1659],        ['atan', 4.8425],        ['atan', 0.8816],        ['sin', 18],        ['tan', 30, 36],        ['asin', 0.5018]        ];    size = len(task);    result = [];    import math;    for i in range(size):                if task[i][0] == 'sin' or task[i][0] == 'cos' or task[i][0] == 'tan' \           or task[i][0] == 'cot':            size_1 = len(task[i]);            angle = 0;            if size_1 == 2:                angle = task[i][1];            elif size_1 == 3:                angle = task[i][1]+task[i][2]/60;            elif size_1 == 4:                angle = task[i][1]+task[i][2]/60+task[i][3]/3600;            angle = angle/180*math.pi;            if task[i][0] == 'sin':                s = '';                if size_1 == 2:                    s = task[i][0]+str(task[i][1])+'°';                elif size_1 == 3:                    s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\'';                elif size_1 == 4:                    s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\''+str(task[i][3])+'″';                s += ' = ';                s += str(round(math.sin(angle), 3));                s += '\n';                result.append(s);            elif task[i][0] == 'cos':                s = '';                if size_1 == 2:                    s = task[i][0]+str(task[i][1])+'°';                elif size_1 == 3:                    s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\'';                elif size_1 == 4:                    s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\''+str(task[i][3])+'″';                s += ' = ';                s += str(round(math.cos(angle), 3));                s += '\n';                result.append(s);            elif task[i][0] == 'tan':                s = '';                if size_1 == 2:                    s = task[i][0]+str(task[i][1])+'°';                elif size_1 == 3:                    s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\'';                elif size_1 == 4:                    s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\''+str(task[i][3])+'″';                s += ' = ';                s += str(round(math.tan(angle), 3));                s += '\n';                result.append(s);            elif task[i][0] == 'cot':                s = '';                if size_1 == 2:                    s = task[i][0]+str(task[i][1])+'°';                elif size_1 == 3:                    s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\'';                elif size_1 == 4:                    s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\''+str(task[i][3])+'″';                s += ' = ';                s += str(round(1/math.tan(angle), 3));                s += '\n';                result.append(s);        else:            if task[i][0] == 'asin':                s = '';                s = task[i][0]+str(task[i][1])+' = ';                res = math.asin(task[i][1])/math.pi*180;                if res < 0:                    s += '-';                absres = abs(res);                s += str(math.floor(absres))+'°'+str(math.floor(absres*60)%60)+'\''+str(round(absres*3600)%60)+'″';                s += '\n';                result.append(s);            elif task[i][0] == 'acos':                s = '';                s = task[i][0]+str(task[i][1])+' = ';                res = math.acos(task[i][1])/math.pi*180;                if res < 0:                    s += '-';                absres = abs(res);                s += str(math.floor(absres))+'°'+str(math.floor(absres*60)%60)+'\''+str(round(absres*3600)%60)+'″';                s += '\n';                result.append(s);            elif task[i][0] == 'atan':                s = '';                s = task[i][0]+str(task[i][1])+' = ';                res = math.atan(task[i][1])/math.pi*180;                if res < 0:                    s += '-';                absres = abs(res);                s += str(math.floor(absres))+'°'+str(math.floor(absres*60)%60)+'\''+str(round(absres*3600)%60)+'″';                s += '\n';                result.append(s);            elif task[i][0] == 'acot':                s = '';                s = task[i][0]+str(task[i][1])+' = ';                res = 90-math.atan(task[i][1])/math.pi*180;                if res < 0:                    s += '-';                absres = abs(res);                s += str(math.floor(absres))+'°'+str(math.floor(absres*60)%60)+'\''+str(round(absres*3600)%60)+'″';                s += '\n';                result.append(s);                            else:                pass;                size = len(result);    for i in range(size):        print(result[i]);        if __name__ == '__main__':    triFun();</span>`

`<span style="font-size:18px;">>>> sin20° = 0.342cos70° = 0.342sin35° = 0.574cos55° = 0.574sin15°32' = 0.268cos74°28' = 0.268tan3°8' = 0.055tan80°25'43″ = 5.93asin0.6275 = 38°51'57″asin0.0547 = 3°8'8″acos0.6252 = 51°18'11″acos0.1659 = 80°27'2″atan4.8425 = 78°19'56″atan0.8816 = 41°23'58″sin18° = 0.309tan30°36' = 0.591asin0.5018 = 30°7'9″</span>`

`<span style="font-size:18px;">//例1if (1) {config.setSector(1,1,1,1);var r = 20;config.graphPaper2D(0, 0, r);config.axis2D(0, 0, 180);//繪制三角形var triangle = new Triangle();var array = triangle.know2edges([Math.sqrt(6), Math.sqrt(2)], 90);var scale = 3*r;shape.angleDraw([].concat(array), 'red', scale, 'BCA');//求角的三角函數值var angle = 60 / 180*Math.PI;var sinA = Math.sin(angle), cosA = Math.cos(angle), tanA = Math.tan(angle);//打印結果var x = -200, y = -170;var result = [];result.push(['sinA = ', sinA]);result.push(['cosA = ', cosA]);result.push(['tanA = ', tanA]);for (var i = 0; i < 3; i++) {plot.fillText(result[i][0]+result[i][1].toFixed(3), x, y, 100);y += 30;}//求角的三角函數值angle = Math.PI/2- angle;sinA = Math.sin(angle);cosA = Math.cos(angle);tanA = Math.tan(angle);//打印結果x = -200, y = 30;result = [];result.push(['sinB = ', sinA]);result.push(['cosB = ', cosA]);result.push(['tanB = ', tanA]);for (var i = 0; i < 3; i++) {plot.fillText(result[i][0]+result[i][1].toFixed(3), x, y, 100);y += 30;}}</span>`

`<span style="font-size:18px;">//例2if (1) {config.setSector(1,1,1,1);var r = 20;config.graphPaper2D(0, 0, r);config.axis2D(0, 0, 180);//繪制三角形var triangle = new Triangle();//此處兩角分別為B, A，即第三、一兩頂點，邊則是AC， 即一、二兩頂點var array = triangle.know2angles([35, 55], 20);var scale = r/4;shape.angleDraw([].concat(array), 'red', scale, 'ACB');//求角的三角函數值var angle = 55 / 180*Math.PI;var sinA = Math.sin(angle), cosA = Math.cos(angle), tanA = Math.tan(angle);//打印結果var x = -200, y = -170;var result = [];result.push(['sinA = ', sinA]);result.push(['cosA = ', cosA]);result.push(['tanA = ', tanA]);for (var i = 0; i < 3; i++) {plot.fillText(result[i][0]+result[i][1].toFixed(3), x, y, 100);y += 30;}//求角的三角函數值angle = Math.PI/2- angle;sinA = Math.sin(angle);cosA = Math.cos(angle);tanA = Math.tan(angle);//打印結果x = -200, y = 30;result = [];result.push(['sinB = ', sinA]);result.push(['cosB = ', cosA]);result.push(['tanB = ', tanA]);for (var i = 0; i < 3; i++) {plot.fillText(result[i][0]+result[i][1].toFixed(3), x, y, 100);y += 30;}}</span>`

`<span style="font-size:18px;">//神舟飛船if (1) {config.setSector(1,1,1,1);var r = 20;config.graphPaper2D(0, 0, r);config.axis2D(0, 0, 180);//繪制三角形var triangle = new Triangle();//此處兩邊分別為FO，即第一二兩頂點，OQ， 即二三兩頂點，直角為Qvar array = triangle.know2edges([6400+343, 6400], -90);var scale = 0.035;shape.angleDraw([].concat(array), 'red', scale, 'FOQ');//求角的三角函數值var angle = 18.35 / 180*Math.PI;var sinA = Math.sin(angle), cosA = Math.cos(angle), tanA = Math.tan(angle);//打印結果var x = -200, y = -170;var result = [];result.push(['sinA = ', sinA]);result.push(['cosA = ', cosA]);result.push(['tanA = ', tanA]);for (var i = 0; i < 3; i++) {plot.fillText(result[i][0]+result[i][1].toFixed(3), x, y, 100);y += 30;}//求角的三角函數值angle = Math.PI/2- angle;sinA = Math.sin(angle);cosA = Math.cos(angle);tanA = Math.tan(angle);//打印結果x = -200, y = 30;result = [];result.push(['sinB = ', sinA]);result.push(['cosB = ', cosA]);result.push(['tanB = ', tanA]);for (var i = 0; i < 3; i++) {plot.fillText(result[i][0]+result[i][1].toFixed(3), x, y, 100);y += 30;}y += 50;plot.fillText('A => O , B => Q', x, y, 150);}>>> 18.35/180*3.142*64002049.9804444444444</span>`