Loading...
Logo
Processing Forum
inacen's Profile
11 Posts
11 Responses
0 Followers

Activity Trend

Last 30 days
Show:
Private Message
    Suppose you have multiple arrays, each a dimension of a coordinate set.. The max and min functions work well to find the max and min, but what if you want to find the index of the result. Is there a built-in function that retrieves the index of the find for max/min?
    I'm trying to learn processing by converting Java algorithms to Processing. 

    One of the toy projects I'm working on is converting the Sierspinski to Processing  http://www.cs.princeton.edu/introcs/22library/Sierpinski.java.html

    However, I seem to be able to get just a single box instead of the iterated triangles.. I am not sure what's wrong....


    void setup(){//size(400,400);
      int N = 10000;
       float[] cx   = { 0.000, 1.000, 0.500 }; 
            float[] cy   = { 0.000, 0.000, 0.866 }; 

            float x = 0.0, y = 0.0; 
            for (int i = 0; i < N; i++) { 
                int r = (int)random(3);
                x = (x + cx[r]) / 2.0; 
                y = (y + cy[r]) / 2.0; 
               point((float)x,(float) y); 
            } 
    }