Convert Number to Angle?

For questions about using Classic.

Post » 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?
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Sun May 08, 2011 4:57 pm

1000%360
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » 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.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » 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.
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » 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
G
2
Posts: 34
Reputation: 718

Post » 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?
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » 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?
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Sun May 08, 2011 6:56 pm

your.angle % 360 should do that.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » 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
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » 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
79
S
24
G
52
Posts: 4,724
Reputation: 39,711

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests