Packageflare.util
Classpublic class Maths

Utility methods for mathematics not found in the Math class.



Public Methods
 MethodDefined by
  
Constructor, throws an error if called, as this is an abstract class.
Maths
  
adjLog(x:Number, b:Number):Number
[static] Computes a zero-symmetric logarithm, with adjustment to values between zero and the logarithm base.
Maths
  
adjLogInterp(f:Number, min:Number, max:Number, b:Number):Number
[static] Computes a logarithmic interpolation between two values.
Maths
  
invAdjLogInterp(x:Number, min:Number, max:Number, b:Number):Number
[static] Computes an inverse logarithmic interpolation, returning an interpolation fraction.
Maths
  
invLinearInterp(x:Number, min:Number, max:Number):Number
[static] Computes an inverse linear interpolation, returning an interpolation fraction.
Maths
  
invLogInterp(x:Number, min:Number, max:Number, b:Number):Number
[static] Computes an inverse logarithmic interpolation, returning an interpolation fraction.
Maths
  
invQuantileInterp(x:Number, quantiles:Array):Number
[static] Computes an inverse quantile scale interpolation, returning an interpolation fraction.
Maths
  
invRootInterp(x:Number, min:Number, max:Number, p:Number):Number
[static] Computes an inverse Nth-root interpolation, returning an interpolation fraction.
Maths
  
invSqrtInterp(x:Number, min:Number, max:Number):Number
[static] Computes an inverse square root interpolation, returning an interpolation fraction.
Maths
  
linearInterp(f:Number, min:Number, max:Number):Number
[static] Computes a linear interpolation between two values.
Maths
  
log(x:Number, base:Number):Number
[static] Returns the logarithm with a given base value.
Maths
  
logCeil(x:Number, base:Number):Number
[static] Rounds an input value up according to its logarithm.
Maths
  
logFloor(x:Number, base:Number):Number
[static] Rounds an input value down according to its logarithm.
Maths
  
logInterp(f:Number, min:Number, max:Number, b:Number):Number
[static] Computes a logarithmic interpolation between two values.
Maths
  
noise(x:Number, y:Number = 0, z:Number = 0):Number
[static] Computes Perlin noise for a given (x, y, z) point.
Maths
  
quantile(n:uint, values:Array, sort:Boolean):Array
[static] Computes the n-quantile boundaries for a set of values.
Maths
  
quantileInterp(f:Number, quantiles:Array):Number
[static] Computes an interpolated value in a quantile scale.
Maths
  
rootInterp(f:Number, min:Number, max:Number, p:Number):Number
[static] Computes an Nth-root interpolation between two values.
Maths
  
sqrtInterp(f:Number, min:Number, max:Number):Number
[static] Computes a square root interpolation between two values.
Maths
  
symLog(x:Number, b:Number):Number
[static] Computes a zero-symmetric logarithm.
Maths
  
symRoot(x:Number, p:Number):Number
[static] Computes a zero-symmetric Nth root.
Maths
  
symSqrt(x:Number):Number
[static] Computes a zero-symmetric square root.
Maths
Constructor detail
Maths()constructor
public function Maths()

Constructor, throws an error if called, as this is an abstract class.

Method detail
adjLog()method
public static function adjLog(x:Number, b:Number):Number

Computes a zero-symmetric logarithm, with adjustment to values between zero and the logarithm base. This adjustment introduces distortion for values less than the base number, but enables simultaneous plotting of log-transformed data involving both positive and negative numbers.

Parameters
x:Number — the number for which to compute the logarithm
 
b:Number — the base of the logarithm

Returns
Number — the adjusted, symmetric log value.
adjLogInterp()method 
public static function adjLogInterp(f:Number, min:Number, max:Number, b:Number):Number

Computes a logarithmic interpolation between two values. Uses an adjusted zero-symmetric logarithm calculation (see adjLog).

Parameters
f:Number — the interpolation fraction (typically between 0 and 1)
 
min:Number — the minimum value (corresponds to f==0)
 
