protected void doMoveAirspaceVertically(
      WorldWindow wwd, Airspace airspace, Point mousePoint, Point previousMousePoint) {
    // Find the closest points between the rays through each screen point, and the ray from the
    // control point
    // and in the direction of the globe's surface normal. Compute the elevation difference between
    // these two
    // points, and use that as the change in airspace altitude.
    //
    // If the state keepControlPointsAboveTerrain is set, we prevent the control point from passing
    // any lower than
    // the terrain elevation beneath it.

    if (!(airspace instanceof Movable)) {
      return;
    }

    Movable movable = (Movable) airspace;
    Position referencePos = movable.getReferencePosition();
    if (referencePos == null) return;

    Vec4 referencePoint = wwd.getModel().getGlobe().computePointFromPosition(referencePos);

    Vec4 surfaceNormal =
        wwd.getModel()
            .getGlobe()
            .computeSurfaceNormalAtLocation(
                referencePos.getLatitude(), referencePos.getLongitude());
    Line verticalRay = new Line(referencePoint, surfaceNormal);
    Line screenRay =
        wwd.getView()
            .computeRayFromScreenPoint(previousMousePoint.getX(), previousMousePoint.getY());
    Line previousScreenRay =
        wwd.getView().computeRayFromScreenPoint(mousePoint.getX(), mousePoint.getY());

    Vec4 pointOnLine = AirspaceEditorUtil.nearestPointOnLine(verticalRay, screenRay);
    Vec4 previousPointOnLine =
        AirspaceEditorUtil.nearestPointOnLine(verticalRay, previousScreenRay);

    Position pos = wwd.getModel().getGlobe().computePositionFromPoint(pointOnLine);
    Position previousPos = wwd.getModel().getGlobe().computePositionFromPoint(previousPointOnLine);
    double elevationChange = previousPos.getElevation() - pos.getElevation();

    double[] altitudes = this.getAirspace().getAltitudes();
    boolean[] terrainConformance = this.getAirspace().isTerrainConforming();

    if (this.isKeepControlPointsAboveTerrain()) {
      if (terrainConformance[LOWER_ALTITUDE]) {
        if (altitudes[LOWER_ALTITUDE] + elevationChange < 0.0)
          elevationChange = 0.0 - altitudes[LOWER_ALTITUDE];
      } else {
        double height =
            AirspaceEditorUtil.computeLowestHeightAboveSurface(
                wwd, this.getCurrentControlPoints(), LOWER_ALTITUDE);
        if (elevationChange <= -height) {
          elevationChange = -height;
        }
      }
    }

    altitudes[LOWER_ALTITUDE] += elevationChange;
    altitudes[UPPER_ALTITUDE] += elevationChange;
    this.getAirspace().setAltitudes(altitudes[LOWER_ALTITUDE], altitudes[UPPER_ALTITUDE]);

    this.fireAirspaceMoved(new AirspaceEditEvent(wwd, airspace, this));
  }