title: comparing elements in an array and fetching new ones
body: <p>I realize this has been asked before and I had a look at it but, for me, it only works to a point. After some struggle, I thought I'd ask.
  I have an array of floats in an object's constructor.  </p>
  
  <p>That goes like this:</p>
  
  <pre><code>count = 3;
  angles = new float[count];
  </code></pre>
  
  <p>The array length is really small though I'd like implement a modular and reusable approach.</p>
  
  <p>I loop through the array assigning floats:</p>
  
  <pre><code>for (int i = 0; i &lt; angles.length; i++) {
          angles[i] = radians(random(360));
  }
  </code></pre>
  
  <p>Then, with a new loop, I check if the singular elements have less than 30 degrees in between them, and if so, assign a new random value:</p>
  
  <pre><code>for (int i = 0; i &lt; angles.length; i++) {
          for (int k = i+1; k &lt; angles.length; k++){
              if(angles[i] != angles[k]){
                  if(abs(angles[i] - angles[k]) &lt;= radians(30)){
                      angles[i] = radians(random(360));
                  }
              }
          }
  }
  </code></pre>
  
  <p>This works nice and well but it doesn't guarantee that the new random number will keep the 30 degrees limit with the remaining elements. This, I assume, has to do with the length of the 'for' loop. </p>
  
  <p>What would be the best way to overcome this and guarantee that newly fetched number will always conform to the 30 degree rule?</p>