View Javadoc
1   package org.opentrafficsim.road.network.speed;
2   
3   import org.djunits.unit.SpeedUnit;
4   import org.djunits.value.vdouble.scalar.Acceleration;
5   import org.djunits.value.vdouble.scalar.Length;
6   import org.djunits.value.vdouble.scalar.Speed;
7   import org.djutils.exceptions.Throw;
8   
9   /**
10   * Class with curvature info for curvature speed limit type.
11   * <p>
12   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
14   * </p>
15   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
16   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
17   * @param radius curvature radius
18   */
19  public record SpeedInfoCurvature(Length radius)
20  {
21  
22      /**
23       * Constructor with curvature radius.
24       * @param radius curvature radius
25       * @throws NullPointerException if radius is null
26       */
27      public SpeedInfoCurvature
28      {
29          Throw.whenNull(radius, "Radius may not be null.");
30      }
31  
32      /**
33       * Returns the speed for which the current lateral acceleration follows in the corner.
34       * @param acceleration acceleration to result from speed in corner
35       * @return speed for which the current lateral acceleration follows in the corner
36       * @throws NullPointerException if acceleration is null
37       */
38      public final Speed getSpeedForLateralAcceleration(final Acceleration acceleration)
39      {
40          Throw.whenNull(acceleration, "Acceleration may not be null.");
41          // a=v*v/r => v=sqrt(a*r)
42          return new Speed(Math.sqrt(acceleration.si * this.radius.si), SpeedUnit.SI);
43      }
44  
45  }