protected static FactorRange getRangeMinMax(GunWave wave, State state, int direction) {
		Simulate sim = new Simulate();
		sim.position = state.targetPosition.clone();
		sim.heading = state.targetHeading;
		sim.velocity = state.targetVelocity;
		sim.direction = direction;
		long time = wave.fireTime - 1;

		wave.storeState();
		while(true) {
			wave.update(time++, sim.position);
			if(wave.isCompleted()) {
				break;
			}
			double goalAngle = wave.angleTo(sim.position) + Math.PI / 2.0;
			sim.angleToTurn = -Utils.normalRelativeAngle(sim.heading - goalAngle);
			if(Math.abs(sim.angleToTurn) > Math.PI / 2.0) {
				sim.angleToTurn = Utils.normalRelativeAngle(sim.angleToTurn + Math.PI);
			}
			sim.step();
		}
		
		FactorRange range = new FactorRange();
		range.set(wave.factorRange);
		
		wave.restoreState();
		return range;
	}