trig_functions_degrees.as

来自「这是《Flash MX编程与创意实现》的源代码」· AS 代码 · 共 46 行

AS
46
字号
/*
  Trigonometric Functions in Degrees
  Oct. 29, 2002
  (c) 2002 Robert Penner
  
  These are wrappers for the built-in Math functions
  (sin, cos, tan, and their inverses) that allow you
  to work with angles in degrees instead of radians.
  
  Discussed in Chapter 3 of 
  Robert Penner's Programming Macromedia Flash MX
  
  http://www.robertpenner.com/profmx
  http://www.amazon.com/exec/obidos/ASIN/0072223561/robertpennerc-20
*/

	
Math.sinD = function (angle) {
	return Math.sin (angle * (Math.PI / 180));
};

Math.cosD = function (angle) {
	return Math.cos (angle * (Math.PI / 180));
};

Math.tanD = function (angle) {
	return Math.tan (angle * (Math.PI / 180));
};

Math.asinD = function (ratio) {
	return Math.asin (ratio) * (180 / Math.PI);
};

Math.acosD = function (ratio) {
	return Math.acos (ratio) * (180 / Math.PI);
};

Math.atanD = function (ratio) {
	return Math.atan (ratio) * (180 / Math.PI);
};

Math.atan2D = function (y, x) {
	return Math.atan2 (y, x) * (180 / Math.PI);
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?