Difference between revisions of "Thread:User talk:Wompi/Questions/reply (6)"
Jump to navigation
Jump to search
(Reply to Questions) |
(Utils.normalAbsoluteAngle added) |
||
Line 20: | Line 20: | ||
double widestArea = maxRelBearing - minRelBearing; | double widestArea = maxRelBearing - minRelBearing; | ||
double startAngle = minAbsBearing; | double startAngle = minAbsBearing; | ||
− | double endAngle = minAbsBearing + widestArea | + | double endAngle = Utils.normalAbsoluteAngle(minAbsBearing + widestArea); |
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 07:21, 24 April 2012
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 = Utils.normalAbsoluteAngle(minAbsBearing + widestArea);