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 public class SpeedInfoCurvature implements Serializable
21 {
22
23
24 private static final long serialVersionUID = 20160501L;
25
26
27 private final Length radius;
28
29
30
31
32
33
34 public SpeedInfoCurvature(final Length radius)
35 {
36 Throw.whenNull(radius, "Radius may not be null.");
37 this.radius = radius;
38 }
39
40
41
42
43
44 public final Length getRadius()
45 {
46 return this.radius;
47 }
48
49
50
51
52
53
54
55 public final Speed getSpeedForLateralAcceleration(final Acceleration acceleration)
56 {
57 Throw.whenNull(acceleration, "Acceleration may not be null.");
58
59 return new Speed(Math.sqrt(acceleration.si * this.radius.si), SpeedUnit.SI);
60 }
61
62
63 @Override
64 public final int hashCode()
65 {
66 return this.radius.hashCode();
67 }
68
69
70 @Override
71 public final boolean equals(final Object obj)
72 {
73 if (this == obj)
74 {
75 return true;
76 }
77 if (obj == null)
78 {
79 return false;
80 }
81 if (getClass() != obj.getClass())
82 {
83 return false;
84 }
85 SpeedInfoCurvature other = (SpeedInfoCurvature) obj;
86 if (!this.radius.equals(other.radius))
87 {
88 return false;
89 }
90 return true;
91 }
92
93
94 @Override
95 public final String toString()
96 {
97 return "SpeedInfoCurvature [radius=" + this.radius + "]";
98 }
99
100 }