Example #1
0
void
RouteLink::CalcSpeedups(const TaskProjection& proj)
{
  const fixed scale = proj.GetApproximateScale();
  const fixed dx = fixed(first.longitude - second.longitude);
  const fixed dy = fixed(first.latitude - second.latitude);
  if (!positive(fabs(dx)) && !positive(fabs(dy))) {
    d = fixed(0);
    inv_d = fixed(0);
    polar_index = 0;
    return;
  }
  mag_rmag(dx, dy, d, inv_d);
  polar_index = XYToIndex(dx, dy);
  d *= scale;
  inv_d /= scale;
}
Example #2
0
static void test_mag_rmag(double mag) {
  fixed px(7.07106*mag);
  fixed py(-7.07106*mag);

  double msq(px * px + py * py);
  printf("# testing mag i %g %g\n", mag, msq);

  fixed d; fixed inv_d;
  mag_rmag(px, py, d, inv_d);
  fixed ed = fabs(d-fixed(10.0*mag))/fixed(0.03*mag);
  if (ed>= fixed_one) {
    printf("# d %g %g %g\n", (double)d, (double)ed, mag);
  }
  ok(ed< fixed_one, "mag_rmag d", 0);
  fixed inv_ed = fabs(inv_d-fixed(0.1/mag))/fixed(3.0e-4/mag);
  if (inv_ed>= fixed_one) {
    printf("# inv %g %g %g\n", (double)inv_d, (double)inv_ed, mag);
  }
  ok(inv_ed< fixed_one, "mag_rmag inv_d", 0);
}