Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/PVS/trig_fnd/     Datei vom 28.9.2014 mit Größe 948 B image not shown  

Impressum jatan2.pvs   Sprache: PVS

 

%------------------------------------------------------------------------------
% Java atan2  --> (-pi, pi)
%
% Java atan2(y,x) converts rectangular coordinates (x,y) to polar (r,?),
% where r is the distance from the origin and ? is the angle from the x-axis.
% The equation for determining atan2 is: tan? = y / x (where ? is the angle).
% The output values are in the range between -pi and pi
%------------------------------------------------------------------------------
jatan2: THEORY
BEGIN
 
    IMPORTING trig_values, trig_inverses,  atan2_props
  
    x,y: VAR real

    jatan2(y:real,x:{z:real|y=0 => z/=0}): real = IF y >= 0 THEN atan2(x,y)
                                                  ELSE atan2(x,y) - 2*pi
                                                  ENDIF


%%  TEST

    t1: LEMMA jatan2(1,1) = pi/4
    t2: LEMMA jatan2(-1,1) = -pi/4
    t3: LEMMA jatan2(1,-1) = 3*pi/4
    t4: LEMMA jatan2(-1,-1) = -3*pi/4

END jatan2



Messung
CHZG
979610097

¤ Dauer der Verarbeitung: 0.5 Sekunden  ¤

*© Formatika GbR, Deutschland