Note that there are some explanatory texts on larger screens.

plurals
  1. PORandom float [0-1] to n random floats [0-1]
    text
    copied!<p>If I have a set of random floats (0.0f - 1.0f) around a sphere (or even on a 2D grid would work too), each of which only differ by about 0.1f from their neighbors, is there a way to transform these floats into, say Colors, each of which's RGB values also only differ by about 0.1f from their neighbors in a way that has (essentially) equal possibility of getting any color (so some colors aren't biased over others)?</p> <p>The method I'm using is <a href="http://freespace.virgin.net/hugo.elias/models/m_landsp.htm" rel="nofollow">this</a>, where after each vertices' final offset is complete I scale all of the offsets down to float values from 0.0 to 1.0, where these float values still reflect the initial distribution of values. I could post code snippets if it'd help, or they're in the edits if you're just curious.</p> <p>Here's a potential answer, thanks Hot Licks! Something that gave a little more even distribution might be nice, though. Still, it's a start (and kinda cool on it's own), yes thanks!</p> <pre><code>Random randomGen = new Random(); int randomOne = randomGen.nextInt(256); int randomTwo = randomGen.nextInt(256); int randomThree = randomGen.nextInt(256); float offsets[] = new float[vertices.length]; ... // Calcuate the offsets via the method described in that article (code is in the edits if you're curious) for(int i = 0; i &lt; vertices.length; i++) { float randomFloat = offsets[i]; float r = (float)((int)(offsets[i]*255.0) ^ randomOne)/255.0f; float b = (float)((int)(offsets[i]*255.0) ^ randomTwo)/255.0f; float g = (float)((int)(offsets[i]*255.0) ^ randomThree)/255.0f; } </code></pre> <p>edit: Removed much of the extra stuff and got to the meat of the question. You can see edits if you're curious about code snippets or other related info, but this is really the bulk what I'm asking.</p> <p>edit edit: Added (partial) solution code snippet.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload