# What direction is 0 degrees in your Games?

## Recommended Posts

Where do you guys measure angles from in Games?

Ie what is 0 degrees relative to?

ATM I am using 0 as  from south to North, or straight up. However I'm tempted to making it the +tve x direction.

##### Share on other sites

I use clockwise: 0 is 12 o'clock / straight up and 0.5 is 6 o'clock / straight down.  I also label positional things in a clockwise fashion, e.g. up right down left controllers, points etc.  Clockwise is a convention that is adaptable to many scenarios, easily understood and easily adhered to.

##### Share on other sites

HTML5 Canvas uses the +x axis as 0 degrees/radians, with positive angles in the anticlockwise direction.

That's also the standard in trigonometry:

Using another standard means you'll have to convert frequently if you want to use standard routines like Math.atan2(), which are pretty dang useful.  I recommend using +x.

##### Share on other sites
17 hours ago, stay said:

Using another standard means you'll have to convert frequently if you want to use standard routines like Math.atan2().

True, but we usually don't limit our Games to the x-y plane just because Math and Canvas are rooted in 2D trigonometry.

So I'm cautious of this being significant.  Conversion is almost always necessary at some part of the process irrespective of the trigonometric standard / reference axis.  Else we assume that the view's orientation is directly proportional to the model (or global view).  The atan2 example is good (because the method documentation specifies input values of "y" and "x"), but I would encourage adoption choices be made based on the cost of conversion of such functions (that probably won't make it into optimised production code as-is) versus the conceptual advantage of the alternatives (specifically for the development of Games).  Same applies to units (e.g. degrees vs radians vs the many alternatives).

##### Share on other sites
1 hour ago, b10b said:

I would encourage adoption choices be made based on the cost of conversion of such functions [..] versus the conceptual advantage of the alternatives

Makes sense.  I confess that in some previous game work I used straight up as 0 degrees, which made more sense for the artists working on our games.  They wanted to create art pointing up by default.  Similarly, while the programmers used radians internally, we always supported degrees in game-designer-focused tools and data files, and carefully defined places where we'd convert from degrees to radians in the game engine.

Since this is an html5-specific forum, I think Math and Canvas standards are particularly relevant, but I admit I'm doing all my coding directly to the canvas API and not using a popular engine.  I don't know how other html5 engines approach this.  At a quick glance, it looks like Phaser and Pixi both use +x, clockwise rotations, and radians, but I might have read this wrong.

##### Share on other sites

atm I've been basing all my degrees at starting from 12 oclock, but am still tempted to go back to my Maths roots. I also prefer to work in degrees , not radians.

More opinions wanted!

##### Share on other sites

atan2 is good too, but I convert by adding 90 degrees to the angle to get 0 as north

##### Share on other sites

I'm gonna switch to working in Radians now instead of degrees, and just have constants for the radians based on human directions

##### Share on other sites

I work with radians and 0 is on the right. I am very glad about this choice, as it would be a real pain to have to adapt all math functions. having 0 at the top for artists is fine, but there is no need to have to convert anything else imho. my unit images start from the top and rotate clockwise. but this is a pretty simple conversion to find the correct image. if you want to use sin/cos/atan2 its just much more straightforward to have 0 on the right and use the x/y axis as they are used on screen.

##### Share on other sites

0 is right. Degress go counterclockwise. I read that a lot of rendering engines had it like this because of some implementation in opengl.