导航

  • 首页
  • Tags列表
  • 管理
  • 简繁转换
Search Engine Optimization 站外搜索 站内搜索
« 硬盘故障,ADSL错误代码表,Windows死机各种代码总结什么是iso感光度 »

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}
}
}

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Search



  • 互联网 站内搜索

最新留言

最近发表

站点统计

  • 文章总数:244
  • 评论总数:246
  • 引用总数:0
  • 浏览总数:380993
  • 当前样式:default
  • 当前语言:zh-CN

图标汇集

  • 订阅到抓虾
    新闻蚂蚁
    周博通
    订阅到狗狗
    google reader
    bloglines
    my yahoo
    newsgator
    netvibes
    Rojo
  • 通过 W3C XHTML 1.0 Transitional 校验
  • 通过 W3C CSS 校验
  • 订阅本站的 ATOM 1.0 新闻聚合
  • 订阅本站的 RSS 2.0 新闻聚合

Powered By Z-Blog 1.6 Final Build 60802

Copyright Yufuzi Some Rights Reserved.
E-mail:yufuzi80@126.com QQ:20168130
备案序号:苏ICP备06015492号