Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angles are negated (and in degrees, but we'll let that one slide) #22

Open
Draknek opened this issue Aug 11, 2011 · 8 comments
Open

Angles are negated (and in degrees, but we'll let that one slide) #22

Draknek opened this issue Aug 11, 2011 · 8 comments

Comments

@Draknek
Copy link
Contributor

Draknek commented Aug 11, 2011

So I guess the degrees thing is personal preference, and it's admittedly sometimes more convenient to type 90 rather than Math.PI*0.5.

But the fact that they're negated has on a few occasions led to some really avoidable issues.

Is there anything that can be done about this without breaking a lot of code?

@dabrorius
Copy link

OMG, and I thought I was doing my trigonometry wrong all this time...

@zachwlewis
Copy link
Member

FlashPunk was based off GameMaker, and I believe that's where the degrees over radians came into play.

I was talking with Chevy Ray and Matt Thorson about angles in Ogmo and Chevy admitted to having done them wrong. They're fine if you assume the stage axes are centered at the bottom left (like a graph you'd draw in class), but since the positive y axis is downward and centered at the top left, the angles are incorrect.

@AbelToy
Copy link
Contributor

AbelToy commented Jul 24, 2013

I think we should definitely change this for FlashPunk 2.0, correct them.

Also, I'd make them radians. You only need to type degrees when manually setting an angle or displaying an angle, and the conversion should happen there.

@zachwlewis
Copy link
Member

Most people are used to working with degrees, as are most graphics programs. If you look at Photoshop (or a similar tool), all the angles are given in degrees, with 0° being along the positive X-axis. While radians are great for math nerds (and programmers), are they the best choice for FlashPunk?

I do believe any exposed API for FlashPunk involving rotation should have congruent units, as well as utilities for unit conversion.

Things To Consider

  • Graphics applications use degrees.
  • Degrees are easier to work with (no need for irrational numbers).
  • The Actionscript Math library uses radians.
  • Math dorks love radians.
  • Experienced developers can deal with either as long as they're predictable.

@AbelToy
Copy link
Contributor

AbelToy commented Jul 24, 2013

Thing is, when using utils functions, they are all converting the given angle to rads and the result back to degrees. This means, if you're using multiple util functions you're converting back and forth from degs to rads all the time, which is useless.

@zachwlewis
Copy link
Member

Thing is, when using utils functions, they are all converting the given angle to rads and the result back to degrees.

This should not happen. When you say "they should be radians," I'm not sure what you're referring to. When developing an API, you just need to consider the user.

If the user sets an angle as 90°, then adds 10°, when he looks at the angle, it should return 100°. If there are optimizations we as developers can do in the backend to improve performance (like storing 90° as 90 * Math.PI / 180 or performing all internal calculations without conversions back and forth), we should do that.

My big question is this: What will the user work with? Is it better for the user to work with degrees or radians?

@Draknek
Copy link
Contributor Author

Draknek commented Jul 24, 2013

@Rolpege You're overthinking this. The overhead of converting between degrees and radians is minimal. The programmer overhead of being confused about units is potentially high.

@BNeutral
Copy link

BNeutral commented Jun 2, 2014

I vote for "good old radians". I used angles in flashpunk for the first time today and was completely baffled by both the negation and my values < PI only very slightly rotating my sprite, as pretty much everything in programming uses radians, including AS3's math library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants