home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / CNC11TP.ZIP / DELHANGD.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-11-04  |  1.7 KB  |  50 lines

  1. { Copyright (C) 1988 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
  2.  
  3. program RotateHyperbolicAngle (output) ;
  4.  
  5.      { DelHAngD - Compute exact and approximate number of  }
  6.      {    iterations required to drive hyperbolic cosine   }
  7.      {    coordinate to display limit.                     }
  8.  
  9. uses GRAPH ;
  10.  
  11. var
  12.      grDriver,grMode : integer ; { graphics mode parameters }
  13.      xc             : integer ; { x coordinate center }
  14.      isr,r          : integer ; { shift parameter and radius }
  15.      dx,coshdx,sinhdx : single ; { step angle and functions }
  16.      coshx,sinhx    : single ;  { coordinate angle functions }
  17.      ndx,ndxe       : integer ; { number of coordinate rotations }
  18.  
  19. begin
  20.                                 { initialize graphics }
  21.    grDriver := Detect ;
  22.    InitGraph(grDriver,grMode,'') ;
  23.    CloseGraph ;
  24.                                 { for radii from 1 to 1024 }
  25.    write (output,'X Center: ') ;
  26.    readln (xc) ;
  27.  
  28.    for isr := 0 to 10 do begin
  29.       r := 1 shl isr ;
  30.       dx := 2.0*sqrt(1.0/r) ;
  31.       coshdx := (exp(dx) + exp(-dx))/2.0 ;
  32.       sinhdx := sqrt(sqr(coshdx) - 1.0) ;
  33.       coshx := 1.0 ;
  34.       sinhx := 0.0 ;
  35.       ndx := 0 ;
  36.                                 { compute ndx }
  37.       while (r * coshx) <= (abs(xc) + GetMaxX) do begin
  38.          coshx := coshx * coshdx + sinhx * sinhdx ;
  39.          sinhx := sqrt(sqr(coshx) - 1.0) ;
  40.          Inc(ndx)
  41.       end ;
  42.                                 { estimate ndx }
  43.       ndxe := Trunc(ln(2*(abs(xc)+GetMaxX)/r)/ln(coshdx+dx)) ;
  44.       writeln (output,' ',r:5,' ',dx:10:5,' ',ndx:4,' ',ndxe:4)
  45.  
  46.    end
  47. end.
  48.  
  49. { Copyright (C) 1988 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
  50.