Remove FastMath.exp
FastMath.exp was neither continuous nor strictly monotonically increasing for x < -1 and therefore inappropriate for the intended purpose.
This commit is contained in:
parent
2eb47300cf
commit
f5f3a7a6d6
3 changed files with 3 additions and 29 deletions
|
@ -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)
|
||||
|
@ -57,7 +54,7 @@ final class KinematicPath extends OsmPath {
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
*/
|
||||
package btools.router;
|
||||
|
||||
import btools.util.FastMath;
|
||||
|
||||
final class StdPath extends OsmPath {
|
||||
/**
|
||||
* The elevation-hysteresis-buffer (0-10 m)
|
||||
|
@ -200,7 +198,7 @@ final class StdPath extends OsmPath {
|
|||
} 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;
|
||||
|
@ -227,7 +225,7 @@ final class StdPath extends OsmPath {
|
|||
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);
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
package btools.util;
|
||||
|
||||
/**
|
||||
* Some fast approximations to mathematical functions
|
||||
*
|
||||
* @author ab
|
||||
*/
|
||||
public class FastMath {
|
||||
/**
|
||||
* Approximation to Math.exp for small negative arguments
|
||||
*/
|
||||
public static double exp(double e) {
|
||||
double x = e;
|
||||
double f = 1.;
|
||||
while (e < -1.) {
|
||||
e += 1.;
|
||||
f *= 0.367879;
|
||||
}
|
||||
return f * (1. + x * (1. + x * (0.5 + x * (0.166667 + 0.0416667 * x))));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue