Stupid noob questions regarding radius...

Started by
12 comments, last by Paradigm Shifter 10 years, 7 months ago

atan(y/x) only returns angles in the range -pi/2 to pi. You need to use atan2(y, x). Note the order of arguments (y is first). The angle is measured anticlockwise from the +x axis. (EDIT: And it returns negative values if y < 0, if you need positive values only add 2pi if atan2 returns an angle < 0).

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
Advertisement

So here is what I did:


double atan2Random = math.atan2(randomY,randomX);if 
(atan2Random < 0) atan2Random = atan2Random + 2*(math.PI);

Sadly enough, I'm still only getting results in a single quadrant.

My conditions for detecting a valid 'object' are (sorry the indentation was lost by copy/pasting)


if (atan2Random > 
arcPlayerList[currentPlayer]){

if (atan2Random <= 
arcPlayerList[nextPlayer]){

if (rangeIsOk){

starListX[i] = randomX;
starListY[i] = randomY;
 
i++;
}
}
}

arcPlayerList is a list that contains the angle(rad) for each player. I'm using it to define the 'range' each player has access to, by checking if its bigger than what the current player's start is and smaller or equal to the next player's value.

Are the values in 'arcPlayerList' correct?

What the hell is 'rangeIsOk'?

Are you aware that the && operator can combine conditions?

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

Watch out for ranges that cross the 2pi boundary as well.

You should put a breakpoint on the code where the atan2random value is calculated and step through in the debugger, you should be able to work out what is wrong easily enough.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

This topic is closed to new replies.

Advertisement