correctOutOfRangeRadii function

List<double> correctOutOfRangeRadii(
  1. double rx,
  2. double ry,
  3. double x1p,
  4. double y1p,
)

Implementation

List<double> correctOutOfRangeRadii(
    double rx, double ry, double x1p, double y1p) {
  rx = rx.abs();
  ry = ry.abs();

  var lambda = (x1p * x1p) / (rx * rx) + (y1p * y1p) / (ry * ry);

  if (lambda > 1) {
    var sqrtLambda = sqrt(lambda);
    rx *= sqrtLambda;
    ry *= sqrtLambda;
  }

  return [rx, ry];
}