Methods Summary |
---|
public static double | abs(double num)The math:abs function returns the absolute value of a number.
return Math.abs(num);
|
public static double | acos(double num)The math:acos function returns the arccosine value of a number.
return Math.acos(num);
|
public static double | asin(double num)The math:asin function returns the arcsine value of a number.
return Math.asin(num);
|
public static double | atan(double num)The math:atan function returns the arctangent value of a number.
return Math.atan(num);
|
public static double | atan2(double num1, double num2)The math:atan2 function returns the angle ( in radians ) from the X axis to a point (y,x).
return Math.atan2(num1, num2);
|
public static double | constant(java.lang.String name, double precision)The math:constant function returns the specified constant to a set precision.
The possible constants are:
PI
E
SQRRT2
LN2
LN10
LOG2E
SQRT1_2
String value = null;
if (name.equals("PI"))
value = PI;
else if (name.equals("E"))
value = E;
else if (name.equals("SQRRT2"))
value = SQRRT2;
else if (name.equals("LN2"))
value = LN2;
else if (name.equals("LN10"))
value = LN10;
else if (name.equals("LOG2E"))
value = LOG2E;
else if (name.equals("SQRT1_2"))
value = SQRT1_2;
if (value != null)
{
int bits = new Double(precision).intValue();
if (bits <= value.length())
value = value.substring(0, bits);
return new Double(value).doubleValue();
}
else
return Double.NaN;
|
public static double | cos(double num)The math:cos function returns cosine of the passed argument.
return Math.cos(num);
|
public static double | exp(double num)The math:exp function returns e (the base of natural logarithms) raised to a power.
return Math.exp(num);
|
public static org.w3c.dom.NodeList | highest(org.w3c.dom.NodeList nl)The math:highest function returns the nodes in the node set whose value is the maximum
value for the node set. The maximum value for the node set is the same as the value as
calculated by math:max. A node has this maximum value if the result of converting its
string value to a number as if by the number function is equal to the maximum value,
where the equality comparison is defined as a numerical comparison using the = operator.
If any of the nodes in the node set has a non-numeric value, the math:max function will
return NaN. The definition numeric comparisons entails that NaN != NaN. Therefore if any
of the nodes in the node set has a non-numeric value, math:highest will return an empty
node set.
double maxValue = max(nl);
NodeSet highNodes = new NodeSet();
highNodes.setShouldCacheNodes(true);
if (Double.isNaN(maxValue))
return highNodes; // empty Nodeset
for (int i = 0; i < nl.getLength(); i++)
{
Node n = nl.item(i);
double d = toNumber(n);
if (d == maxValue)
highNodes.addElement(n);
}
return highNodes;
|
public static double | log(double num)The math:log function returns the natural logarithm of a number.
return Math.log(num);
|
public static org.w3c.dom.NodeList | lowest(org.w3c.dom.NodeList nl)The math:lowest function returns the nodes in the node set whose value is the minimum value
for the node set. The minimum value for the node set is the same as the value as calculated
by math:min. A node has this minimum value if the result of converting its string value to
a number as if by the number function is equal to the minimum value, where the equality
comparison is defined as a numerical comparison using the = operator.
If any of the nodes in the node set has a non-numeric value, the math:min function will return
NaN. The definition numeric comparisons entails that NaN != NaN. Therefore if any of the nodes
in the node set has a non-numeric value, math:lowest will return an empty node set.
double minValue = min(nl);
NodeSet lowNodes = new NodeSet();
lowNodes.setShouldCacheNodes(true);
if (Double.isNaN(minValue))
return lowNodes; // empty Nodeset
for (int i = 0; i < nl.getLength(); i++)
{
Node n = nl.item(i);
double d = toNumber(n);
if (d == minValue)
lowNodes.addElement(n);
}
return lowNodes;
|
public static double | max(org.w3c.dom.NodeList nl)The math:max function returns the maximum value of the nodes passed as the argument.
The maximum value is defined as follows. The node set passed as an argument is sorted
in descending order as it would be by xsl:sort with a data type of number. The maximum
is the result of converting the string value of the first node in this sorted list to
a number using the number function.
If the node set is empty, or if the result of converting the string values of any of the
nodes to a number is NaN, then NaN is returned.
if (nl == null || nl.getLength() == 0)
return Double.NaN;
double m = - Double.MAX_VALUE;
for (int i = 0; i < nl.getLength(); i++)
{
Node n = nl.item(i);
double d = toNumber(n);
if (Double.isNaN(d))
return Double.NaN;
else if (d > m)
m = d;
}
return m;
|
public static double | min(org.w3c.dom.NodeList nl)The math:min function returns the minimum value of the nodes passed as the argument.
The minimum value is defined as follows. The node set passed as an argument is sorted
in ascending order as it would be by xsl:sort with a data type of number. The minimum
is the result of converting the string value of the first node in this sorted list to
a number using the number function.
If the node set is empty, or if the result of converting the string values of any of
the nodes to a number is NaN, then NaN is returned.
if (nl == null || nl.getLength() == 0)
return Double.NaN;
double m = Double.MAX_VALUE;
for (int i = 0; i < nl.getLength(); i++)
{
Node n = nl.item(i);
double d = toNumber(n);
if (Double.isNaN(d))
return Double.NaN;
else if (d < m)
m = d;
}
return m;
|
public static double | power(double num1, double num2)The math:power function returns the value of a base expression taken to a specified power.
return Math.pow(num1, num2);
|
public static double | random()The math:random function returns a random number from 0 to 1.
return Math.random();
|
public static double | sin(double num)The math:sin function returns the sine of the number.
return Math.sin(num);
|
public static double | sqrt(double num)The math:sqrt function returns the square root of a number.
return Math.sqrt(num);
|
public static double | tan(double num)The math:tan function returns the tangent of the number passed as an argument.
return Math.tan(num);
|