开发者

Drawing the curve y = 1 - x ^ 4 in Processing/Java

开发者 https://www.devze.com 2023-01-13 12:13 出处:网络
I un开发者_如何学运维derstand that y = x ^ n would be float y = (x, n) but what if i wanted to draw the curves

I un开发者_如何学运维derstand 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);
}


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);

0

精彩评论

暂无评论...
验证码 换一张
取 消