1 package org.opentrafficsim.road.gtu.lane;
2
3 import org.djunits.value.vdouble.scalar.Acceleration;
4 import org.djunits.value.vdouble.scalar.Mass;
5
6
7
8
9
10
11
12
13
14
15
16
17 public interface VehicleModel
18 {
19
20
21 VehicleModel NONE = new VehicleModel()
22 {
23 @Override
24 public Acceleration boundAcceleration(final Acceleration acceleration, final LaneBasedGTU gtu)
25 {
26 return acceleration;
27 }
28
29
30 @Override
31 public String toString()
32 {
33 return "VehicleModel [None]";
34 }
35 };
36
37
38 VehicleModel MINMAX = new VehicleModel()
39 {
40 @Override
41 public Acceleration boundAcceleration(final Acceleration acceleration, final LaneBasedGTU gtu)
42 {
43 return acceleration.si > gtu.getMaximumDeceleration().si
44 ? (acceleration.si < gtu.getMaximumAcceleration().si ? acceleration : gtu.getMaximumAcceleration())
45 : gtu.getMaximumDeceleration();
46 }
47
48
49 @Override
50 public String toString()
51 {
52 return "VehicleModel [MinMax]";
53 }
54 };
55
56
57
58
59
60
61
62 Acceleration boundAcceleration(Acceleration acceleration, LaneBasedGTU gtu);
63
64
65
66
67
68 default Mass getMass()
69 {
70 return null;
71 }
72
73
74
75
76
77 default double getMomentOfInertiaAboutZ()
78 {
79 return 0;
80 }
81
82
83
84
85
86
87
88
89
90
91
92
93
94 class MassBased implements VehicleModel
95 {
96
97 private final Mass mass;
98
99
100 private final double momentOfInertiaAboutZ;
101
102
103
104
105
106 public MassBased(final Mass mass, final double momentOfInertiaAboutZ)
107 {
108 this.mass = mass;
109 this.momentOfInertiaAboutZ = momentOfInertiaAboutZ;
110 }
111
112
113 @Override
114 public Acceleration boundAcceleration(final Acceleration acceleration, final LaneBasedGTU gtu)
115 {
116 return MINMAX.boundAcceleration(acceleration, gtu);
117 }
118
119
120 @Override
121 public Mass getMass()
122 {
123 return this.mass;
124 }
125
126
127 @Override
128 public double getMomentOfInertiaAboutZ()
129 {
130 return this.momentOfInertiaAboutZ;
131 }
132 }
133
134 }