[Question] Get angle XYZ between points
#2

The link in my sig has working example (arrow.inc)

Taken from the include with name changed, returns xy angle between 2 points:

X and Y being the point from which you want the angle.
pawn Код:
stock Float:AngleBetweenPoints(Float:X, Float:Y, Float:PointX, Float:PointY)
{
        new Float:fAngle;
        if(X > PointX && Y > PointY)
                fAngle = floatabs(atan2(floatsub(PointX, X), floatsub(PointY, Y)));
        if(X > PointX && Y <= PointY)
                fAngle = floatadd(floatabs(atan2(floatsub(Y, PointY), floatsub(PointX, X))), 270.0);
        if(X <= PointX && Y > PointY)
                fAngle = floatadd(floatabs(atan2(floatsub(PointY, Y), floatsub(X, PointX))), 90.0);
        if(X <= PointX && Y <= PointY)
                fAngle = floatadd(floatabs(atan2(floatsub(X, PointX), floatsub(Y, PointY))), 180.0);
        return fAngle >= 360.0 ? floatsub(fAngle, 360.0) : fAngle;
}
Reply


Messages In This Thread
[Question] Get angle XYZ between points - by Logofero - 16.05.2015, 08:43
Re: [Question] Get angle XYZ between points - by iggy1 - 16.05.2015, 08:59
Re: [Question] Get angle XYZ between points - by Logofero - 16.05.2015, 09:32
Re: [Question] Get angle XYZ between points - by Logofero - 16.05.2015, 10:24

Forum Jump:


Users browsing this thread: 1 Guest(s)