Skip to content

Commit

Permalink
Merge pull request #502 from quaelnix/fastmath-fix
Browse files Browse the repository at this point in the history
Fix inappropriate approximation of Math.exp
  • Loading branch information
afischerdev committed Apr 10, 2023
2 parents 2eb4730 + f5f3a7a commit 7e29732
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 29 deletions.
5 changes: 1 addition & 4 deletions brouter-core/src/main/java/btools/router/KinematicPath.java
Expand Up @@ -5,9 +5,6 @@
*/
package btools.router;

import btools.util.FastMath;


final class KinematicPath extends OsmPath {
private double ekin; // kinetic energy (Joule)
private double totalTime; // travel time (seconds)
Expand Down Expand Up @@ -57,7 +54,7 @@ protected double processWaySection(RoutingContext rc, double dist, double delta_

double curveSpeed = aa > 10. ? 200. / aa : 20.;
double distanceTime = dist / curveSpeed;
double decayFactor = FastMath.exp(-distanceTime / km.turnAngleDecayTime);
double decayFactor = Math.exp(-distanceTime / km.turnAngleDecayTime);
floatingAngleLeft = (float) (floatingAngleLeft * decayFactor);
floatingAngleRight = (float) (floatingAngleRight * decayFactor);

Expand Down
6 changes: 2 additions & 4 deletions brouter-core/src/main/java/btools/router/StdPath.java
Expand Up @@ -5,8 +5,6 @@
*/
package btools.router;

import btools.util.FastMath;

final class StdPath extends OsmPath {
/**
* The elevation-hysteresis-buffer (0-10 m)
Expand Down Expand Up @@ -200,7 +198,7 @@ private double calcIncline(double dist) {
} else if (elevation_buffer < -min_delta) {
shift = min_delta;
}
double decayFactor = FastMath.exp(-dist / 100.);
double decayFactor = Math.exp(-dist / 100.);
float new_elevation_buffer = (float) ((elevation_buffer + shift) * decayFactor - shift);
double incline = (elevation_buffer - new_elevation_buffer) / dist;
elevation_buffer = new_elevation_buffer;
Expand All @@ -227,7 +225,7 @@ protected void computeKinematic(RoutingContext rc, double dist, double delta_h,
double f_roll = rc.totalMass * GRAVITY * (rc.defaultC_r + incline);
if (rc.footMode) {
// Use Tobler's hiking function for walking sections
speed = rc.maxSpeed * FastMath.exp(-3.5 * Math.abs(incline + 0.05));
speed = rc.maxSpeed * Math.exp(-3.5 * Math.abs(incline + 0.05));
} else if (rc.bikeMode) {
speed = solveCubic(rc.S_C_x, f_roll, rc.bikerPower);
speed = Math.min(speed, maxSpeed);
Expand Down
21 changes: 0 additions & 21 deletions brouter-util/src/main/java/btools/util/FastMath.java

This file was deleted.

0 comments on commit 7e29732

Please sign in to comment.