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

Add support for enumerable noise sets #21

Open
GoogleCodeExporter opened this issue Dec 3, 2015 · 5 comments
Open

Add support for enumerable noise sets #21

GoogleCodeExporter opened this issue Dec 3, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

A useful method to perform algorithms that use noise would be to set up the
noise data as an enumeration, much like Enumerable.Range(int start, int
count). The proposed method would be Enumerable.Noise(int seed), yielding
infinite procedural noise generation. 

Then, to take five random numbers one would call var randomNumbers =
Enumerable.Noise(seed).Take(5); 

There is alot of uses for floating point noise aswell, mainly in procedural
fractal generation. 

Enumerable.Noise<float>(seed); // Generate noise between 0-1
Enumerable.NoiseSigned<float>(seed); // Generate noise between (-1)-1

Due to the problem of infinite enumeration, foreach loops on raw
enumerations of noise would be problematic. Perhaps one should set up a
maximum range of numbers?

Original issue reported on code.google.com by l.jarven...@gmail.com on 25 Mar 2009 at 2:40

@GoogleCodeExporter
Copy link
Author

Original comment by azizatif on 4 Apr 2009 at 6:30

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

What about:


public static IEnumerable<TReturn> Infinity<TReturn>(TReturn start, 
  Func<TReturn, TReturn?> generator)
  where TReturn : struct 
{
  generator.ThrowIfNull("generator");
  TReturn? val = start;
  while (val.HasValue)
  {
    yield return val.Value;
    val = generator(val.Value);
  }
}

public static IEnumerable<double> Noise(int seed)
{
  Random r = new Random(seed);
  return Infinity(r.NextDouble(), x => r.NextDouble());
}


Original comment by bruno.ac...@gmail.com on 22 Oct 2011 at 4:02

@GoogleCodeExporter
Copy link
Author

mail me if you want the full implementation with testing

Original comment by bruno.ac...@gmail.com on 22 Oct 2011 at 5:17

@GoogleCodeExporter
Copy link
Author

That's a pretty easy way of doing it, yes. Coming to think about it again after 
these years, maybe it's a bit odd to have an infinite enumerable? I haven't 
found other places in .NET where an enumerable sequence never end. 

Original comment by l.jarven...@gmail.com on 22 Oct 2011 at 11:15

@GoogleCodeExporter
Copy link
Author

This issue has been migrated to:
https://github.com/MoreLINQ/morelinq/issues/21
The conversation continues there.
DO NOT post any further comments to the issue tracker on Google Code as it is 
shutting down.
You can also just subscribe to the issue on GitHub to receive notifications of 
any further development.

Original comment by azizatif on 21 Aug 2015 at 6:55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant