📄 body.java
字号:
package sim.app.tutorial6;import sim.engine.*;import sim.util.*;public class Body implements Steppable { public double velocity; public double distanceFromSun; public double getVelocity() { return velocity; } public double getDistanceFromSun() { return distanceFromSun; } public Body(double vel, double d) { velocity = vel; distanceFromSun = d; } public void step(SimState state) { Tutorial6 tut = (Tutorial6) state; if (distanceFromSun > 0) // the sun's at 0, and you can't divide by 0 { double theta = ((velocity / distanceFromSun) * state.schedule.getSteps())%(2*Math.PI) ; tut.bodies.setObjectLocation(this, new Double2D(distanceFromSun*Math.cos(theta), distanceFromSun*Math.sin(theta))); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -