mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-17 12:59:24 +02:00
* fixed and improved generic ArcTan2 implementation by Paolo Valle, resolves #39861
(cherry picked from commit f18d6f1c85
)
This commit is contained in:
parent
705e7429d3
commit
4e32172df0
@ -906,22 +906,26 @@ end;
|
||||
{$ifndef FPC_MATH_HAS_ARCTAN2}
|
||||
function arctan2(y,x : float) : float;
|
||||
begin
|
||||
if (x=0) then
|
||||
if x=0 then
|
||||
begin
|
||||
if y=0 then
|
||||
arctan2:=0.0
|
||||
result:=0.0
|
||||
else if y>0 then
|
||||
arctan2:=pi/2
|
||||
else if y<0 then
|
||||
arctan2:=-pi/2;
|
||||
result:=pi/2
|
||||
else
|
||||
result:=-pi/2;
|
||||
end
|
||||
else
|
||||
ArcTan2:=ArcTan(y/x);
|
||||
if x<0.0 then
|
||||
ArcTan2:=ArcTan2+pi;
|
||||
if ArcTan2>pi then
|
||||
ArcTan2:=ArcTan2-2*pi;
|
||||
end;
|
||||
else
|
||||
begin
|
||||
if X > 0 then
|
||||
result:=ArcTan(y/x)
|
||||
else
|
||||
if Y < 0.0 then
|
||||
result:=ArcTan(y/x)-pi
|
||||
else
|
||||
result:=ArcTan(y/x)+pi;
|
||||
end;
|
||||
end;
|
||||
{$endif FPC_MATH_HAS_ARCTAN2}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user