Packagejp.nium.utils
Classpublic final class MathUtil
InheritanceMathUtil Inheritance Object

MathUtil クラスは、算術演算のためのユーティリティクラスです。 MathUtil クラスを直接インスタンス化することはできません。 new MathUtil() コンストラクタを呼び出すと、ArgumentError 例外がスローされます。 The MathUtil class is an utility class for arithmetic operation. MathUtil class can not instanciate directly. When call the new MathUtil() constructor, the ArgumentError exception will be thrown.



Public Methods
 MethodDefined By
  
cycle(number:Number, cycle:Number):Number
[static] 数値を指定された周期内に収めて返します。 Returns the value of number put in the specified cycle.
MathUtil
  
even(number:Number):Boolean
[static] 数値が偶数かどうかを返します。 Returns if the value is even number.
MathUtil
  
percent(numerator:Number, denominator:Number):Number
[static] 分母が 0 の場合に 0 となるパーセント値を返します。 Returns the percent value (return 0 if the denominator is 0).
MathUtil
  
range(number:Number, min:Number, max:Number):Number
[static] 範囲内に適合する値を返します。 Returns the value suited within the range.
MathUtil
Method Detail
cycle()method
public static function cycle(number:Number, cycle:Number):Number

数値を指定された周期内に収めて返します。 Returns the value of number put in the specified cycle.

Parameters

number:Number周期内に収めたい数値です。 The value which want to put in the cycle.
 
cycle:Number周期となる数値です。 The cycle value.

Returns
Number変換後の数値です。 The translated value.

Example
         trace( MathUtil.cycle( 8, 10 ) ); // 8
         trace( MathUtil.cycle( 10, 10 ) ); // 0
         trace( MathUtil.cycle( 24, 10 ) ); // 4
         
even()method 
public static function even(number:Number):Boolean

数値が偶数かどうかを返します。 Returns if the value is even number.

Parameters

number:Numberテストしたい数値です。 The number to test.

Returns
Boolean偶数であれば true を、奇数であれば false を返します。 Returns true if the value is even number, otherwise return false.

Example
         trace( MathUtil.even( 1 ) ); // false
         trace( MathUtil.even( 2 ) ); // true
         trace( MathUtil.even( 3 ) ); // false
         
percent()method 
public static function percent(numerator:Number, denominator:Number):Number

分母が 0 の場合に 0 となるパーセント値を返します。 Returns the percent value (return 0 if the denominator is 0).

Parameters

numerator:Number分子となる数値です。 The numerator value.
 
denominator:Number分母となる数値です。 The denominator value.

Returns
Number変換後の数値です。 The translated value.

Example
         trace( MathUtil.percent( 100, 100 ) ); // 100
         trace( MathUtil.percent( 100, 200 ) ); // 50
         trace( MathUtil.percent( 200, 100 ) ); // 200
         
range()method 
public static function range(number:Number, min:Number, max:Number):Number

範囲内に適合する値を返します。 Returns the value suited within the range.

Parameters

number:Number範囲内に適合させたい数値です。 The number which wanted to suit within the range.
 
min:Number範囲の最小値となる数値です。 The mininum value of the range.
 
max:Number範囲の最大値となる数値です。 The maximum value of the range.

Returns
Number変換後の数値です。 The translated value.

Example
         trace( MathUtil.range( 0, 10, 30 ) ); // 10
         trace( MathUtil.range( 20, 10, 30 ) ); // 20
         trace( MathUtil.range( 40, 10, 30 ) ); // 30