unit unit_funkce;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils;

  procedure slo2exp(Re:real;Im:real; var absol:real;var arg:real);
  procedure exp2slo(absol:real;arg:real; var Re:real; var Im:real);

implementation

  procedure slo2exp(Re:real;Im:real;var absol:real;var arg:real);

  begin
   if (Re=0) and (Im=0) then begin
      arg:=0;
      absol:=0;
      exit;
   end;

   absol:=sqrt(sqr(Re)+sqr(Im));
   if Re=0 then
      arg:=90
   else
       arg:=180 * arctan(Im/(abs(Re))) / pi;
   if Re<0 then
      if Im>0 then arg:=180-arg else arg:=-180-arg;
  end;

  procedure exp2slo(absol:real;arg:real; var Re:real; var Im:real);
  begin

       Re:=absol*cos(arg*pi/180);
       Im:=absol*sin(arg*pi/180);
  end;


end.