public class MathUtil extends Object
| Constructor and Description |
|---|
MathUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
bound(int low,
int value,
int high)
Bounds the supplied value within the specified range.
|
static int |
choose(int n,
int k)
Computes (N choose K), the number of ways to select K different elements from a set of size
N.
|
static float |
distance(int x0,
int y0,
int x1,
int y1)
Return the distance between the given points.
|
static float |
distance(Point source,
Point dest)
Return the distance between the given points.
|
static int |
distanceSq(int x0,
int y0,
int x1,
int y1)
Return the squared distance between the given points.
|
static double |
ellipseCircum(double a,
double b)
Returns the approximate circumference of the ellipse defined by the specified minor and
major axes.
|
static int |
floorDiv(int dividend,
int divisor)
Computes the floored division
dividend/divisor which
is useful when dividing potentially negative numbers into bins. |
static String |
lineToString(int x0,
int y0,
int x1,
int y1)
Return a string representation of the given line.
|
static String |
lineToString(Point p1,
Point p2)
Return a string representation of the given line.
|
static int |
sign(int value)
Returns positive 1 if the sign of the argument is positive, or -1 if the sign of the
argument is negative.
|
static float[] |
stddev(int[] values,
int start,
int length)
Computes the standard deviation of the supplied values.
|
public static int bound(int low,
int value,
int high)
value < low, high if value > high and value otherwise.public static int distanceSq(int x0,
int y0,
int x1,
int y1)
public static float distance(int x0,
int y0,
int x1,
int y1)
public static float distance(Point source, Point dest)
public static String lineToString(int x0, int y0, int x1, int y1)
public static String lineToString(Point p1, Point p2)
public static double ellipseCircum(double a,
double b)
Pi(3a + 3b - sqrt[(a+3b)(b+3a)]).public static int sign(int value)
public static int floorDiv(int dividend,
int divisor)
dividend/divisor which
is useful when dividing potentially negative numbers into bins.
For example, the following numbers floorDiv 10 are:
-15 -10 -8 -2 0 2 8 10 15 -2 -1 -1 -1 0 0 0 1 1
public static float[] stddev(int[] values,
int start,
int length)
public static int choose(int n,
int k)
Copyright © 2015. All rights reserved.