-
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(morton): fix tree coord conversion fns, add tests
- Loading branch information
1 parent
a6ec36a
commit 9a23fa2
Showing
2 changed files
with
47 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
// import * as assert from "assert"; | ||
// import * as m from "../src/index"; | ||
import * as assert from "assert"; | ||
import { | ||
cartesianToTree, | ||
treeToCartesian, | ||
treeToMorton, | ||
mortonToTree, | ||
} from "../src/index"; | ||
|
||
describe("morton", () => { | ||
it("tests pending"); | ||
it("tree <> cartesian3 fuzz", function () { | ||
this.timeout(10000); | ||
const M = 1 << 11; | ||
const $ = () => (1 + Math.random() * M) | 0; | ||
for (let i = 0; i < 1e5; i++) { | ||
const p = [$(), $(), $()]; | ||
const tree = cartesianToTree(p); | ||
const morton = treeToMorton(tree, 3); | ||
assert.deepEqual(mortonToTree(morton, 3), tree, "m2t"); | ||
assert.deepEqual(treeToCartesian(tree, 3), p, "t2c"); | ||
} | ||
}); | ||
}); |