home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / GRAPHICS / PLOT / SURFUTI3.ZIP / 3DSURF.PAS next >
Encoding:
Pascal/Delphi Source File  |  1988-01-16  |  2.1 KB  |  80 lines

  1.  { GENERATE A 3 DIMENSIONAL SURFACE - INPUT TO THE SURFMODL PROGRAM
  2.   Written by Amnon Levav
  3.   Converted to turbo pascal 4.0 on January 16 1987 by Kevin Lowey.  Needed
  4.   to ensure a space between real numbers output with the WRITELN routine
  5. }
  6.  
  7. program SURF;
  8.  
  9. var Out : string[12];
  10.     OutFile : text;
  11.     Pi:real;
  12.     NU ,NV:integer;
  13.     StartU,EndU,StartV,EndV:real;
  14.  
  15. procedure f(u,v:real; var x,y,z:real);
  16. begin
  17.      x:= u;
  18.      y:= cos(v)*(1.3+sin(u));
  19.      z:= sin(v)*(1.3+sin(u));
  20. end;
  21.  
  22. procedure printGrid;
  23. var iu,iv:integer;U,V,X,Y,Z:real;
  24. begin
  25.      writeln(OutFile,'* Nodal Coordinate lines');
  26.      for iu :=0 to NU -1 do
  27.      begin
  28.           U:=StartU+iu*(EndU-StartU)/(NU-1);
  29.           for iv :=0 to NV -1 do
  30.           begin
  31.                V:=StartV+iv*(EndV-StartV)/(NV-1);
  32.                f(U,V,X,Y,Z);
  33.                writeln(OutFile,X,' ',Y,' ',Z);
  34.           end;
  35.      end;
  36. end;
  37.  
  38. procedure Connect;
  39. var iu,iv,n1,n2,n3,n4:integer;
  40. begin
  41.      writeln(OutFile,'* Surface Connectivity Data');
  42.      FOR IU := 1 TO NU-1 do begin
  43.         FOR IV := 1 TO NV-1 do begin
  44.            N1 := (IU-1)*NV + IV;
  45.            N2 := (IU-1)*NV + IV + 1;
  46.            N3 := (IU)*NV + IV + 1;
  47.            N4 := (IU)*NV + IV;
  48.            writeln(OutFile, 4,' ', 1,' ', N1,' ', N2,' ', N3,' ', N4);
  49.         end
  50.      end
  51. end;
  52.  
  53. procedure Initialize;
  54. begin
  55.     Pi := 3.1415926;
  56.     NU := 21; NV:=21;
  57.     StartU := -Pi; EndU := Pi;
  58.     StartV := 0;  EndV := Pi*2;
  59. end;
  60.  
  61. begin {main}
  62.      Initialize;
  63.      write('output file ? ');
  64.      readln(Out);
  65.      Assign(OutFile,Out);
  66.      rewrite(OutFile);
  67.      writeln(OutFile,'3d parametric function');
  68.      writeln(OutFile,'* version line');
  69.      writeln(OutFile,4);
  70.      writeln(OutFile,'* Control line');
  71.      writeln(OutFile,'* No. Of Materials,No. Of nodes,No. of Surfaces,');
  72.      writeln(OutFile,'* Max Vert Per Surf,No. of sides in the surface to use');
  73.      writeln(OutFile,1,' ',NU*NV,' ',(NU-1)*(NV-1),' ',4,' ',2);
  74.      writeln(OutFile,'* Material Data');
  75.      writeln(OutFile,'2 .7 .5 1 .1');
  76.      PrintGrid;
  77.      Connect;
  78.      close(OutFile);
  79. end.
  80.