我创建了一个Java Applet,它有一个抛物线图,但我的抛物线是颠倒的吗?如何旋转drawLine?
我扩展和实施的内容:
public class Parabola extends Applet implements AdjustmentListener {
//bunch of my code is in here ...
public void paint(Graphics g) {
//bunch of my code in here ...
for (int i = 0; i <= 999; i++) {
y1 = (int)(p[i] * 100) + 100;
y2 = (int)(p[i+1] * 100) + 100;
g.drawLine(i + 20, y1, (i + 1) + 20, y2); //its upside down, needs to be rotated
}
}
}
答案 0 :(得分:0)
实际上,我从this网站上发现了它 - 它是基本的三角函数。
但是,如果有更简单的方法,请分享。
我们使用:
X2 =X1*cos(theta)-Y1*sin(theta);
Y2 =X1*sin(theta)+Y1*cos(theta);
原帖:
g.drawLine(200,200,x1+200,200-y1);
旋转线:
g.drawLine(200,200,x2+200,200-y2);