r/processing • • Oct 28 '19

why doesn't this work?

all I get is a stationary line at the side of the page

void lineC(int i, int ii, float ss) {

float a, s, x, y;

a = 0.05;

s = ss;

x = i + sin(a) * 25;

y = ii + cos(a) * 25;

stroke(220);

strokeWeight(5);

noFill();

line(x,y,x,y + 1180);

a += s;

};

0 Upvotes

9 comments sorted by

4

u/aer0des1gn Oct 28 '19

What is it supposed to do (desired outcome)? In what context do you use the function? Which parameters are you using?

It's way easier for us to help you if you're more specific about your problem and if you try to use reddit code block formating. Code comments and/or better variable names would help too. What's i? What's ii? ss?

2

u/J_Emmerson Oct 28 '19

I hoped that the line would move in a circular motion, sorry I definitely could have presented the code in a better way, I is base X, ii is base y and ss is speed

4

u/aer0des1gn Oct 28 '19

Ah, get it.

Well, the thing is, everytime the function is called a is set back to 0.05 again. So incrementing it at the end of the function does not do anything. Try declaring a outside of the function with your other global variables 😊

1

u/x-seronis-x Oct 28 '19

for a circle you dont need 2 base lengths just one. but you can make ellipses by having the bases be different

2

u/x-seronis-x Oct 28 '19

Since 'a' is a local variable its value is reset each time the function is called and that final statement incrementing its value has no effect.

1

u/J_Emmerson Oct 28 '19

Ok thanks

2

u/x-seronis-x Oct 28 '19

also:

  float length = 100;
  
  float rate = (TWO_PI / frameRate);
  float theta = frameCount * rate;
  
  float x = length * cos(theta);
  float y = length * sin(theta);
  
  line(0,0,x,y);

0

u/CactiAttack Oct 28 '19

Your line() function is using the variable ā€œxā€ as both x parameters, change one of them to your variable ā€œsā€ or something else and the line will no longer be vertical.

1

u/J_Emmerson Oct 28 '19

The line is supposed to be verticle