06.04.2013, 11:53
Some math functions (probably seen way before this day)..
pawn Код:
stock GetOffsetDegrees(Float:a, Float:b)
{
new Float:c;
c = (b > a) ? b - a : 0.0 - (a - b);
if(c > 180.0) c = 0.0 - (360.0 - c);
else if(c <= -180.0) c = (360.0 + c);
return c;
}
stock GetDistanceBetweenPoints2D(Float:x, Float:y, Float:xx, Float:yy)
{
new Float:newx = (xx - x);
new Float:newy = (yy - y);
return floatsqroot( (newx * newx) + (newy * newy) );
}
stock GetDistanceBetweenPoints3D(Float:x, Float:y, Float:z, Float:xx, Float:yy, Float:zz)
{
new Float:newx = (xx - x);
new Float:newy = (yy - y);
new Float:newz = (zz - z);
return floatsqroot( (newx * newx) + (newy * newy) + (newz * newz));
}