Circles with polar coordinates

Hi there! I am really interested on Katharina Brunner’s work with circles made with thousand of points. I have read that she made them using a polar coordinate system. I think that she has a package to create them with R. I don’t know what R is, but I ask myself if there is a (easy) way to do somehing like that with processing. Could you please help me to start looking for some tutorial ?
Generative+Art+By+Katharina+Brunner

See R (programming language) - Wikipedia

So It is a programming language, shoul I learn It to these kind of things?

No, you don’t have to learn it.

Just use processing.

And How could I start?

1 Like

Ambitious

Regards,

Chrisir

Hi

If you ask how to start learning processing

1 Like

Thank you my funny friends. I was thinking in somehing about polar coordinates or another way to Focus on that, but thank you anyway for your help!

1 Like

Hi

Is this what you want?

Hi @humano

Once I found this but don’t remember the site


final int nbWeeds = 60;
SeaWeed[] weeds;
PVector rootNoise = new PVector(random(123456), random(123456));
int mode = 1;
float radius = 220;
Boolean noiseOn = true;
PVector center;

void setup()
{
  size(1000, 800, P2D);
  center = new PVector(width/2, height/2);
  strokeWeight(1);
  weeds = new SeaWeed[nbWeeds];
  for (int i = 0; i < nbWeeds; i++)
  {
    weeds[i] = new SeaWeed(i*TWO_PI/nbWeeds, 3*radius);
  }
}

void draw()
{
  //background(50);
  noStroke();
  fill(0);//, 50);
  rect(0, 0, width, height);
  rootNoise.add(new PVector(.01, .01));
  strokeWeight(1);
  for (int i = 0; i < nbWeeds; i++)
  {
    weeds[i].update();
  }
  stroke(0);
  strokeWeight(2);
  noFill();
  ellipse(center.x, center.y, 2*radius, 2*radius);
}

void keyPressed()
{
  if(key == 'n')
  {
    noiseOn = !noiseOn;
  }else
  {
  mode = (mode + 1) % 2;
  }
}


class MyColor
{
  float R, G, B, Rspeed, Gspeed, Bspeed;
  final static float minSpeed = .6;
  final static float maxSpeed = 1.8;
  final static float minR = 200;
  final static float maxR = 255;
  final static float minG = 20;
  final static float maxG = 120;
  final static float minB = 100;
  final static float maxB = 140;

 // final static float minR = 200;
 //  final static float maxR = 255;
 //  final static float minG = 20;
 //  final static float maxG = 120;
 //  final static float minB = 100;
 //  final static float maxB = 140;
  
  
  MyColor()
  {
    init();
  }
  
  public void init()
  {
    R = random(minR, maxR);
    G = random(minG, maxG);
    B = random(minB, maxB);
    Rspeed = (random(1) > .5 ? 1 : -1) * random(minSpeed, maxSpeed);
    Gspeed = (random(1) > .5 ? 1 : -1) * random(minSpeed, maxSpeed);
    Bspeed = (random(1) > .5 ? 1 : -1) * random(minSpeed, maxSpeed);
  }
  
  public void update()
  {
    Rspeed = ((R += Rspeed) > maxR || (R < minR)) ? -Rspeed : Rspeed;
    Gspeed = ((G += Gspeed) > maxG || (G < minG)) ? -Gspeed : Gspeed;
    Bspeed = ((B += Bspeed) > maxB || (B < minB)) ? -Bspeed : Bspeed;
  }
  
  public color getColor()
  {
    return color(R, G, B);
  }
}
class SeaWeed
{
  final static float DIST_MAX = 5.5;//length of each segment
  final static float maxWidth = 50;//max width of the base line
  final static float minWidth = 11;//min width of the base line
  final static float FLOTATION = -3.5;//flotation constant
  float mouseDist;//mouse interaction distance
  int nbSegments;
  PVector[] pos;//position of each segment
  color[] cols;//colors array, one per segment
  float[] rad;
  MyColor myCol = new MyColor();
  float x, y;//origin of the weed
  float cosi, sinu;

  SeaWeed(float p_rad, float p_length)
  {
    nbSegments = (int)(p_length/DIST_MAX);
    pos = new PVector[nbSegments];
    cols = new color[nbSegments];
    rad = new float[nbSegments];
    cosi = cos(p_rad);
    sinu = sin(p_rad);
    x = width/2 + radius*cosi;
    y = height/2 + radius*sinu;
    mouseDist = 40;
    pos[0] = new PVector(x, y);
    for (int i = 1; i < nbSegments; i++)
    {
      pos[i] = new PVector(pos[i-1].x - DIST_MAX*cosi, pos[i-1].y - DIST_MAX*sinu);
      cols[i] = myCol.getColor();
      rad[i] = 3;
    }
  }

