### Author Topic: Direction of Angles  (Read 4437 times)

0 Members and 1 Guest are viewing this topic.

#### kolofsson

• Full Member
• Posts: 100
##### Direction of Angles
« on: April 10, 2008, 12:57:12 am »
Hello, I wanted to suggest if the angle in SFML should not be clockwise instead of counter-clockwise?

On paper, the X coordinate expands to the right, and the Y to the top. But on screen the Y coordinate is flipped downwards. To use the usual trigonometrical formulas I have to add minuses when calculating or refering to the Y coordinate.

So, in brief: if the coordinates system is flipped, shouldn't the angle be flipped too?

Other case is the measure. SFML uses degrees but the trigonometrical functions in cmath use radians, which makes me store my angle values as radians and then convert them for SFML.

#### Laurent

• Hero Member
• Posts: 32504
##### Direction of Angles
« Reply #1 on: April 10, 2008, 03:41:17 am »
Y is flipped downwards, but in your game the top of the view is still considered as being upwards, so I think angles are more consistent this way.

About degrees, it's much more human-friendly than radians. Think about beginners who may not be very cumfortable with Pi and trigonometry in general

Conclusion : just write your own function to convert SFML angles to whatever you want
Code: [Select]
`inline float ConvertAngle(float UpwardDegrees){    return -UpwardDegrees * Pi / 360.f;}`
Laurent Gomila - SFML developer

#### dunce

• Jr. Member
• Posts: 77
##### Direction of Angles
« Reply #2 on: April 10, 2008, 04:50:33 am »
Code: [Select]
`inline float ConvertAngle(float UpwardDegrees){    return -UpwardDegrees * Pi / 360.f;}`

A little bit faster:
Code: [Select]
`{    return -UpwardDegrees * 0,008726646f;}`

#### Laurent

• Hero Member
• Posts: 32504
##### Direction of Angles
« Reply #3 on: April 10, 2008, 05:20:54 am »
I think compilers are smart enough to precompute constant expressions
Laurent Gomila - SFML developer

#### tgm

• Jr. Member
• Posts: 69
##### Direction of Angles
« Reply #4 on: April 10, 2008, 12:36:42 pm »
yes, he is^^

#### kolofsson

• Full Member
• Posts: 100
##### Direction of Angles
« Reply #5 on: April 10, 2008, 05:42:22 pm »
Code: [Select]
`Y is flipped downwards, but in your game the top of the view is still considered as being upwards, so I think angles are more consistent this way.`

Speaking of consistency, if you assume that "an angle increments from X to Y" then the consistent solution would be to revert the angle. Another consistency issue: when reverted, the mathematical formulas work without alteration.

But well, i know it's not a big deal, just complaining, that's what i do best.

`RotateR(float radians);`