Stormworks: Build and Rescue

Stormworks: Build and Rescue

Galactian Apr 30, 2022 @ 8:56am
Finding the angle of an object (0 - 360 degrees)
I have an angle to system using atan2 to get the angle to the target, but it outputs an angle 0 to 360. How would I find the angle of my plane from 0 - 360?
< >
Showing 1-6 of 6 comments
(((x*-1)*360)+360)%360

Copy/paste that into a function block, with the compass sensor being the X input, your output will be a 0-360 degree.
Galactian Apr 30, 2022 @ 6:27pm 
Originally posted by Jackthedragonkiller Chirch:
(((x*-1)*360)+360)%360

Copy/paste that into a function block, with the compass sensor being the X input, your output will be a 0-360 degree.
That gives me the opposite angle. Basically it's giving me 25 when my actual angle is 335.
GrumpyOldMan Apr 30, 2022 @ 7:20pm 
Originally posted by Galactian:
Originally posted by Jackthedragonkiller Chirch:
(((x*-1)*360)+360)%360

Copy/paste that into a function block, with the compass sensor being the X input, your output will be a 0-360 degree.
That gives me the opposite angle. Basically it's giving me 25 when my actual angle is 335.

The formula above works fine, a more compact version would be:
((1-x)%1)*360

Converts the compass -0.5 to 0.5 into 0-360 degree angle.

atan2 also returns radians from 0 to 2pi, so you might have something mixed up when you state it returns 0-360 degrees.
Originally posted by Galactian:
Originally posted by Jackthedragonkiller Chirch:
(((x*-1)*360)+360)%360

Copy/paste that into a function block, with the compass sensor being the X input, your output will be a 0-360 degree.
That gives me the opposite angle. Basically it's giving me 25 when my actual angle is 335.
You may wanna recheck all the logic and the formula in the function. I use this formula a lot, so much I have it saved in a txt document on my PC to quickly copy/paste into a creation. It's never given me an issue.
Booze_Rooster Jun 5, 2022 @ 6:28am 
I have noticed that when using that formula, it will be affected by the orientation of your compass sensor block.

I had the system set up and working so I had indicated course 180 when spawned facing south at the creative island. Happy with it. Then I broke out the section grid tool and started piling my logic up on the deck to start compressing it all into smaller microcontrollers. I sectioned out the compass sensor block and slapped it down vertrically and 90 degrees off the way I had it earlier and it threw the compass off.

Be sure the compass block lays flat (glass up) and the blue arrow is pointing towards the azimuth you wish to read.
Ra-Ra-Rasputin Jun 5, 2022 @ 9:15am 
Originally posted by Galactian:
Originally posted by Jackthedragonkiller Chirch:
(((x*-1)*360)+360)%360

Copy/paste that into a function block, with the compass sensor being the X input, your output will be a 0-360 degree.
That gives me the opposite angle. Basically it's giving me 25 when my actual angle is 335.

I think your compass is not pointed in the right direction.
< >
Showing 1-6 of 6 comments
Per page: 1530 50

Date Posted: Apr 30, 2022 @ 8:56am
Posts: 6