Create Arc with curves/bezier

Hello. I created for-loop for generating ARCs with random angles… using build in arc function. Here some issues with controlling this arcs because they based on circles, and overlays each other (my arc is quarter of circle, so next arc may overlay previous because my step is half of this arc’s circle)… i need titled pattern of arcs… i know i can try to play with offsets, but may be here is a way to generate arc’s based on bezier and forgot about over engineering with offsets and my code is kinda messy, im new in the programming.

What is right way to achieve this? Please share your thoughts
As you see on the picture here is some overplayed arcs.
processing arcs

Is it supposed to be almost totally black?

in my opinion, you have a grid of cells here.

A circle / arc is never allowed to leave its cell.

  • So when your circle is facing left (and down), it must start at upper right corner and so on.

So there are let’s say 4 types. Get the type with random() command and in a switch() clause draw the arc like case 0: facing left (and down), start at upper right corner; break; and so on

@noel they all have random fill. here is more detailed picture
processing arcs 1

@Chrisir Its not just bottom left issue :wink:
Circles generating from X (0) Y(0) and till end its 10x10 canvas of cells which can include arcs.
Arc can be generated or not. If arc going to be generated its randomise angle of arc left top, right top, right bottom or left bottom and appear, then cycle repeats. This is what i did and then i got overlays and stuck.

My idea is if special type of arc is generated, i need to generate next only special array of arc angels to exclude overlays… Seem like i have to work in this direction.

But i also want to know how i can create same form arc with bezier.

Hi @nktlst,

You could store in an array the possible start angles and then, during iteration, pick them at random while making sure to select the corresponding translation vector.

W = H = 800      # dimensions of canvas
N = 4.0          # number of cols/rows
S = W/N          # step size

T = (PVector(0,0), PVector(S,0), PVector(S,S), PVector(0,S))    # 4 possible translation vectors
A = (0, HALF_PI, PI, PI+HALF_PI)                                # corresponding 4 "start" angles

def setup():
    size(W, H)
    background(0)
    
    for i in xrange(N*N):
        x = (i%N) * S        # x position
        y = (i//N) * S       # y position
        ri = int(random(4))  # pick an index at random
        t = T[ri]            # select a translation vector accordingly
        a = A[ri]            # select a start angle accordingly
        
        pushMatrix()
        translate(t.x, t.y)
        fill(random(20,120))
        arc(x, y, S*2, S*2, a, a+HALF_PI)
        popMatrix()

EDIT:

Processing Java version (please feel free to modify if incorrect):

int W = 800;      // dimensions of canvas
int H = W;
int N = 4;        // number of cols/rows
float S = W/N;    // step size

PVector[] T = {new PVector(0,0), new PVector(S,0), new PVector(S,S), new PVector(0,S)};    // 4 possible translation vectors
float[] A = {0, HALF_PI, PI, PI+HALF_PI} ;                                                 // corresponding 4 "start" angles

void setup(){
    size(800, 800);
    background(0);
    
    for (int i=0; i<N*N; i++){
        float x = (i%N) * S;        // x position
        float y = (i/N) * S;        // y position
        int ri = int(random(4));    // pick an index at random
        PVector t = T[ri];          // select a translation vector accordingly
        float a = A[ri];            // select a start angle accordingly
        
        pushMatrix();
        translate(t.x, t.y);
        fill(random(20,120));
        arc(x, y, S*2, S*2, a, a+HALF_PI);
        popMatrix();
    }
}
2 Likes

Wow! so tiny code thnx for this solution!

1 Like