Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make sqrt constants #72

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions simplex-noise.ts
Original file line number Diff line number Diff line change
@@ -30,12 +30,14 @@ Better rank ordering method by Stefan Gustavson in 2012.

// these __PURE__ comments help uglifyjs with dead code removal
//
const F2 = 0.5 * (/*#__PURE__*/Math.sqrt(3.0) - 1.0);
const G2 = (3.0 - /*#__PURE__*/Math.sqrt(3.0)) / 6.0;
const SQRT3 = /*#__PURE__*/ Math.sqrt(3.0);
const SQRT5 = /*#__PURE__*/ Math.sqrt(5.0);
const F2 = 0.5 * (SQRT3 - 1.0);
const G2 = (3.0 - SQRT3) / 6.0;
const F3 = 1.0 / 3.0;
const G3 = 1.0 / 6.0;
const F4 = (/*#__PURE__*/Math.sqrt(5.0) - 1.0) / 4.0;
const G4 = (5.0 - /*#__PURE__*/Math.sqrt(5.0)) / 20.0;
const F4 = (SQRT5 - 1.0) / 4.0;
const G4 = (5.0 - SQRT5) / 20.0;

// I'm really not sure why this | 0 (basically a coercion to int)
// is making this faster but I get ~5 million ops/sec more on the