补全的myMath类 class myMath{ /*用角度制*/ static function sinD(angle:Number):Number { return Math.sin (angle * (Math.PI / 180)); } static function cosD(angle:Number):Number { return Math.cos (angle * (Math.PI / 180)); } static function tanD(angle:Number):Number { return Math.tan (angle * (Math.PI / 180)); } static function asinD(ratio:Number):Number { return Math.asin (ratio) * (180 / Math.PI); } static function acosD(ratio:Number):Number{ return Math.acos (ratio) * (180 / Math.PI); } static function atanD(ratio:Number):Number { return Math.atan (ratio) * (180 / Math.PI); } static function atan2D(y:Number, x:Number):Number { return Math.atan2 (y, x) * (180 / Math.PI); } /*求两点间距离*/ static function distance(x1:Number, y1:Number, x2:Number, y2:Number):Number{ var dx:Number = x2 - x1; var dy:Number = y2 - y1; return Math.sqrt (dx*dx + dy*dy); } /*计算两点间连线的倾斜角*/ static function angleOfLine(x1:Number, y1:Number, x2:Number, y2:Number):Number { return atan2D (y2 - y1, x2 - x1); } /*度转换为弧度*/ static function degreesToRadians(angle:Number):Number { return angle * (Math.PI / 180); } /*弧度转换为度*/ static function radiansToDegrees(angle:Number):Number { return angle * (180 / Math.PI); } /*将一个角度转化为在0~360度之间*/ static function fixAngle(angle:Number):Number { angle %= 360; return (angle < 0) ? angle + 360 : angle; } /*将笛卡尔坐标系转化为极坐标系,p为点对象*/ static function cartesianToPolar (p:Object):Object { var radius:Number = Math.sqrt (p.x*p.x + p.y*p.y); var theta:Number = atan2D (p.y, p.x); return {r:radius, t:theta} } /*将极坐标系转化为笛卡尔坐标系*/ static function polarToCartesian(p:Object):Object{ var x:Number = p.r * cosD (p.t); var y:Number = p.r * sinD (p.t); return {x:x, y:y} } } |
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |