timeAtX method Null safety

double timeAtX(
  1. double x
)

The time at which the value of x(time) will equal x.

Returns double.infinity if the simulation will never reach x.

Implementation

double timeAtX(double x) {
  if (x == _x) {
    return 0.0;
  }
  if (_v == 0.0 || (_v > 0 ? (x < _x || x > finalX) : (x > _x || x < finalX))) {
    return double.infinity;
  }
  return math.log(_dragLog * (x - _x) / _v + 1.0) / _dragLog;
}