Sign in Join
FPDoc Onlineexperiment

ArcTan2 function

In unit Math

Return arctangent of (y/x).

Declaration

pascal
function ArcTan2(y: Float; x: Float): Float

Description

arctan2 calculates arctan(y/x), and returns an angle in the correct quadrant. The returned angle will be in the range $-\pi$ to $\pi$ radians. The values of x and y must be between -2\^{}64 and 2\^{}64, moreover x should be different from zero. On Intel systems this function is implemented with the native intel fpatan instruction.

See also

Example: ex6

pascal
Program Example6;

{ Program to demonstrate the arctan2 function. }

Uses math;

  Procedure WriteRadDeg(X : float);

  begin
    Writeln(X:8:5,' rad = ',radtodeg(x):8:5,' degrees.')
  end;

begin
  WriteRadDeg (arctan2(2,1));
end.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.