Questions

Fragment of a discussion from User talk:Wompi
Jump to navigation Jump to search

I'm not sure, that i correctly understood your question and that its algorithm is completely correct, but idea must work, i think

double minAbsBearing = Integer.MAX_VALUE;
double minRelBearing = Integer.MAX_VALUE;
double maxRelBearing = Integer.MIN_VALUE;

for (ATarget target : enemys) {
    double absBearing = ...; // me.angleTo(target) in my case
    double relBearing = Utils.normalRelativeAngle(absBearing);
    if (relBearing < minRelBearing) {
        minAbsBearing = absBearing;
        minRelBearing = relBearing;
    } 
    if (relBearing > maxRelBearing) {
        maxRelBearing = relBearing;
    }
}

double widestArea = maxRelBearing - minRelBearing;
double startAngle = minAbsBearing;
double endAngle = minAbsBearing + widestArea
Jdev07:20, 24 April 2012