以下是一些在AS3.0中常用的三角函数。代码如下:
trace (Math.tan(45*Math.PI/180));//已知45度角求正切值; trace (Math.atan(1)*180/Math.PI);//已知正切值为1求出角度; trace (Math.sin(30*Math.PI/180));//已知30度角求正弦值; trace (Math.asin(1/2)*180/Math.PI);//已知正弦值0.5求角度; trace (Math.cos(60*Math.PI/180));//已知60度角求余弦值; trace (Math.acos(1/2)*180/Math.PI);//已知余弦值0.5求角度; //已知两个点的坐标计算出两点之间的角度 var $point1:Point = new Point(100,100); var $point2:Point = new Point(200,200); var angle:Number = Math.atan2($point2.y - $point1.y,$point2.x - $point1.x) * 180 / Math.PI; if (angle < 0) { angle = angle + 360;//限制角度在[0,360]范围; } trace(angle)
时间: 2024-10-09 06:42:31