未验证 提交 ecb07d74 编写于 作者: V Václav Volhejn 提交者: GitHub

Fix bugs in setAngleInRangeZeroTwoPi (#2011)

The function would compute the angle modulo 360, not 2pi as the function's name promises. Additionally, [fmod](https://en.cppreference.com/w/cpp/numeric/math/fmod) returns negative values if the argument is negative, which we also don't want. This can be fixed by adding 2pi to the argument - assuming the angle is not lower than -2pi.
上级 b1cb2b69
......@@ -196,7 +196,7 @@ namespace op
try
{
// Return angle in range [0,2pi)
return std::fmod(angle, 360); // floating-point remainder
return std::fmod(angle + 2 * PI, 2 * PI); // floating-point remainder
// double result{angle};
// Return angle in range [0,2pi)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册