# Convert Number to Angle?

### » Sun May 08, 2011 4:47 pm

I'm in need of help...

How would I convert a number (i.e. 1000) to whatever angle that would be?
B
34
S
14
G
4
Posts: 251
Reputation: 4,074

### » Sun May 08, 2011 4:57 pm

1000%360
Spriter Dev
B
103
S
22
G
12
Posts: 3,283
Reputation: 17,147

### » Sun May 08, 2011 5:14 pm

Yep, you probably don't need the number of complete rotations that 1000/ 360 would give you. (2)
% or modulus gives you the remainder of 1000/360.(.77777777)
But keep in mind that's in addition to current angle.

If you do need the number of rotations, and a method to implement them without the 0/360 reset, Lucid's math plug with anglerp() will also work nice.
B
175
S
50
G
199
Posts: 8,625
Reputation: 124,026

### » Sun May 08, 2011 5:26 pm

That sort of works...

If I set an object's angle to 1000, I need to know what angle (0-360) that would be.

So if the number happens to be 450.33 then the object would be pointing at 90.33 degrees.

This way gives me an approximate but only in whole numbers.
B
34
S
14
G
4
Posts: 251
Reputation: 4,074

### » Sun May 08, 2011 5:58 pm

Here's another way : (1000/360 - round down(1000/360)) * 360 witch equals 280 degree. To get a whole number just round all that : round((1000/360 - round down(1000/360)) * 360)

Hope this helps.
B
2
S
1
G
2
Posts: 34
Reputation: 868

### » Sun May 08, 2011 6:12 pm

[quote="YetAnotherSuperhero":1xcyeuxj]That sort of works...

If I set an object's angle to 1000, I need to know what angle (0-360) that would be.

So if the number happens to be 450.33 then the object would be pointing at 90.33 degrees.

This way gives me an approximate but only in whole numbers.[/quote:1xcyeuxj]

Not sure what you mean.

360 degrees is one revolution, so 0.25 of one revolution would be?
B
175
S
50
G
199
Posts: 8,625
Reputation: 124,026

### » Sun May 08, 2011 6:20 pm

Maybe I'm not being clear...

If you tell a sprite "set angle" to 450.33, it would be pointing at 90.33.

How could I get 90.33 without resorting to using a sprite?
B
34
S
14
G
4
Posts: 251
Reputation: 4,074

### » Sun May 08, 2011 6:56 pm

your.angle % 360 should do that.
B
175
S
50
G
199
Posts: 8,625
Reputation: 124,026

### » Sun May 08, 2011 7:06 pm

But that only works on integers not floats.

How could I do this but with floats?

Also... with negative numbers if you did -450%360 it gives you -90 but if you set a sprite to -450%360 and retrieve the angle it is at you get 270 which is what I want
B
34
S
14
G
4
Posts: 251
Reputation: 4,074

### » Sun May 08, 2011 7:30 pm

n-360*floor(n/360) will do the same thing as "%" but preserve floating point numbers.

If you want only a positive angle as a answer:
n-360*floor(n/360) +360*(n<0)
B
97
S
36
G
131
Posts: 5,513
Reputation: 83,464

Next