home *** CD-ROM | disk | FTP | other *** search
- Program PlotAGlobularCluster (input,Output);
- Label
- Line48;
- Var
- S1,R,R0,R1,R2,R3,C,C0,C1,D,A,P1,X,Y,X2,Y2,Z : Real;
- T,Xm,Ym,XPlot,YPlot,I,K,S : Integer;
-
- Procedure Sub100; { Newton-Raphson Iteration }
- Begin { Procedure Sub100 }
- A := R/R0;
- C1 := ArcTan(A)*0.5*R3;
- A := 1+A*A;
- C1 := C1+R*0.5*R2/A;
- C1 := PI*(C1-R*R2/(A*A));
- D := 4*PI*R*R/(A*A*A);
- End; { Procedure Sub100 }
-
- Procedure Sub200; { 2-Dimensional Plot }
- Label
- Line225;
- Begin { Procedure Sub200 }
- XPlot := Round(X*S+X2);
- YPlot := Round(Y*S+Y2);
- If (XPlot < 0) Or (YPlot < 0) Then
- Goto Line225;
- If (XPlot > Xm) Or (YPlot > Ym) Then
- Goto Line225;
- Plot(XPlot,YPlot,2);
- Line225:
- End; { Procedure Sub200 }
-
- Begin { Program }
- R0 := 20;
- R2 := R0*R0;
- R3 := R2*R0;
- C0 := PI*PI*R3/4;
- R1 := R0/Sqrt(2);
- Xm := 320;
- Ym := 200;
- X2 := Xm/2;
- Y2 := Ym/2;
- S := 5;
- Write('How many stars? ');
- Readln(T);
- GraphMode;
- Palette(0);
- For I := 1 To T Do
- Begin { For I }
- C := C0*Random;
- R := R1;
- For K := 1 To 5 Do
- Begin { For K }
- Sub100;
- R := R+(C-C1)/D;
- End; { For K }
- Line48:
- X := Random - 0.5;
- Y := Random - 0.5;
- Z := Random - 0.5;
- S1 := Sqrt(X*X+Y*Y+Z*Z);
- If S1 > 1 Then
- Goto Line48;
- R := R*S1;
- X := X*R;
- Y := Y*R;
- Z := Z*R;
- Sub200;
- End; { For I }
- Write(^G);
- Repeat Until Keypressed;
- TextMode;
- End. { Program }
-