01.12.2010, 00:29
(
Последний раз редактировалось xxmitsu; 01.12.2010 в 00:40.
)
Hello,
I was doing some tests when I discovered that atan2 function returns different values
The pawn code:
And this is the C code:
This is what I got in debug file:
The coords are correct. They are the same as the ones collected with client's /save command.
Why is angle different ? The value witch is calculated trough pawn, is the value that I would like to be in both cases.
Seems like atan2 doesn't return the same result. It's just a name coincidence ? Or I'm doing smth wrong..
Does anyone have a wiki refference for atan2 - pawn version ?
How to rewrite the C variant of function to gain the same result as pawn does?
Thank you in advance,
Mike.
I was doing some tests when I discovered that atan2 function returns different values
The pawn code:
pawn Код:
stock SetPlayerToFacePlayera(playerid, facingtoid)
{
new Float:x, Float:y, Float:z, Float:ix, Float:iy, Float:iz, Float:angle;
GetPlayerPos(facingtoid, x, y, z);
GetPlayerPos(playerid, ix, iy, iz);
angle = 180.0-atan2(ix-x,iy-y);
new string[196];
format(string,sizeof(string),"!PAWN- Playerid: X: %f, Y: %f, Z: %f | facingID: X: %f, Y: %f, Z: %f Unghiul %f",ix, iy, iz,x, y, z,angle);
WriteLog(string);
}
pawn Код:
PLUGIN_FUNCTION n_SetPlayerFaceToPlayer( AMX* amx, cell* params )
{
float x, y, z, ix, iy, iz, angle;
callFunction(&PAWN::GetPlayerPos, params[2], &x, &y, &z);
callFunction(&PAWN::GetPlayerPos, params[1], &ix, &iy, &iz);
angle = 180.0-atan2(ix-x,iy-y);
Log("!PLUGIN- Playerid: X: %f, Y: %f, Z: %f | facingID: X: %f, Y: %f, Z: %f Unghiul %f",ix, iy, iz,x, y, z,angle);
}
Код:
[Wed Dec 1 03:33:44 2010] DEBUG: "!PAWN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1539.359008, Y: -1627.401000, Z: 13.103496 Unghiul 47.077163". [Wed Dec 1 03:33:44 2010] DEBUG: "!PLUGIN- Playerid: X: 1544.198242, Y: -1631.901489, Z: 13.382812 | facingID: X: 1539.359009, Y: -1627.401001, Z: 13.103497 Unghiul 177.680054".
Why is angle different ? The value witch is calculated trough pawn, is the value that I would like to be in both cases.
Seems like atan2 doesn't return the same result. It's just a name coincidence ? Or I'm doing smth wrong..
Does anyone have a wiki refference for atan2 - pawn version ?
How to rewrite the C variant of function to gain the same result as pawn does?
Thank you in advance,
Mike.