public final class Mer extends java.lang.Object implements java.io.Serializable, RNode
>=
lower bound for each dimension.
A standard empty Mer as created by the Mer(int)
constructor have POSITIVE_INFINITY for its lower bounds and
NEGATIVE_INFINITY for its upper bounds (inverted relationship). All Mers used or output by this code are either
non-empty or the standard empty Mer.
Constructor and Description |
---|
Mer(double[] arrayMer)
Create a Mer from a bare array.
|
Mer(double[] arrayMer,
boolean deepCopy)
Create a Mer from a bare array.
|
Mer(int dim)
Create a mer that contains nothing; it can be extended into a real mer.
|
Mer(Mer m)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
covers(double[] firstMer,
double[] queryMer)
Test if the query mer is completely covered by the first mer
|
boolean |
covers(Mer query)
Return true if this Mer completely covers the query mer.
|
int |
dim()
Return the dimension of this mer.
|
static double |
distance(double[] merA,
double[] merB)
Return the Euclidean distance between two mers.
|
double |
distance(Mer targetMer)
Return the Euclidean distance from this mer to targetMer.
|
static double |
distance2(double[] merA,
double[] merB)
Return square of the Euclidean distance between two mers.
|
double |
distance2(Mer targetMer)
Return square of the Euclidean distance from this mer to targetMer.
|
static double[] |
emptyMer(int dim)
Create a new, standard empty mer of dimension dim.
|
void |
extend(double[] pt)
Extend this mer to include pt.
|
static double[] |
extend(double[] target,
double[] ptMer)
Extend a target MER to include a new MER or a new point.
|
static double[] |
extend(double[] target,
JPoint2DD pt)
Extend a 2D target MER to include a new MER or a new point.
|
void |
extend(JPoint2DD pt)
Extend this mer to include pt.
|
void |
extend(Mer m)
Extend this mer to include m.
|
double[] |
getArray()
Returns the mer as array - changing the returned array results in undefined behavior.
|
Mer |
getMer()
Returns the bounding box of this spatial object.
|
double[][] |
getRanges()
Create and return a copy of the mer is an array of ranges,
{
{min x, max x},
{min y, max y}, etc. |
static double[] |
infiniteMer(int dim)
Create a new mer that covers the universe (infinite extent).
|
boolean |
interacts(double[] pt)
Return true if pt touches or is inside this mer.
|
static boolean |
interacts(double[] target,
double[] ptOrMer)
Test if the point or mer touches the target mer.
|
static boolean |
interacts(double[] target,
double[] ptMer,
double tol)
Test if the point or mer touches the target mer + tolerance.
|
static boolean |
interacts(double[] target,
JPoint2DD pt)
Test if the 2D MER contains the given point.
|
boolean |
interacts(JPoint2DD pt)
Return true if pt touches or is inside this mer.
|
boolean |
interacts(Mer target)
Return true if target touches or is inside this mer.
|
boolean |
interacts(Mer target,
double tol)
Return true if target touches or is inside this mer.
|
static boolean |
interactsTile(double[] tileMer,
JPoint2DD pt)
Test if the 2D MER contains the given point, excluding the right and bottom edges of the mer.
|
boolean |
interactsTile(JPoint2DD pt)
Return true if pt is inside this mer, or touches the top or left edge.
|
boolean |
isEmpty()
Test whether this Mer is empty.
|
static boolean |
isEmpty(double[] mer)
Test whether a Mer is empty.
|
java.lang.String |
toString() |
public Mer(int dim)
dim
- public Mer(double[] arrayMer)
Mer(double[], boolean)
arrayMer
- public Mer(double[] arrayMer, boolean deepCopy)
arrayMer
- deepCopy
- public Mer(Mer m)
m
- public static final double[] extend(double[] target, double[] ptMer)
target
- the mer to extend (modified by this call).ptMer
- the pt/mer to be included (if size dim, is a point; if size dim*2, is a MER).public static final double[] extend(double[] target, JPoint2DD pt)
target
- the 2D mer to extend (modified by this call).pt
- the pt/mer to be included (if size dim, is a point; if size dim*2, is a MER).public static final boolean interacts(double[] target, double[] ptOrMer)
target
- ptOrMer
- point if size = dim, mer if size = 2*dimpublic static final boolean covers(double[] firstMer, double[] queryMer)
firstMer
- queryMer
- public static final boolean interacts(double[] target, double[] ptMer, double tol)
target
- ptMer
- tol
- effectively expands (shrinks, if negative) the mer in all dimensions by this tolerancepublic static final boolean interacts(double[] target, JPoint2DD pt)
target
- pt
- public static final boolean interactsTile(double[] tileMer, JPoint2DD pt)
tileMer
- pt
- public static final boolean isEmpty(double[] mer)
Mer(int)
constructor constructs an empty Mer with lower bounds of positibve infinity and
upper bounds of negative infinity.public static final double[] emptyMer(int dim)
dim
- the dimension to createpublic static final double[] infiniteMer(int dim)
To create a correspoinding Mer object, use new Mer(Mer.infiniteMer(dim))
dim
- the dimension to createpublic static final double distance2(double[] merA, double[] merB)
Mer(int)
is infinite distance
from any other Mer; other non-standard empty Mers will provide unexpected results.merA
- first MermerB
- second Merpublic static final double distance(double[] merA, double[] merB)
Mer(int)
is infinite distance
from any other Mer; other non-standard empty Mers will provide unexpected results.merA
- first MermerB
- second Merpublic double[] getArray()
public double[][] getRanges()
{
{min x, max x},
{min y, max y}, etc.
}
public final void extend(Mer m)
m
- public final void extend(JPoint2DD pt)
pt
- public final void extend(double[] pt)
pt
- public final boolean interacts(double[] pt)
pt
- public final boolean interacts(JPoint2DD pt)
pt
- public final boolean interacts(Mer target)
target
- public final boolean interacts(Mer target, double tol)
target
- tol
- effectively expands (shrinks, if negative) this mer in all dimensions by this tolerancepublic final boolean interactsTile(JPoint2DD pt)
pt
- public final boolean isEmpty()
Mer(int)
constructor constructs an empty Mer with lower bounds of positibve infinity and
upper bounds of negative infinity.public final int dim()
public final boolean covers(Mer query)
query
- mer to testpublic final double distance2(Mer targetMer)
Mer(int)
is infinite distance
from any other Mer; other non-standard empty Mers will provide unexpected results.targetMer
- the other Merpublic final double distance(Mer targetMer)
Mer(int)
is infinite distance
from any other Mer; other non-standard empty Mers will provide unexpected results.targetMer
- the other merpublic java.lang.String toString()
toString
in class java.lang.Object