mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 10:49:09 +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}
|
{$ifndef FPC_MATH_HAS_ARCTAN2}
|
||||||
function arctan2(y,x : float) : float;
|
function arctan2(y,x : float) : float;
|
||||||
begin
|
begin
|
||||||
if (x=0) then
|
if x=0 then
|
||||||
begin
|
begin
|
||||||
if y=0 then
|
if y=0 then
|
||||||
arctan2:=0.0
|
result:=0.0
|
||||||
else if y>0 then
|
else if y>0 then
|
||||||
arctan2:=pi/2
|
result:=pi/2
|
||||||
else if y<0 then
|
else
|
||||||
arctan2:=-pi/2;
|
result:=-pi/2;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
ArcTan2:=ArcTan(y/x);
|
begin
|
||||||
if x<0.0 then
|
if X > 0 then
|
||||||
ArcTan2:=ArcTan2+pi;
|
result:=ArcTan(y/x)
|
||||||
if ArcTan2>pi then
|
else
|
||||||
ArcTan2:=ArcTan2-2*pi;
|
if Y < 0.0 then
|
||||||
end;
|
result:=ArcTan(y/x)-pi
|
||||||
|
else
|
||||||
|
result:=ArcTan(y/x)+pi;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
{$endif FPC_MATH_HAS_ARCTAN2}
|
{$endif FPC_MATH_HAS_ARCTAN2}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user