Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Conversion from SFML angles to radians [SOLVED]  (Read 3659 times)

0 Members and 1 Guest are viewing this topic.

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Conversion from SFML angles to radians [SOLVED]
« on: June 21, 2014, 06:20:29 pm »
Greetings.

When designing things making use of angles - movement, for example - I generally use radians now, as the underlying mechanism, though I may specify initial angles in degrees, as I still find them easier to picture (for example, 1 degree is much more clear to me than the radian equivalent). This works well as the trig functions generally takes radians.

SFML, however, does not.

Due to this, I was trying to convert to and from these different units.

In detail. Radians starting on the positive x axis, counted counterclockwise. SFML degrees, it seems, start on the positive y axis, and are counted clockwise.

I imagine this may be of use to future searches for the same thing.

I seem to have inconsistent success with the functions.

What math would be required for each?
« Last Edit: June 21, 2014, 10:02:16 pm by chessguy »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Conversion from SFML angles to radians
« Reply #1 on: June 21, 2014, 06:24:09 pm »
SFML degrees, it seems, start on the positive y axis, and are counted clockwise.
No, the degrees are counted naturally, 0° corresponds to "right" (+X). There may be confusion because the Y axis points downwards, unlike in mathematical coordinate systems. But this only related to rendering, not angle computations themselves.

I imagine this may be of use to future searches for the same thing.
Have you also imagined that there may be past discussions about degrees and radians? ;)
There were quite a lot of them, actually.

What math would be required for each?
What do you mean?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: Conversion from SFML angles to radians
« Reply #2 on: June 21, 2014, 06:30:04 pm »
Ah. It seems (I was using a pointed sprite) I mistook an edge of the sprite to be the angle rotation, but it starts upwards.

I made this after finding all of them google made available to me. Some were talks about API changes, but I recall at least two talking about the conversion. Though given the mistake I just realized, it is likely I adapted it wrong.

Conversion functions, basically.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Conversion from SFML angles to radians
« Reply #3 on: June 21, 2014, 06:46:35 pm »
Please explain your problem in a meaningful way. Converting between radians and degrees is a trivial task that can be found within seconds on the Internet, so I assume you mean something else... but what?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: Conversion from SFML angles to radians
« Reply #4 on: June 21, 2014, 09:56:52 pm »
It had been for SFML, but it had one less step than I had thought. It seems it is simply the radian-degree calculation (respective of which direction) along with a negation.

As far as I can tell, it is fixed and working as expected.