max:Number — the maximum value (corresponds to f==1)
 
b:Number — the base of the logarithm

Returns
Number — the interpolated value
invAdjLogInterp()method 
public static function invAdjLogInterp(x:Number, min:Number, max:Number, b:Number):Number

Computes an inverse logarithmic interpolation, returning an interpolation fraction. Uses an adjusted zero-symmetric logarithm. Returns 0.5 if the min and max values are the same.

Parameters
x:Number — the interpolated value
 
min:Number — the minimum value (corresponds to f==0)
 
max:Number — the maximum value (corresponds to f==1)
 
b:Number — the base of the logarithm

Returns
Number — the inferred interpolation fraction
invLinearInterp()method 
public static function invLinearInterp(x:Number, min:Number, max:Number):Number

Computes an inverse linear interpolation, returning an interpolation fraction. Returns 0.5 if the min and max values are the same.

Parameters
x:Number — the interpolated value
 
min:Number — the minimum value (corresponds to f==0)
 
max:Number — the maximum value (corresponds to f==1)

Returns
Number — the inferred interpolation fraction
invLogInterp()method 
public static function invLogInterp(x:Number, min:Number, max:Number, b:Number):Number

Computes an inverse logarithmic interpolation, returning an interpolation fraction. Uses a zero-symmetric logarithm. Returns 0.5 if the min and max values are the same.

Parameters
x:Number — the interpolated value
 
min:Number — the minimum value (corresponds to f==0)
 
max:Number — the maximum value (corresponds to f==1)
 
b:Number — the base of the logarithm

Returns
Number — the inferred interpolation fraction
invQuantileInterp()method 
public static function invQuantileInterp(x:Number, quantiles:Array):Number

Computes an inverse quantile scale interpolation, returning an interpolation fraction.

Parameters
x:Number — the interpolated value
 
quantiles:Array — an array of quantile boundaries

Returns
Number — the inferred interpolation fraction
invRootInterp()method 
public static function invRootInterp(x:Number, min:Number, max:Number, p:Number):Number

Computes an inverse Nth-root interpolation, returning an interpolation fraction. Uses a zero-symmetric root. Returns 0.5 if the min and max values are the same.

Parameters
x:Number — the interpolated value
 
min:Number — the minimum value (corresponds to f==0)
 
max:Number — the maximum value (corresponds to f==1)
 
p:Number — the root value (2 for square root, 3 for cubic root, etc)

Returns
Number — the inferred interpolation fraction
invSqrtInterp()method 
public static function invSqrtInterp(x:Number, min:Number, max:Number):Number

Computes an inverse square root interpolation, returning an interpolation fraction. Uses a zero-symmetric square root. Returns 0.5 if the min and max values are the same.

Parameters
x:Number — the interpolated value
 
min:Number — the minimum value (corresponds to f==0)
 
max:Number — the maximum value (corresponds to f==1)

Returns
Number — the inferred interpolation fraction
linearInterp()method 
public static function linearInterp(f:Number, min:Number, max:Number):Number

Computes a linear interpolation between two values.

Parameters
f:Number — the interpolation fraction (typically between 0 and 1)
 
min:Number — the minimum value (corresponds to f==0)
 
max:Number — the maximum value (corresponds to f==1)

Returns
Number — the interpolated value
log()method 
public static function log(x:Number, base:Number):Number

Returns the logarithm with a given base value.

Parameters
x:Number — the number for which to compute the logarithm
 
base:Number — the base of the logarithm

Returns
Number — the logarithm value
logCeil()method 
public static function logCeil(x:Number, base:Number):Number

Rounds an input value up according to its logarithm. The method takes the ceiling of the logarithm of the value and then uses the resulting value as an exponent for the base value. For example: trace(Maths.logCeil(13,10)); // prints "100" trace(Maths.logCeil(113,10)); // prints "1000"

Parameters
x:Number — the number for which to compute the logarithm ceiling
 
base:Number — the base of the logarithm

