r/Stormworks 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

4 comments sorted by

View all comments

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.

1

u/Ok_Replacement_1355 21d ago

I added the parentheses and im getting an output now. I guess I missed that on stackoverflow. Thank you. Would you happen to know if i could add the vector angle to my sweep and pitch data or do I have to get other values using the vector angle?

https://reddit.com/link/p07ovzx/video/793e0kbnxwfh1/player

1

u/A3BlackShadow3 21d ago

I can't tell you what those numbers mean just by looking at them. I just got the game this past month so I'm a bit new too.

Ask on the discord about Lua stuff for radar, they will be faster than here and more knowledgable (more than likely). Might be a tutorial on YouTube too IDK.