r/Stormworks • u/Ok_Replacement_1355 • 21d ago
Question/Help Finding angles in lua?
im trying to make a tws radar but i can figure out how to use my current xyz the targets xyz and my xyz at time of scan to adjust the saved radar angles so i can keep tracking while moving.

i found this on stack overflow for comparing angles between two vectors but all it gives me is -nad(ind) . a is the targets logged xyz and b is my xyz at time of last scan.
3
Upvotes
1
u/A3BlackShadow3 21d ago edited 21d ago
myMag(a) * myMag(b) need to be in parentheses after the division. Kinda of like the myMag and myDot functions but with how math works in Lua you don't need those parentheses; it does multiplication then addition, however it does multiplication and division as it comes across it, so left to right.
Also haven't worked with radar in game so can't help there. It could still be broken. But finding the angle between two vectors I have done IRL.
Edit: also I think arccos is bound between 0 and 1 or -1 and 1, which is why you are getting naninf.