在Processing/Java中绘制曲线 y = 1 - x ^ 4
我知道 y = x ^ n
将是 float y = (x, n)
但是如果我想绘制曲线怎么办
y = 1 - x ^ 4
y = (1-x) ^ 4
y = 1-(1-x) ^ 4
这是我编写的代码,但它在数学上绘制的曲线并不正确 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);
}
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 fory = 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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你要让它绘制 (1-x)^4
你想将
float y = pow(1-n, 4);
更改为float y = 1-pow(n, 4 );
you're making it draw (1-x)^4
you want to change
float y = pow(1-n, 4);
tofloat y = 1-pow(n, 4);