Exemplo n.º 1
0
  private float calculateSmoothAzimuth(float newAzimuth) {
    // hacky version of a ringbuffer
    if (azimuthBuffer.size() <= bufferCounter) {
      azimuthBuffer.add((double) newAzimuth);
    } else {
      azimuthBuffer.set(bufferCounter, (double) newAzimuth);
    }
    bufferCounter = (bufferCounter + 1) % azimuthBufferSize;

    return (float) CircleUtils.getMeanAngle(azimuthBuffer);
  }
Exemplo n.º 2
0
  @Override
  public void onAzimuthChange(float newAzimuth) {
    azimuth = newAzimuth;

    smoothAzimuth = calculateSmoothAzimuth(newAzimuth);

    if (measureFragment != null) {
      measureFragment.rotateView(360 - (float) CircleUtils.radiansToDegree(smoothAzimuth));
    }
    if (currentFragment == resultFragment) {
      resultFragment.onSmoothAzimuthChange(smoothAzimuth);
    }
  }