SA-MP Forums Archive
Calculating Race Grid positions - Formula help - 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)
+--- Thread: Calculating Race Grid positions - Formula help (/showthread.php?tid=545887)



Calculating Race Grid positions - Formula help - denNorske - 11.11.2014

Hello again!

okay one more time, i've tried to make a new way of calculating the the spawns with trigonometrical functions like this:

pawn Код:
stock GetXYForRacer(Float:xs, Float:ys, &Float:x, &Float:y, Float:angle, position, columns,  Float:sDistance, Float:rDistance)
{
    // we assume the index is starting at = 0 (Then we will get (0,0) as a start pos,
    //because of the calculations for I and J below) which is forwarded to the "calc_point"
    //Defs: xs & ys Should be the reference X&Y and
    //rDistance and sDistance is particularly the sideDistance (side offset) and rearDistance (rear offset)
    // x and y is forwarded to the arrays i added to hold the info.

    new i = position%columns;
    new j = floatround(position, floatround_floor) / columns;
    Calc_Point(xs, ys, Resultx, Resulty, sDistance, rDistance, angle, i, j);
    x = Resultx;
    y = Resulty;
   
}

stock Calc_Point(Float:xs, Float:ys, &Float:x, &Float:y, Float:sDistance, Float:rDistance, Float:angle, i, j)
{
    //rDistance = offset behind the front column
    //sDistance = side offset
    // X and Y gets sent back.
    //xs and ys is the position i am calculating this from. (xStock and yStock)
    //I og J is from the other funct


    x = xs - i * sDistance * floatcos(angle) + j * rDistance * floatsin(angle);
    y = ys + i * sDistance * floatsin(angle) + j * rDistance * floatcos(angle);
}
And it SHOULD look like this when testing it out;



But instead I end up with the results such as below:


How can i edit the formula to make it match the coordinate-system used in sa-mp ?

Thanks guys!


Re: Calculating Race Grid positions - Formula help - denNorske - 12.11.2014

Nevermind guys.

I found out what the problem as. I had to change the minuses to plusses in the last one and add
"floatcos(angle, degrees)" which mainly was my problem.

Solved!