  void update()
  {
    PVector mouse = new PVector(mouseX, mouseY);

    pos[0] = new PVector(x, y);
    for (int i = 1; i < nbSegments; i++)
    {
      float n = noise(rootNoise.x + .002 * pos[i].x, rootNoise.y + .002 * pos[i].y);
      float noiseForce = (.5 - n) * 7;
      if(noiseOn)
      {
        pos[i].x += noiseForce;
        pos[i].y += noiseForce;
      }
      PVector pv = new PVector(cosi, sinu);
      pv.mult(map(i, 1, nbSegments, FLOTATION, .6*FLOTATION));
      pos[i].add(pv);

      //mouse interaction
      //if(pmouseX != mouseX || pmouseY != mouseY)
      {
        float d = PVector.dist(mouse, pos[i]);
        if (d < mouseDist)// && pmouseX != mouseX && abs(pmouseX - mouseX) < 12)
        {
          PVector tmpPV = mouse.get();       
          tmpPV.sub(pos[i]);
          tmpPV.normalize();
          tmpPV.mult(mouseDist);
          tmpPV = PVector.sub(mouse, tmpPV);
          pos[i] = tmpPV.get();
        }
      }

      PVector tmp = PVector.sub(pos[i-1], pos[i]);
      tmp.normalize();
      tmp.mult(DIST_MAX);
      pos[i] = PVector.sub(pos[i-1], tmp);
      
      //keep the points inside the circle
      if(PVector.dist(center, pos[i]) > radius)
      {
        PVector tmpPV = pos[i].get();
        tmpPV.sub(center);
        tmpPV.normalize();
        tmpPV.mult(radius);
        tmpPV.add(center);
        pos[i] = tmpPV.get();
      }
    }

    updateColors();

    if (mode == 0)
    {
      stroke(0);
    }     
    beginShape();
    noFill(); 
    for (int i = 0; i < nbSegments; i++)
    { 
      float r = rad[i];
      if (mode == 1)
      {
        stroke(cols[i]);
        vertex(pos[i].x, pos[i].y);
        //line(pos[i].x, pos[i].y, pos[i+1].x, pos[i+1].y);
      } else
      {
     
        noStroke();
        ellipse(pos[i].x, pos[i].y, 2, 2);
      }
    }
    endShape();
  }

  void updateColors()
  {
    myCol.update();
    cols[0] = myCol.getColor();
    for (int i = nbSegments-1; i > 0; i--)
    {
      cols[i] = cols[i-1];
    }
  }
}

float ang = 0.0;
float x;
float y;
float rot;
float turn_pts = 14 ;

void setup() {
  size(400, 400);
  background(0);
}

void draw() { 
  
  float x = cos(ang)*150;
  float y = sin (ang)*50; 
  
  translate(width/2, height/2);
  rotate(rot);
  noStroke() ;
  fill(ang*25,ang*15,ang*5);
  ellipse(x, y, 10, 10);
  ang += 0.05;
  rot += 0.05/turn_pts;
}

1 Like

for trig & circle see https://processing.org/tutorials/trig

an example

an example based on this tutorial (last example)



float px, py; // , px2, py2;

float angle1, angle2, angle3, angle4;

float radius = 50;
float radius2 = 50;
float radius4 = 50;

float frequency = 2;

float x, x2;

void setup() {
  size(1600, 200);
  background (127);
}

void draw() {
  // background (127);

  circle1(); 
  circle2();
  circle3();
  circle4();
}

// --------------------------------------------------------------------

void circle1() {
  noStroke();
  fill(255);
  ellipse(600/8, 75, radius*2, radius*2);

  // Rotates rectangle around circle
  px = 600/8 + cos(radians(angle1))*(radius);
  py = 75 + sin(radians(angle1))*(radius);
  fill(0);

  rect (px, py, 5, 5);
  stroke(100);
  line(600/8, 75, px, py);
  stroke(200);

  angle1 -= frequency;
}

void circle2() {

  if (abs(angle2)>363)
    return; 

  noStroke();
  fill(255);
  ellipse(600/8, 75, radius*2, radius*2);

  // Rotates rectangle around circle
  px = 2.7* 600/8 + cos(radians(angle2))*(radius);
  py = 75 + sin(radians(angle2))*(radius);
  fill(0);

  rect (px, py, 5, 5);
  stroke(100);
  line( 2.7*600/8, 75, px, py);
  stroke(200);

  angle2 -= frequency*2.992687;
}

void circle3() {
  if (abs(radius2)>radius)
    return; 

  noStroke();
  fill(255);
  ellipse(600/8, 75, radius2*2, radius2*2);

  // Rotates rectangle around circle
  px = 4.9* 600/8 + cos(radians(angle3))*(radius2);
  py = 75 + sin(radians(angle3))*(radius2);
  fill(0);

  rect (px, py, 5, 5);
  stroke(100);
  line( 4.9*600/8, 75, px, py);
  stroke(200);

  radius2 -= 0.51;

  angle3 -= frequency*2.992687;
}

void circle4() {
  if ((radius4)<=0)
    return; 

  noStroke();
  fill(255);
  //  ellipse(600/8, 75, radius4*2, radius4*2);

  // Rotates rectangle around circle
  px = 6.9* 600/8 + cos(radians(angle4))*(radius4);
  py = 75 + sin(radians(angle4))*(radius4);
  fill(0);

  rect (px, py, 5, 5);
  stroke(100);
  // line( 6.9*600/8, 75, px, py);
  stroke(200);

  radius4 -= 0.251;

  angle4 -= frequency*2.992687;
}

2 Likes

Thank you so much! I have a lot of material to start working now

2 Likes

This thread about Spirographs features some code that you could play around with :slight_smile:

1 Like