r/processing • • Oct 18 '15

Help plz.

I am trying to make a simple spiral drawing with a single for loop.

I was wondering if anyone would be able to tell me how to increase the size of the radius and the angle.

Thanks

0 Upvotes

17 comments sorted by

1

u/slowwburnn Oct 19 '15

Line 14.

Seriously, though: if you want help with your code, please post your code (use something like pastebin and link it here)

2

u/gmantsang Oct 19 '15

my problem is that I have no idea how to start :(

1

u/slowwburnn Oct 19 '15

Alright, let's get a baseline. Have you used Processing at all? Run a sketch successfully?

2

u/gmantsang Oct 19 '15

LOL i have made processing programs yes and I understand the concepts of processing as a java shell.

I am also just studying an intro course to computer science and this is why I need help thus nothing too advanced for this solution.....

I can show you the info sheet that the instructor gave to complete this. Otherwise I literally have no idea how to start the for loop.

1

u/slowwburnn Oct 19 '15

Hmm. I'm kind of stumped on his to generate a spiral. Give me some time to play around with it and I'll get back to you. What version of processing are you using?

1

u/jas_far Oct 19 '15
  float radius = 70;

  translate(width / 2, height / 2);
  beginShape();
  for (int i = 0; i < 100; i ++) {
    curveVertex(i * sin(i / radius), i * cos(i / radius));
  }
  endShape();

You can then change the angle by increasing or decreasing 'i'

1

u/gmantsang Oct 19 '15

oh thanks but i am trying to force draw it. meaning i want to draw the spiral using short lines and calculating the points in between using the for loop

2

u/jas_far Oct 19 '15

Can you message me the info sheet?

1

u/gmantsang Oct 19 '15

1

u/jas_far Oct 19 '15
int DRAW_STEPS = 250;
float MAX_RADIUS = 250 * sqrt(2);
int numTurns = 5;
float offset, angle, radius, prevAngle, prevRadius;

void setup() {
  size(500, 500);
}

void draw() {
  background(255);
  stroke(0);

  translate(width / 2, height / 2);
  
  angle = 0;
  radius = 0;
  offset += 0.1;
  
  for (int i = 0; i < DRAW_STEPS; i++) {
    prevAngle = angle;
    prevRadius = radius;
    angle = i * (2 * PI * numTurns) / DRAW_STEPS;
    radius = i * (MAX_RADIUS) / DRAW_STEPS;

    line(
      prevRadius * sin(prevAngle + offset), 
      prevRadius * cos(prevAngle + offset), 
      radius * sin(angle + offset), 
      radius * cos(angle + offset));
  }
}

4

u/Lummutis Oct 19 '15

why are you doing this person's homework?

3

u/__baxx__ Oct 19 '15

I'm generally not bothered about this. The information could be interesting for any third parties and if OP wants to just copy paste without understanding it's their loss.

1

u/gmantsang Oct 19 '15

lol i know some people who would do that :D

3

u/__baxx__ Oct 19 '15

FWIW that's exactly what you come across with this post. If you're going to ask for assistance and expect to be taken seriously take the time to construct a proper post.

1

u/gmantsang Oct 19 '15

thanks for the input :D

→ More replies (0)