libprimis icon indicating copy to clipboard operation
libprimis copied to clipboard

`RAD` does not equal one radian

Open no-lex opened this issue 4 years ago • 6 comments

The radian is a ratio equal to 180/π degrees or 1/(2π) revolutions. Because (of course) tools.h has to do everything its way, the macro RAD is defined as π/180 which is, of course, totally wrong.

The reason that RAD is inverted is for performance (division is slow and multiplication is fast), but this does not excuse the poor naming of the macro.

no-lex avatar Jan 22 '21 05:01 no-lex

Does this mean that the value of RAD should be changed, or that the macro name RAD should be changed?

b-sharman avatar Feb 17 '21 09:02 b-sharman

Yes

no-lex avatar Feb 18 '21 02:02 no-lex

(actually, it's probably better to change the name, on the outside case that the division vs multiplication speed matters)

no-lex avatar Feb 18 '21 02:02 no-lex

On further inspection, there are /RAD events where the RAD constant is the divisor, making it not only counterproductive but also confusing to use the inverse radian for RAD.

no-lex avatar Feb 23 '21 06:02 no-lex

I've taken a look at this and the codebase has both angle*RAD and angle/RAD as @no-lex said

Is the division vs multiplication thing really that impactful? If so, whould we make an INV_RAD = 180/π constant and change the codebase accordingly?

If not, the value of RAD should be π/180 imho I could start working on this once I have a clearer way of doing this

Duskhorn avatar Aug 30 '22 10:08 Duskhorn

@no-lex Actually why isn't this issue closed? lol

Duskhorn avatar Aug 30 '22 11:08 Duskhorn