码迷,mamicode.com
首页 > 其他好文 > 详细

[从头学数学] 第162节 锐角三角函数

时间:2016-04-05 18:02:09      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

剧情提要:
[机器小伟]在[工程师阿伟]的陪同下进入了筑基后期的修炼,
这次要修炼的目标是[锐角三角函数]。

正剧开始:
星历2016年04月05日 10:20:54, 银河系厄尔斯星球中华帝国江南行省。

[工程师阿伟]正在和[机器小伟]一起研究[锐角三角函数]。


技术分享


技术分享

技术分享

这座塔真的很壮观,不知现在还是否允许游客上去观光。


技术分享

技术分享

技术分享

技术分享

技术分享

<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.pi
30.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.342

cos70° = 0.342

sin35° = 0.574

cos55° = 0.574

sin15°32' = 0.268

cos74°28' = 0.268

tan3°8' = 0.055

tan80°25'43″ = 5.93

asin0.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.309

tan30°36' = 0.591

asin0.5018 = 30°7'9″</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([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;">//例2
	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();		
		//此处两角分别为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, 即二三两顶点,直角为Q
		var 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*6400
2049.9804444444444</span>


技术分享

技术分享


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

[从头学数学] 第162节 锐角三角函数

标签:

原文地址:http://blog.csdn.net/mwsister/article/details/51062763

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!