Hate doing this stuff with code so

Is there an equation that converts any number into an angle:
For ex: -5 to 355, -175 to 185, 374 to 14

2 Likes

I thought you were based. Now you’re just spamming off-topic memes everywhere. Please stop. This is not funny.

3 Likes

Couldn’t you just do X+360? Otherwise, you can also use Modulo to do this. X%360. If you aren’t aware, this is like division, but instead of returning the actual quotient (10/2=5) it returns the remainder (10%2=0)
16/5=3 with a remainder of 1 (3.2) but 16%5 just equals 1 (the remainder)

None of that would work. I’m trying to transfer values into a value between 0 - 360. Basically convert a number into an angular measurement.

1 Like

I’m afraid I’m not really following. -5%360 is 355, -175%360 is 185, and 374%360 is 14. Why would using modulo not work?

1 Like

Well, when it gets to stuff past the 720s or -360s, it would break.

2 Likes

784%360=64 and -532%360=188. What is broken here?

Not sure why it needs to be so specific, but try this in the expression:

A%360<0?A%360+360:A%360

If you use a negative number, you get a negative result.

3 Likes

Yes, try

((A%360)+360)%360

A little long, but it will take any number at all (positives, negatives, decimals, anything) and turn it into a positive angle between 0 and 360 (including 0 and up to but excluding 360 itself).

JR01’s version works too : )

3 Likes

Couldn’t you use an absolute value to mitigate this?

1 Like

No because -20%360 = -20, but you need instead 340.

1 Like

Ooooh gotcha. Angles are complicated, lol. Thank you for explaining

So, what is this code saying? Im trying to figure it out, but the notation is confusing me

2 Likes

It’s a question with answers, basically an " if " boolean.
Question ? Answer1 : Answer2

is A%360<0?
if A is below 0, A%360+360 (so like -20 + 360 = 340)
if A is over 0, A%360

2 Likes

Oooh that makes so much more sense now! Thank you! You’re really good at explaining things, lol

3 Likes