ActionScript 3 计算椭圆

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 计算椭圆相关的知识,希望对你有一定的参考价值。

/*
		* This functions returns an array containing 36 points to draw an
		* ellipse.
		*
		* @param x {double} X coordinate
		* @param y {double} Y coordinate
		* @param a {double} Semimajor axis
		* @param b {double} Semiminor axis
		* @param angle {double} Angle of the ellipse
		*/

		private function calculateEllipse(x:Number, y:Number, a:Number, b:Number, angle:Number, steps:Number = 36 ):Array 
		{
			var points:Array = [];
			
			// Angle is given by Degree Value
			var beta:Number = -angle * (Math.PI / 180); //(Math.PI/180) converts Degree Value into Radians
			var sinbeta:Number = Math.sin(beta);
			var cosbeta:Number = Math.cos(beta);
		 
			for (var i:Number = 0; i < 360; i += 360 / steps) 
			{
				var alpha:Number = i * (Math.PI / 180) ;
				var sinalpha:Number = Math.sin(alpha);
				var cosalpha:Number = Math.cos(alpha);
				 
				var X:Number = x + (a * cosalpha * cosbeta - b * sinalpha * sinbeta);
				var Y:Number = y + (a * cosalpha * sinbeta + b * sinalpha * cosbeta);
				 
				points.push(new Point(X, Y));
			}
		 
			return points;
		}

以上是关于ActionScript 3 计算椭圆的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 简单椭圆长弦

ActionScript的椭圆曲线加密

ActionScript 3.0 + 计算两个日期之间的时间跨度?

画出经过 3 个点的椭圆

ActionScript 3 计算年龄

ActionScript 3 计算弧度和背面的度数