Skip to content

Commit

Permalink
Fixed issue with extreme high percentile noise samples
Browse files Browse the repository at this point in the history
  • Loading branch information
clexmond committed Aug 26, 2024
1 parent 07ee8bf commit d396727
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@influenceth/sdk",
"version": "2.3.0",
"version": "2.3.1",
"description": "Influence SDK",
"type": "module",
"module": "./build/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/simplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export const percentileByOctaves = (noise, octaves) => {
const raws = SIMPLEX_OCTAVES[octaves].find((b) => BigInt(Math.round(noiseArg * 2 ** 32)) < b[0]);
const [ limit, whole, low, high ] = raws.map((n) => Number(n) / 2 ** 32);

if (whole === 0 && noiseArg <= low) return 0;
if (whole === 0 && noiseArg <= low) noiseArg = low;

const partial = (noiseArg - low) / (100 * (high - low));
const percentile = whole + partial;
Expand Down
4 changes: 4 additions & 0 deletions test/lib/asteroid.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ describe('Asteroid library', function () {
abundances = 163694267033613831154047584829516n;
abundance = asteroid.getAbundanceAtLot(1, 1758637, 7, abundances);
expect(Number(abundance.toFixed(4))).to.equal(0.9338);

abundances = 15330960757084393714262110814936014964360621324743354563n;
abundance = asteroid.getAbundanceAtLot(5394, 14, 5, abundances);
expect(Number(abundance.toFixed(5))).to.equal(1);
});

it('should get abundances at a unit sphere position', function () {
Expand Down

0 comments on commit d396727

Please sign in to comment.