public final class HilbertCurve extends Object
BigInteger
) and N-dimensional points.
Note: This algorithm is derived from work done by John Skilling and published in "Programming the Hilbert curve". (c) 2004 American Institute of Physics. With thanks also to Paul Chernoch who published a C# algorithm for Skilling's work on StackOverflow and GitHub).
Modifier and Type | Class and Description |
---|---|
static class |
HilbertCurve.Builder
Builds a
HilbertCurve instance. |
Modifier and Type | Method and Description |
---|---|
static HilbertCurve.Builder |
bits(int bits)
Returns a builder for and object that performs transformations for a
Hilbert curve with the given number of bits.
|
BigInteger |
index(long... point)
Converts a point to its Hilbert curve index.
|
long[] |
point(BigInteger index)
Converts a
BigInteger index (distance along the Hilbert Curve
from 0) to a point of dimensions defined in the constructor of
this . |
long[] |
point(long index)
Converts a
long index (distance along the Hilbert Curve from 0)
to a point of dimensions defined in the constructor of this . |
static SmallHilbertCurve.Builder |
small() |
public static HilbertCurve.Builder bits(int bits)
bits
- depth of the Hilbert curve. If bits is one, this is the
top-level Hilbert curvepublic static SmallHilbertCurve.Builder small()
public BigInteger index(long... point)
point
- an array of long
. Each coordinate can be between 0 and
2bits-1.BigInteger
)IllegalArgumentException
- if length of point array is not equal to the number of
dimensions.public long[] point(BigInteger index)
BigInteger
index (distance along the Hilbert Curve
from 0) to a point of dimensions defined in the constructor of
this
.index
- index along the Hilbert Curve from 0. Maximum value 2
bits * dimensions-1.NullPointerException
- if index is nullIllegalArgumentException
- if index is negativepublic long[] point(long index)
long
index (distance along the Hilbert Curve from 0)
to a point of dimensions defined in the constructor of this
.index
- index along the Hilbert Curve from 0. Maximum value 2
bits+1-1.IllegalArgumentException
- if index is negativeCopyright © 2013–2017. All rights reserved.