Physolator-Programmierung Java-Programmcode

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import de.physolator.usr.*;
import de.physolator.usr.tvg.TVG;
 
public class TestSystem extends PhysicalSystem {
 
	@V(unit = "m", derivative = "v")
	public double x = 3;
 
	@V(unit = "m/s", derivative = "a")
	public double v = 5;
 
	@V(unit = "m/s^2")
	public double a;
 
	@Override
	public void f(double t, double h) {
		a = -9.81 - 0.1 * Math.signum(v) * Math.pow(v, 2);
	}
 
	@Override
	public void initPlotterDescriptors(PlotterParameters r) {
		r.add("x,v,a", 5, -15, 15);
	}
 
	@Override
	public void initGraphicsComponents(GraphicsComponents g) {
		g.addTVG(new TVG() {
			@Override
			public void paint() {
				double p = 50;
				double q = 150 + x * 20;
				drawCircle(p, q, 14);
				drawLineArrow(p, q, p, q + 5 * v);
			}
		});
	}
 
	public static void main(String[] args) {
		start();
	}
 
}