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