DC Analog stick in degrees?

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
User avatar
GyroVorbis
Elysian Shadows Developer
Elysian Shadows Developer
Posts: 1874
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has thanked: 81 times
Been thanked: 64 times
Contact:

DC Analog stick in degrees?

Post by GyroVorbis »

I'm working on a particle demo that can create particles at 0-360 degrees.

I'm using cond.joyx and cond.joyy to get the state of the analog stick. I wanted to somehow treat the analog stick like a 360 degree circle.

Tvspelsfreak had the bright idea of using inverse tangent (tan^-1), but it looks like that isn't going to work).

I was doing this:

Code: Select all

Part_Attribs.s_angle = atan(Buttons.joyx/Buttons.joyy) * (180/3.1415927);
I used the atan function in <math.h> to calculate radians, then converted the radians to degrees by multiplying radians by 180 over pi.

It sorta almost worked, but not correctly.

Any ideas?
quarn
DC Developer
DC Developer
Posts: 80
Joined: Wed Oct 17, 2001 7:44 pm
Location: Sweden
Has thanked: 0
Been thanked: 1 time

Post by quarn »

Try atan2(x,y) instead, regular atan does not determine the quadrant and thus only covers half the angles.
User avatar
GyroVorbis
Elysian Shadows Developer
Elysian Shadows Developer
Posts: 1874
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has thanked: 81 times
Been thanked: 64 times
Contact:

Post by GyroVorbis »

Aha! Thanks. :)
Post Reply