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

[从头学数学] 第203节 坐标系与参数方程

时间:2016-05-03 18:17:15      阅读:267      评论:0      收藏:0      [点我收藏+]

标签:

剧情提要:
[机器小伟]在[工程师阿伟]的陪同下进入了[九转金丹]之第七转的修炼。
这次要研究的是[坐标系与参数方程]。

正剧开始:

星历2016年05月03日 13:18:47, 银河系厄尔斯星球中华帝国江南行省。
[工程师阿伟]正在和[机器小伟]一起研究[坐标系与参数方程]。


技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享


技术分享

技术分享

技术分享

技术分享

<span style="font-size:18px;">例3
-2.499999999999999,4.330127018922194
例4
1.9999559995159892,3.6652041313597623
习题1.2 -- 3
4
习题1.2 -- 4
2.121320343559643,2.1213203435596424
-0.9999999999999996,1.7320508075688774
2.4492935982947064e-16,4
-0.866,1.0605441280616079e-16
习题1.2 -- 5
3.4640762116327637,0.523586073612931
-0.7453333333333334,4.71238898038469
3.5,0
3.9999119990319785,4.1887775026147205

	if (1) {
		hint('例3');
		hint(polar2XY([5, 2/3*Math.PI]));
		hint('例4');
		hint(XY2polar([-1.732, -1]));
		
		hint('习题1.2 -- 3');		
		var pointA = [3, -Math.PI/3], pointB = [1, 2*Math.PI/3];		
		hint(distance2D(polar2XY(pointA), polar2XY(pointB)));
		
		hint('习题1.2 -- 4');
		hint(polar2XY([3, Math.PI/4]));
		hint(polar2XY([2, Math.PI*2/3]));
		hint(polar2XY([4, Math.PI/2]));
		hint(polar2XY([0.866, Math.PI]));
		
		hint('习题1.2 -- 5');
		hint(XY2polar([3, 1.732]));
		hint(XY2polar([0, -2.236/3]));
		hint(XY2polar([3.5, 0]));
		hint(XY2polar([-2, -2*1.732]));
		
		
	}
	
//极坐标转为直角坐标
function polar2XY(point) {
	var rou = point[0], thita = point[1];
	return [rou*Math.cos(thita), rou*Math.sin(thita)];
}

//直角坐标转为极坐标
function XY2polar(point) {
	var x = point[0], y = point[1];
	var rou = Math.pow(x*x+y*y, 0.5);
	var thita = Math.PI/2;
	
	if (x != 0) {
		thita = Math.atan(Math.abs(y/x));
		
		if (x < 0 && y >= 0) {
			thita = Math.PI-thita;
		}
		else if (x < 0 && y < 0) {
			thita = Math.PI+thita;
		}
		else if (x > 0 && y < 0) {
			thita = Math.PI*2-thita;
		}
	}
	else {
		rou = y;
		if (y >= 0) {
			thita = Math.PI/2;
		}
		else {
			thita = 3*Math.PI/2;
		}
	}
	return [rou, thita];
}


function hint(string) {
	document.write(string+'<br/>');
}</span>

技术分享

技术分享

<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,180);            
              
        //坐标轴设定      
        var scaleX = 2*r, scaleY = 2*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 transform = new Transform();          
        //存放函数图像上的点      
        var a = [], b = [], c = [], d = [];        
                
        //需要显示的函数说明  
					//希腊字母表(存此用于Ctrl C/V
			//ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ
			//αβγδεζηθικλμνξοπρστυφχψω
        var f1 = 'ρ = 10cosθ', f2 = '', f3 = '', f4 = '';      
          

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		for (var thita = 0; thita < Math.PI*2; thita +=Math.PI/24) {
			pointA = [10*Math.cos(thita), thita];
			a.push(polar2XY(pointA));
		}
		
                
        //存放临时数组      
        var tmp = [];      
                
        //显示变换      
        if (a.length > 0) {      
            a = transform.scale(transform.translate(a, 0, 0), scaleX/spaceX, scaleY/spaceY);       
            //函数1      
            tmp = [].concat(a);          
            shape.pointDraw(tmp, 'red');          
            tmp = [].concat(a);          
            shape.multiLineDraw(tmp, 'pink');        
                    
            plot.setFillStyle('red');      
            plot.fillText(f1, 100, -180, 200);        
        }

		
    }  </span>

技术分享

技术分享

<span style="font-size:18px;">        //需要显示的函数说明  
					//希腊字母表(存此用于Ctrl C/V
			//ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ
			//αβγδεζηθικλμνξοπρστυφχψω
        var f1 = 'ρ = 10', f2 = '', f3 = '', f4 = '';      
          

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		for (var thita = 0; thita < Math.PI*2; thita +=Math.PI/24) {
			pointA = [10, thita];
			a.push(polar2XY(pointA));
		}</span>

技术分享

技术分享

<span style="font-size:18px;">        var f1 = 'ρ = 10/cosθ', f2 = '', f3 = '', f4 = '';      
          

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		for (var thita = 0; thita < Math.PI*2; thita +=Math.PI/24) {
			pointA = [10/Math.cos(thita), thita];
			a.push(polar2XY(pointA));
		}</span>

技术分享

技术分享

技术分享

技术分享

<span style="font-size:18px;">       var f1 = 'ρ = 2sinθ', f2 = '', f3 = '', f4 = '';      
          

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		for (var thita = 0; thita < Math.PI*2; thita +=Math.PI/24) {
			pointA = [2*Math.sin(thita), thita];
			a.push(polar2XY(pointA));
		}</span>

技术分享

技术分享

<span style="font-size:18px;">        var f1 = 'ρ = 5sin(θ+1/4pi)', f2 = '', f3 = '', f4 = '';      
          

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		for (var thita = 0; thita < Math.PI*2; thita +=Math.PI/24) {
			pointA = [5*Math.sin(thita+Math.PI/4), thita];
			a.push(polar2XY(pointA));
		}</span>


技术分享

技术分享

<span style="font-size:18px;">//柱坐标转直角坐标
function cylin2XYZ(point) {
	var rou = point[0], thita = point[1], z = point[2];
	return [rou*Math.cos(thita), rou*Math.sin(thita), z];

}
	
//直角坐标转为柱坐标
function XYZ2cylin(point) {
	var x = point[0], y = point[1], z = point[2];
	var polar = XY2polar([x, y]);
	return [polar[0], polar[1], z];
}

//球坐标转直角坐标
function sphere2XYZ(point) {
	//P(r, psai, thita)
	var r = point[0], psai = point[1], thita = point[2];
	return [r*Math.sin(psai)*Math.cos(thita), 			r*Math.sin(psai)*Math.sin(thita), r*Math.cos(psai)];

}
	
//直角坐标转为球坐标
function XYZ2sphere(point) {
	var x = point[0], y = point[1], z = point[2];
	var r = Math.sqrt(x*x + y*y+z*z);
	return [r, Math.acos(z/r), Math.atan(y/x)];

}</span>



技术分享


技术分享

技术分享

技术分享

<span style="font-size:18px;">        var f1 = 'x = 3t, y = 2t^2+1', f2 = '', f3 = '', f4 = '';      
          

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		for (var t = -5; t <= 5; t+=0.2) {
			a.push([3*t, 2*t*t+1]);
		}</span>


技术分享

技术分享

<span style="font-size:18px;">        var f1 = 'x=rcos(t), y = rsin(t)', f2 = '', f3 = '', f4 = '';      
          

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		for (var t = -5; t <= 5; t+=0.2) {
			a.push([10*Math.cos(t), 10*Math.sin(t)]);
		}</span>

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

<span style="font-size:18px;">      var f1 = 'x=3cost, y = 2sint', f2 = '', f3 = '', f4 = '';      
          

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		for (var t = -5; t <= 5; t+=0.2) {
			a.push([3*Math.cos(t), 2*Math.sin(t)]);
		}</span>

技术分享

技术分享

<span style="font-size:18px;">        var f1 = 'x=3/cost, y = 2tant', f2 = '', f3 = '', f4 = '';      
          

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		for (var t = -5; t <= 5; t+=0.2) {
			a.push([3/Math.cos(t), 2*Math.tan(t)]);
		}</span>


技术分享

技术分享

技术分享

技术分享

技术分享

<span style="font-size:18px;">        var f1 = 'x=2/tan^2(t), y = 2/tant', f2 = '', f3 = '', f4 = '';      
          

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		for (var t = -5; t <= 5; t+=0.2) {
			a.push([2/Math.pow(Math.tan(t),2), 2/Math.tan(t)]);
		}</span>

技术分享

技术分享

技术分享

技术分享


<span style="font-size:18px;">       var f1 = 'x=5+0.5t, y = 4+0.866t', f2 = '', f3 = '', f4 = '';      
          

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		for (var t = -5; t <= 5; t+=0.2) {
			a.push([5 + t*0.5, 4+t*0.866]);
		}
		</span>
技术分享

技术分享

技术分享

技术分享

技术分享

<span style="font-size:18px;">        var f1 = 'x=r(cost+tsint), y = r(sint-tcost)', f2 = '', f3 = '', f4 = '';      
          

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		for (var t = -5; t <= 5; t+=0.2) {
			a.push([(Math.cos(t)+t*Math.sin(t)), (Math.sin(t)-t*Math.cos(t))]);
		}</span>

技术分享

技术分享

<span style="font-size:18px;">     var f1 = 'x=r(t-tsint), y = r(1-cost)', f2 = '', f3 = '', f4 = '';      
          

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		for (var t = -8; t <= 8; t+=0.2) {
			a.push([(t-Math.sin(t)), (1 - Math.cos(t))]);
		}</span>