Returns
Number — the rounded-by-logarithm value
logFloor()method 
public static function logFloor(x:Number, base:Number):Number

Rounds an input value down according to its logarithm. The method takes the floor of the logarithm of the value and then uses the resulting value as an exponent for the base value. For example: trace(Maths.logFloor(13,10)); // prints "10" trace(Maths.logFloor(113,10)); // prints "100"

Parameters
x:Number — the number for which to compute the logarithm floor
 
base:Number — the base of the logarithm

Returns
Number — the rounded-by-logarithm value
logInterp()method 
public static function logInterp(f:Number, min:Number, max:Number, b:Number):Number

Computes a logarithmic interpolation between two values. Uses a zero-symmetric logarithm calculation (see symLog).

Parameters
f:Number — the interpolation fraction (typically between 0 and 1)
 
min:Number — the minimum value (corresponds to f==0)
 
max:Number — the maximum value (corresponds to f==1)
 
b:Number — the base of the logarithm

Returns
Number — the interpolated value
noise()method 
public static function noise(x:Number, y:Number = 0, z:Number = 0):Number

Computes Perlin noise for a given (x, y, z) point.

Parameters
x:Number — the x parameter
 
y:Number (default = 0) — the y parameter (default 0)
 
z:Number (default = 0) — the z parameter (default 0)

Returns
Number — Perlin noise for the input co-ordinates
quantile()method 
public static function quantile(n:uint, values:Array, sort:Boolean):Array

Computes the n-quantile boundaries for a set of values.

Parameters
n:uint — the number of quantiles
 
values:Array — the values to break into quantiles
 
sort:Boolean — indicates if the values array needs to be sorted. If true, the array will be sorted prior to determining quantile boundaries. If false, the array must be in ascending sort order.

Returns
Array — an n-length array of quantile boundaries
quantileInterp()method 
public static function quantileInterp(f:Number, quantiles:Array):Number

Computes an interpolated value in a quantile scale.

Parameters
f:Number — the interpolation fraction (typically between 0 and 1)
 
quantiles:Array — an array of quantile boundaries

Returns
Number — the interpolated value
rootInterp()method 
public static function rootInterp(f:Number, min:Number, max:Number, p:Number):Number

Computes an Nth-root interpolation between two values. Uses a zero-symmetric root calculation (see symRoot).

Parameters
f:Number — the interpolation fraction (typically between 0 and 1)
 
min:Number — the minimum value (corresponds to f==0)
 
max:Number — the maximum value (corresponds to f==1)
 
p:Number — the root value (2 for square root, 3 for cubic root, etc)

Returns
Number — the interpolated value
sqrtInterp()method 
public static function sqrtInterp(f:Number, min:Number, max:Number):Number

Computes a square root interpolation between two values. Uses a zero-symmetric root calculation (see symSqrt).

Parameters
f:Number — the interpolation fraction (typically between 0 and 1)
 
min:Number — the minimum value (corresponds to f==0)
 
max:Number — the maximum value (corresponds to f==1)

Returns
Number — the interpolated value
symLog()method 
public static function symLog(x:Number, b:Number):Number

Computes a zero-symmetric logarithm. Computes the logarithm of the absolute value of the input, and determines the sign of the output according to the sign of the input value.

Parameters
x:Number — the number for which to compute the logarithm
 
b:Number — the base of the logarithm

Returns
Number — the symmetric log value.
symRoot()method 
public static function symRoot(x:Number, p:Number):Number

Computes a zero-symmetric Nth root. Computes the root of the absolute value of the input, and determines the sign of the output according to the sign of the input value.

Parameters
x:Number — the number for which to compute the square root
 
p:Number — the root value (2 for square root, 3 for cubic root, etc)

Returns
Number — the symmetric Nth root value.
symSqrt()method 
public static function symSqrt(x:Number):Number

Computes a zero-symmetric square root. Computes the square root of the absolute value of the input, and determines the sign of the output according to the sign of the input value.

Parameters
x:Number — the number for which to compute the square root

Returns
Number — the symmetric square root value.