Sorry if the title isn't self explanatory. I've worked previously on the development of many small indie games for computers, but never really bothered on developing anything for a console, until recently when I got accepted for an indie development program for a well known game console. The games I'm working on (as most console games) will use the analog sticks for moving the character and rotating the camera, so far so good... except that the analog sticks don't work as I thought they would. When the analog stick is facing up, the "value" returned is pi / 2 (90°). When it's facing to the left the value is 0. When it's facing down, the value is (-pi / 2) (-90° ??) and when it's facing on the right the value is either -pi (-180° ??) or pi (180°). And obviously there are values in between all of those.

Small "ascii art" to demonstrate what I mean.

        ^   pi /2
+- pi <   > 0
        V   -pi /2

The values that I don't get are the negative ones, how can I convert those negative values to an actual circle, so that I get a value between 0° and 360° (0 and 2 pi)?

Sorry if the question might sound stupid, I'm really new to console development. At first I thought I would ask in the official developers forum for this game console, but I thought that a public resource like stack exchange might be better since, I'm most likely, not the only one that has to deal with this, and probably other consoles have the same mechanism too.

  • \$\begingroup\$ As a quick aside, you'll often find working with analog stick inputs as 2D vectors will give less grief than dealing with angle representations. Less trigonometry that way, and you don't have to do any special handling for wraparound cases where 0 and 2pi are the same direction. \$\endgroup\$
    – DMGregory
    Commented Jan 24, 2016 at 16:08

2 Answers 2


how can I convert those negative values to an actual circle, so that I get a value between 0° and 360° (0 and 2 pi)?

Since you have an angle in the range of [-Pi, Pi], you can make the range positive without rotating the angle by adding 2*Pi (360°).

Now your angle is in the range of [Pi, 3*Pi]. You can adjust the range without rotating the angle by computing the modulus: angle % (2*Pi).

The resulting angle has the same direction, but is now in the range [0, 2*Pi].

(In C++ this would look like angle = fmod(angle + 2.0*M_PI, 2.0*M_PI);)


In addition to the practical advice offered by MickLH on how to do the conversion, I would like to explain the trigonometry and address some of the misunderstandings apparent in your question, so that you can decide whether converting to 'normal degrees' is actually preferable. It probably isn't; both [-π,π] and [0,2π] describe 'an actual circle'.

There are many ways to describe a point on the unit circle with an angle. Since a circle is obviously symmetric, you have to arbitrarily define a reference point as zero radians. To differentiate between angles clockwise and counter-clockwise from your reference point, you have to define one of them as positive, the other as negative. Finally, since 1π and 3π describe the same point, you may want to select a point where the angle wraps around, which also determines the range of possible values for the angle.

In your example, the zero point is on the right, the positive direction is counter-clockwise, and the angle wraps around at ±1π. These decisions are not unique to 'analog stick radians', they are by far the most common convention, similar (and related, see image below) to how we usually draw two-dimensional plots with the x-axis to the right and the y-axis upwards.

Unit circle

This coordinate system allows us to describe a point in terms of the angle φ in arguably the simplest way possible, i.e.: x = cos(φ), y = sin(φ), while avoiding reflex angles. If you dislike negative angles, you could allow reflex angles, move the wrap-around point to the right and take the angular range from 0π to 2π instead. The point marked in the circle above would then be at φ = 240° rather than at φ = -120°, which is not the most convenient way to measure the red angle, though equally valid, e.g. should you need to find the x-coordinate of the marked point, both cos(-120°) and cos(240°) will yield the same, correct answer: .


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .