1 package org.opentrafficsim.road.network.speed;
2
3 import java.io.Serializable;
4
5 import org.djunits.unit.SpeedUnit;
6 import org.djunits.value.vdouble.scalar.Acceleration;
7 import org.djunits.value.vdouble.scalar.Length;
8 import org.djunits.value.vdouble.scalar.Speed;
9 import org.djutils.exceptions.Throw;
10
11
12
13
14
15
16
17
18
19
20
21 public class SpeedInfoCurvature implements Serializable
22 {
23
24
25 private static final long serialVersionUID = 20160501L;
26
27
28 private final Length radius;
29
30
31
32
33
34
35 public SpeedInfoCurvature(final Length radius)
36 {
37 Throw.whenNull(radius, "Radius may not be null.");
38 this.radius = radius;
39 }
40
41
42
43
44
45 public final Length getRadius()
46 {
47 return this.radius;
48 }
49
50
51
52
53
54
55
56 public final Speed getSpeedForLateralAcceleration(final Acceleration acceleration)
57 {
58 Throw.whenNull(acceleration, "Acceleration may not be null.");
59
60 return new Speed(Math.sqrt(acceleration.si * this.radius.si), SpeedUnit.SI);
61 }
62
63
64 @Override
65 public final int hashCode()
66 {
67 return this.radius.hashCode();
68 }
69
70
71 @Override
72 public final boolean equals(final Object obj)
73 {
74 if (this == obj)
75 {
76 return true;
77 }
78 if (obj == null)
79 {
80 return false;
81 }
82 if (getClass() != obj.getClass())
83 {
84 return false;
85 }
86 SpeedInfoCurvature other = (SpeedInfoCurvature) obj;
87 if (!this.radius.equals(other.radius))
88 {
89 return false;
90 }
91 return true;
92 }
93
94
95 @Override
96 public final String toString()
97 {
98 return "SpeedInfoCurvature [radius=" + this.radius + "]";
99 }
100
101 }