public final class MathUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static float[] |
add(float[] v1,
float[] v2)
Adds two N-D vectors.
|
static boolean |
areDifferent(float[] a,
float[] b)
Tests whether two arrays of floats are different.
|
static boolean |
areOpposite(float[] v1,
float[] v2)
Tests whether two vectors are coordinate-wise opposite.
|
static boolean |
areSame(float[] a,
float[] b)
Tests whether two arrays of floats are identical.
|
static float[] |
computePtOnSegment(float[] a,
float[] b,
float weight)
Computes a point along the line segment a[]-b[] based on the parameter
weight.
|
static float |
cross2D(float[] v1,
float[] v2)
Computes the cross product of two 2D vectors.
|
static float |
dot(float[] a,
float[] b)
Computes the dot product of two N-D vectors.
|
static double |
getDistance(double[] p,
double[] v)
Computes the minimum distance between the point p and the point v.
|
static double |
getDistance(double[] p,
double[] q,
double[] m)
Gets the distance between the points p and q, using the given conversion
values between pixels and microns.
|
static double |
getDistance(double[] a,
double[] b,
double[] v,
boolean segment)
Computes the minimum distance between the point v and the line a-b.
|
static double |
getDistance(float[] p,
float[] v)
Computes the minimum distance between the point p and the point v in double
precision.
|
static double[] |
getDistSegWt(double[][] nodes,
double x,
double y)
Gets distance to a curve of points connected by straight line segments.
|
static double[] |
getDistSegWt(float[][] nodes,
float x,
float y)
Gets distance to a curve of points connected by straight line segments.
|
static int |
getNearest(double val,
int min,
int max,
int step)
Rounds the value to nearest value along the given progression.
|
static double[] |
getProjection(double[] a,
double[] b,
double[] v,
boolean segment)
Computes the projection of the point v onto the line segment a-b.
|
static float[] |
getRightBisectorVector2D(float[] p1,
float[] p2,
float[] p3)
Gets a unit vector which bisects
(p1 - p2) and (p3 - p2). |
static float[] |
getRightPerpendicularVector2D(float[] p2,
float[] p1)
Gets a vector perpendicular to the vector
p2-p1, pointing to the
right with respect to the direction of p2-p1. |
static String |
getValueWithUnit(BigInteger value,
int places)
Returns the given number as a string complete with unit (e.g., kilo, mega,
etc.), to the specififed number of decimal places.
|
static boolean |
inside(float[] a,
float[] b1,
float[] b2)
Whether the point a is inside the N-D box implied by points b2 and b2
(i.e., in 2D, whether a is inside the box with diagonal b1-b2; in 3D,
whether a is inside the cube with diagonal b1-b2).
|
static float |
mag(float[] a)
Computes the magnitude of an N-D vector.
|
static float |
orient2D(float[] p1,
float[] p2,
float[] p3)
Obtains the z-coordinate of the cross product of the 2D vectors
p2-p1 and p3-p2, useful for determining whether the curve
p1->p2->p3 is curving to the right or left. |
static float[] |
scalarMultiply(float[] v,
float s)
Multiplies an N-D vector by a scalar.
|
static float[] |
unit(float[] v)
Computes the N-D unit vector in the direction of the vector supplied.
|
static float[] |
vector(float[] p2,
float[] p1)
Creates the vector p2-(minus) p1.
|
public static double getDistance(double[] p,
double[] q,
double[] m)
p - Coordinates of the first endpointq - Coordinates of the second endpointm - Conversion values between microns and pixelspublic static double getDistance(double[] a,
double[] b,
double[] v,
boolean segment)
a - Coordinates of the line's first endpointb - Coordinates of the line's second endpointv - Coordinates of the standalone pointsegment - Whether distance computation should be constrained to the
given line segmentpublic static double getDistance(double[] p,
double[] v)
p - Coordinates of the first pointv - Coordinates of the second pointpublic static double getDistance(float[] p,
float[] v)
p - Coordinates of the first pointv - Coordinates of the second pointpublic static double[] getProjection(double[] a,
double[] b,
double[] v,
boolean segment)
a - Coordinates of the segment's first endpointb - Coordinates of the segment's second endpointv - Coordinates of the point to be projectedsegment - Whether the projection should be constrained to the given
line segmentpublic static double[] getDistSegWt(double[][] nodes,
double x,
double y)
x - x coordinate of point in questiony - y coordinate of point in questionpublic static double[] getDistSegWt(float[][] nodes,
float x,
float y)
x - x coordinate of point in questiony - y coordinate of point in questionpublic static float[] computePtOnSegment(float[] a,
float[] b,
float weight)
public static int getNearest(double val,
int min,
int max,
int step)
public static String getValueWithUnit(BigInteger value, int places)
public static float cross2D(float[] v1,
float[] v2)
public static float[] unit(float[] v)
public static float dot(float[] a,
float[] b)
public static float mag(float[] a)
public static float[] vector(float[] p2,
float[] p1)
public static float[] add(float[] v1,
float[] v2)
public static float[] scalarMultiply(float[] v,
float s)
public static boolean areOpposite(float[] v1,
float[] v2)
public static boolean areSame(float[] a,
float[] b)
public static boolean areDifferent(float[] a,
float[] b)
public static boolean inside(float[] a,
float[] b1,
float[] b2)
public static float orient2D(float[] p1,
float[] p2,
float[] p3)
p2-p1 and p3-p2, useful for determining whether the curve
p1->p2->p3 is curving to the right or left.public static float[] getRightPerpendicularVector2D(float[] p2,
float[] p1)
p2-p1, pointing to the
right with respect to the direction of p2-p1.public static float[] getRightBisectorVector2D(float[] p1,
float[] p2,
float[] p3)
(p1 - p2) and (p3 - p2).
This vector points to the 'right' side of the line defined by
p1->p2->p3.Copyright © 2015–2022 SciJava. All rights reserved.