[Question] Get angle XYZ between points
#3

Quote:
Originally Posted by iggy1
Посмотреть сообщение
The link in my sig has working example (arrow.inc)

Taken from the include with name changed, returns xy angle between 2 points:
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;
}
Thanks for answer. But you represent the function that I know:
PHP код:
stock Float:GetAngleZFromPoints(Float:x1Float:y1Float:x2Float:y2) {
    return (
180.0 atan2(x1-x2y1-y2));

Attached picture with an example

How do I get the angle between the Rocket and the player? To rotate it by vertical?
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)