SA-MP Forums Archive
GetPointAngleToPoint - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: GetPointAngleToPoint (/showthread.php?tid=181250)



GetPointAngleToPoint - MJ! - 04.10.2010

Can somebody explain me this function ?

pawn Код:
stock Float:GetPointAngleToPoint(Float:x2, Float:y2, Float:X, Float:Y)
{
    new Float:DX, Float:DY;
    new Float:angle;

    DX = floatabs(floatsub(x2,X));
    DY = floatabs(floatsub(y2,Y));

    if (DY == 0.0 || DX == 0.0)
    {
        if(DY == 0 && DX > 0) angle = 0.0;
        else if(DY == 0 && DX < 0) angle = 180.0;
        else if(DY > 0 && DX == 0) angle = 90.0;
        else if(DY < 0 && DX == 0) angle = 270.0;
        else if(DY == 0 && DX == 0) angle = 0.0;
    }
    else
    {
        angle = atan(DX/DY);
        if(X > x2 && Y <= y2) angle += 90.0;
        else if(X <= x2 && Y < y2) angle = floatsub(90.0, angle);
        else if(X < x2 && Y >= y2) angle -= 90.0;
        else if(X >= x2 && Y > y2) angle = floatsub(270.0, angle);
    }
    return floatadd(angle, 90.0);
}
How can i use it ? And for what ?


Re: GetPointAngleToPoint - [HiC]TheKiller - 04.10.2010

It is the angle between 2 points.

Код:
point1

point2
That would be 180 degrees

Код:
point1        point2
90 degrees etc.