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

Fix Negative Range of Perlin1D #352

Merged
merged 2 commits into from
May 26, 2024
Merged

Conversation

ToroidalFox
Copy link
Contributor

@ToroidalFox ToroidalFox commented May 20, 2024

While making toy project, found out 1-dimensional Perlin noise was broken in negative range.

example:

#[test]
fn perlin_test() {
    let perlin = Perlin::new(69420);

    for i in -9..10 {
        let t = i as f64 / 10.0;
        let val = perlin.get([t]);
        println!("{:.2}: {:.2}", t, val);
    }
}

before fix:

-0.90: 1.00
-0.80: 1.00
-0.70: 1.00
-0.60: 1.00
-0.50: 1.00
-0.40: 0.80
-0.30: 0.60
-0.20: 0.40
-0.10: 0.20
0.00: -0.00
0.10: -0.21
0.20: -0.47
0.30: -0.73
0.40: -0.93
0.50: -1.00
0.60: -0.93
0.70: -0.73
0.80: -0.47
0.90: -0.2

after fix:

-0.90: 0.21
-0.80: 0.47
-0.70: 0.73
-0.60: 0.93
-0.50: 1.00
-0.40: 0.93
-0.30: 0.73
-0.20: 0.47
-0.10: 0.21
0.00: -0.00
0.10: -0.21
0.20: -0.47
0.30: -0.73
0.40: -0.93
0.50: -1.00
0.60: -0.93
0.70: -0.73
0.80: -0.47
0.90: -0.21

perlin_test_stacked

@ToroidalFox ToroidalFox changed the title Fix Nagative Range of Perlin1D Fix Negative Range of Perlin1D May 20, 2024
@Razaekel Razaekel merged commit 4fea5f6 into Razaekel:develop May 26, 2024
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants