Fix broken tests that I forgot to update.
This commit is contained in:
parent
f4b7767198
commit
79b9bd5f49
|
@ -9,6 +9,7 @@ pub mod hilbert {
|
||||||
///
|
///
|
||||||
/// x: The x coordinate. Must be no greater than 2^16-1.
|
/// x: The x coordinate. Must be no greater than 2^16-1.
|
||||||
/// y: The y coordinate. Must be no greater than 2^16-1.
|
/// y: The y coordinate. Must be no greater than 2^16-1.
|
||||||
|
/// n: Basically the "resolution" of the curve, on one side.
|
||||||
///
|
///
|
||||||
/// Returns the hilbert curve index corresponding to the (x,y) coordinates given.
|
/// Returns the hilbert curve index corresponding to the (x,y) coordinates given.
|
||||||
pub fn encode(x: u32, y: u32, n: u32) -> u32 {
|
pub fn encode(x: u32, y: u32, n: u32) -> u32 {
|
||||||
|
@ -33,6 +34,7 @@ pub mod hilbert {
|
||||||
/// Convert hilbert curve index to (x,y).
|
/// Convert hilbert curve index to (x,y).
|
||||||
///
|
///
|
||||||
/// d: The hilbert curve index.
|
/// d: The hilbert curve index.
|
||||||
|
/// n: Basically the "resolution" of the curve, on one side.
|
||||||
///
|
///
|
||||||
/// Returns the (x, y) coords at the given index.
|
/// Returns the (x, y) coords at the given index.
|
||||||
pub fn decode(d: u32, n: u32) -> (u32, u32) {
|
pub fn decode(d: u32, n: u32) -> (u32, u32) {
|
||||||
|
@ -197,8 +199,8 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn hilbert_reversible() {
|
fn hilbert_reversible() {
|
||||||
let i = 0x4c8587a2;
|
let i = 0x4c8587a2;
|
||||||
let (x, y) = hilbert::decode(i);
|
let (x, y) = hilbert::decode(i, 1 << 16);
|
||||||
let i2 = hilbert::encode(x, y);
|
let i2 = hilbert::encode(x, y, 1 << 16);
|
||||||
|
|
||||||
assert_eq!(i, i2);
|
assert_eq!(i, i2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user