Questions

Jump to navigation Jump to search

Hmmm... what are you trying to use this for? I don't think I quite understood the question. Are you trying to get the biggest angle between any two in consecutive radial order? Or the one which is the closest to 180 degrees from it?

Skilgannon17:46, 23 April 2012
Area Picture

Maybe this picture can explain what i need. As you can see the white lines are the absBearing to every enemy and the transparent white area is the area from the two enemys who have the widest bearing to each other. I need this for my radar and my movement.
And yes i need the biggest angle between two in radial order (i guess :)). Nevermind the blue and green lines they are for something else.

Wompi19:43, 23 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);
Jdev08:20, 24 April 2012
 

You nailed it mate. Thanks. Looks like i was totaly looking at the wrong direction. But at least my gut was right :). Man this is even smaller than i hoped for.

Wompi11:26, 24 April 2012

You are welcome, but this code would not work:) Now I have no time to describe why (writing on english is difficult for me), but try to test different cases and you will easy understand the problem.

Jdev06:50, 25 April 2012
 

You do not have permission to edit this page, for the following reasons:

  • The action you have requested is limited to users in the group: Users.
  • You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

Return to Thread:User talk:Wompi/Questions/reply (9).

 

Yes Jdev you are right it does not work for all angles and i was aware of that. But it pushed me into another direction to think about it. If the bot stays almost ever on the edge or corner of the battlefield your code works very well i get some really impressive average visit counts with my radar.

Thanks Skilgannon your first approach looks interesting and i will give it a try. Haven't found the time for now. My first thougth to overcome the angle glitch was to throw in a signum() direction check and switch the angles if they don't fit. Don't know how to describe this and its again more of my gut feeling which tells me that this might work. I'm almost sure i did this once but lost it. The second one looks a little like my first try, not really sure about that to.

But anyway, thanks to both of you for bringing me out of my stubborn mind state.

Wompi16:00, 25 April 2012