Jump to content

What direction is 0 degrees in your Games?


Nikos123
 Share

Recommended Posts

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.

Link to comment
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.

Link to comment
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).

 

 

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...