技术分享

技术分享

<span style="font-size:18px;">        var f1 = '内摆线 x = cost+cos(nt)/n, y = sint-sin(nt)/n, n=3', f2 = '', f3 = '', f4 = '';      
        var r_1 = 1, r_2 = 4*r_1;

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		var angle = 0;
		//思考:
		//angle = r_1*(t-sin(t))/r_2*2pi
		//angle2 = t - Math.floor(t/2pi)
		//x = r_2cos(a)-r_1cos(a2)
		//y = r_2sin(a)- r_1sin(a2)
		
		//正确内摆线公式
		//x = cost+cos(nt)/n, y = sint-sin(nt)/n
		
		var N = 3; //外径与内径比例-1
		
		for (var t = -8; t <= 8; t+=0.2) {
			a.push([Math.cos(t)+Math.cos(N*t)/N, Math.sin(t)-Math.sin(N*t)/N]);
		}</span>

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

<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,180);            
              
        //坐标轴设定      
        var scaleX = 2*r, scaleY = 2*r;        
        var spaceX = 0.5, spaceY = 0.5;         
        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 transform = new Transform();          
        //存放函数图像上的点      
        var a = [], b = [], c = [], d = [];        
                
        //需要显示的函数说明  
					//希腊字母表(存此用于Ctrl C/V
			//ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ
			//αβγδεζηθικλμνξοπρστυφχψω
        var f1 = '内摆线 x = cost+cos(nt)/n, y = sint-sin(nt)/n, n=4', f2 = '', f3 = '', f4 = '';      
        var r_1 = 1, r_2 = 4*r_1;

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		var angle = 0;
		//思考:
		//angle = r_1*(t-sin(t))/r_2*2pi
		//angle2 = t - Math.floor(t/2pi)
		//x = r_2cos(a)-r_1cos(a2)
		//y = r_2sin(a)- r_1sin(a2)
		
		//正确内摆线公式
		//x = cost+cos(nt)/n, y = sint-sin(nt)/n
		
		var N = 4; //外径与内径比例-1
		
		for (var t = -8; t <= 8; t+=0.1) {
			a.push([Math.cos(t)+Math.cos(N*t)/N, Math.sin(t)-Math.sin(N*t)/N]);
		}
		
                
        //存放临时数组      
        var tmp = [];      
                
        //显示变换      
        if (a.length > 0) {      
            a = transform.scale(transform.translate(a, 0, 0), scaleX/spaceX, scaleY/spaceY);       
            //函数1      
            tmp = [].concat(a);          
            shape.pointDraw(tmp, 'blue');          
            tmp = [].concat(a);          
            shape.multiLineDraw(tmp, '#8822FF');        
                    
            plot.setFillStyle('blue');      
            plot.fillText(f1, 30, -150, 200);        
        }

		
    }  
	</span>


技术分享

技术分享

技术分享

技术分享

<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,180);            
              
        //坐标轴设定      
        var scaleX = 2*r, scaleY = 2*r;        
        var spaceX = 0.8, spaceY = 0.8;         
        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 transform = new Transform();          
        //存放函数图像上的点      
        var a = [], b = [], c = [], d = [];        
                
        //需要显示的函数说明  
					//希腊字母表(存此用于Ctrl C/V
			//ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ
			//αβγδεζηθικλμνξοπρστυφχψω
        var f1 = '外摆线 x = (a+b)cost-bcos((a+b)/bt), y = (a+b)sint-bsin((a+b)/bt), a:b = 1 : 1 ', f2 = '', f3 = '', f4 = '';      
        var r_1 = 1, r_2 = 4*r_1;

        //函数描点  
		//参数方程
		var x, y;
		var pointA = [];
		
		var angle = 0;
		
		//外摆线公式
		//x = cost+cos(nt)/n, y = sint-sin(nt)/n
		
		var N1 = 1, N2 = 1; //外径与内径比例-1
		
		for (var t = -10; t <= 10; t+=0.2) {
			a.push([(N1+N2)*Math.cos(t)-N2*Math.cos((N1+N2)/N2*t), 
					(N1+N2)*Math.sin(t)-N2*Math.sin((N1+N2)/N2*t)]);
		}
		
                
        //存放临时数组      
        var tmp = [];      
                
        //显示变换      
        if (a.length > 0) {      
            a = transform.scale(transform.translate(a, 0, 0), scaleX/spaceX, scaleY/spaceY);       
            //函数1      
            tmp = [].concat(a);          
            shape.pointDraw(tmp, 'blue');          
            tmp = [].concat(a);          
            shape.multiLineDraw(tmp, '#8822FF');        
                    
            plot.setFillStyle('blue');      
            plot.fillText(f1, 30, -150, 200);        
        }

		
    }  </span>



技术分享


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

[从头学数学] 第203节 坐标系与参数方程

标签:

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

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