pnuts.math module

The pnuts.math module defines functions for the basic numeric operations which are defined in java.lang.Math class. See API document for more detail.

sin ( double d )

Returns the trigonometric sine of an angle.

cos ( double d )

Returns the trigonometric cosine of an angle.

tan ( double d )

Returns the trigonometric tangent of an angle.

asin ( double d )

Returns the arc sine of an angle, in the range of -pi/2 through pi/2.

acos ( double d )

Returns the arc cosine of an angle, in the range of 0.0 through pi.

atan ( double d )

Returns the arc tangent of an angle, in the range of -pi/2 through pi/2.

atan2 ( double d1 , double d2 )

Converts rectangular coordinates (xy) to polar (r, theta). This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi.

toRadians ( double d )

Converts an angle measured in degrees to an approximately equivalent angle measured in radians. The conversion from degrees to radians is generally inexact.

toDegrees ( double d )

Converts an angle measured in radians to an approximately equivalent angle measured in degrees. The conversion from radians to degrees is generally inexact; users should not expect cos(toRadians(90.0)) to exactly equal 0.0.

exp ( double d )

Returns Euler's number e raised to the power of a double value.

log ( double d )

Returns the natural logarithm (base e) of a double value.

sqrt ( double d )

Returns the correctly rounded positive square root of a double value.

IEEEremainder ( double d1, double d2 )

Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard. The remainder value is mathematically equal to f1 - f2 × n, where n is the mathematical integer closest to the exact mathematical value of the quotient f1/f2, and if two mathematical integers are equally close to f1/f2, then n is the integer that is even. If the remainder is zero, its sign is the same as the sign of the first argument.

ceil ( double d )

Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.

floor ( double d )

Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.

rint ( double d )

Returns the double value that is closest in value to the argument and is equal to a mathematical integer. If two double values that are mathematical integers are equally close, the result is the integer value that is even.

pow ( double d1 , double d2)

Returns the value of the first argument raised to the power of the second argument.

round ( double d )

Returns the closest int to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type int. In other words, the result is equal to the value of the expression:

floor(a + 0.5)
abs ( Number d )

Returns the absolute value of the specified number. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.

max ( num1, num2 ) or
( collectionOrArray {, comparator | f(arg) })

Returns the greater of two numbers.

If a Collection object or an array is specified as the 1st argument, this function returns the maximum element of the Collection/Array object. The optional 2nd argument is used for comparing the elements.

max([1,2,-6,4], abs)  -> -6
min ( num1, num2 ) or
( collectionOrArray {, comparator | f(arg) })

Returns the smaller of two numbers.

If a Collection object or an array is specified as the 1st argument, this function returns the minimum element of the Collection/Array object. The optional 2nd argument is used for comparing the elements.

min([1,2,-6,4], abs)  -> 1