views:

77

answers:

1

I understand that y = x ^ n would be float y = (x, n) but what if i wanted to draw the curves

y = 1 - x ^ 4
y = (1-x) ^ 4
y = 1-(1-x) ^ 4

Here's the code i wrote but it doesn't draw the curve mathematically correct for y = 1 - x ^ 4

for (int x = 0; x < 100; x++) {
  float n = norm(x, 0.0, 100.0);
  float y = pow(1-n, 4);
  y *= 100;
  smooth();
  point(x, y);
}
+7  A: 

you're making it draw (1-x)^4

you want to change float y = pow(1-n, 4); to float y = 1-pow(n, 4);

Jean-Bernard Pellerin
thanks. you're right.
Obinna Izeogu