Adding and calculating coordinates by angle - 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: Adding and calculating coordinates by angle (
/showthread.php?tid=605640)
Adding and calculating coordinates by angle -
Johurt - 22.04.2016
Hello.
Код:
stock PlusCoo(&Float:cx, &Float:cy, Float:ca, Float:plusX, Float:plusY)
{
cx = floatadd(cx, plusX * floatcos(ca, degrees));
cy = floatadd(cy, plusY * floatcos(ca, degrees));
}
What's wrong with this code? Why it doesn't work correctly if angle is not 0 or 180? How to correct it?
EDIT:
Solved:
Код:
stock PlusCoo(Float:cx, Float:cy, Float:ca, Float:plusX, Float:plusY, &Float:x, &Float:y)
{
x = floatsin(-ca, degrees) * plusY + floatcos(-ca, degrees) * -plusX + cx;
y = floatcos(-ca, degrees) * plusY - floatsin(-ca, degrees) * -plusX + cy;
}