Nikos123

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 this post


Link to post
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 this post


Link to post
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:

https://en.wikipedia.org/wiki/Angle

http://www.regentsprep.org/regents/math/algtrig/ATT3/referenceAngles.htm

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.