with ELEMENTARY_FUNCTIONS ; use ELEMENTARY_FUNCTIONS ; function SPIRAL ( X : FLOAT ; Y : FLOAT ) return FLOAT is -- return Z as SPIRAL(X,Y) such that a surface is generated with a spiral -- trough running down a side of a cone with vertex at 0,0 -- typical use X in -16..16 Y in -16..16 step size 0.5 -- then Z, the return, runs about 0..10 for interesting plot -- Z runs from -0.1 to 18.0 full scale HALFPI : FLOAT := 1.57079 ; R : FLOAT; THETA : FLOAT; TZ : FLOAT; begin R := SQRT ( X * X + Y * Y ) ; if R < 0.01 then THETA := 0.0 ; else THETA := ARCTAN ( Y , X ) ; end if ; TZ := THETA / HALFPI ; if TZ < 0.0 then TZ := TZ + 4.0 ; end if ; return 0.75 * R + SIN (( R + TZ ) * HALFPI ); end SPIRAL ; with TEXT_IO; use TEXT_IO; with FLOAT_TEXT_IO; use FLOAT_TEXT_IO; with SPIRAL; procedure TEST_SPIRAL is X : FLOAT; Y : FLOAT; Z : FLOAT; begin for I in INTEGER(-6) .. 6 loop for J in INTEGER(-6) .. 6 loop X := FLOAT(I)/2.0; Y := FLOAT(J)/2.0; Z := SPIRAL(X,Y); PUT(X,3,1,0); PUT(" "); PUT(Y,3,1,0); PUT(" "); PUT(Z,3,1,0); NEW_LINE; end loop; end loop; X := 16.0; Y := 16.0; Z := SPIRAL(X,Y); PUT(X,3,1,0); PUT(" "); PUT(Y,3,1,0); PUT(" "); PUT(Z,3,1,0); NEW_LINE; Y := -16.0; Z := SPIRAL(X,Y); PUT(X,3,1,0); PUT(" "); PUT(Y,3,1,0); PUT(" "); PUT(Z,3,1,0); NEW_LINE; X := -16.0; Z := SPIRAL(X,Y); PUT(X,3,1,0); PUT(" "); PUT(Y,3,1,0); PUT(" "); PUT(Z,3,1,0); NEW_LINE; Y := 16.0; Z := SPIRAL(X,Y); PUT(X,3,1,0); PUT(" "); PUT(Y,3,1,0); PUT(" "); PUT(Z,3,1,0); NEW_LINE; end TEST_SPIRAL;