https://bugs.documentfoundation.org/show_bug.cgi?id=145630
Bug ID: 145630
Summary: Use atan2 function instead of atan
Product: LibreOffice
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Keywords: difficultyBeginner, easyHack, skillCpp
Severity: normal
Priority: medium
Component: LibreOffice
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
If you use atan(x) to calculate the output θ, you have to think about different
situations that may occur, because with the same value of x, there are multiple
values of θ, and it would be your responsibility to handle that, and find out
what is the suitable value of θ.
But, if you have two values y and x, and you want to calculate atan(y / x),
there is a better choice: using atan2(y, x); atan2(y, x) can handle the values
from all the 4 different quadrants:
https://en.wikipedia.org/wiki/Atan2
Instances of the similar situations can be found by invoking:
git grep atan\(
Within the results of the grep, you can find places that atan2() is better
suited. You should take care about the conditions that may be present (or
missing) after the atan() in which check the signature of the and make sure
that the code works correctly after removing them.
--
You are receiving this mail because:
You are the assignee for the bug.