! Orbits					 !
! Implementazione in TrueBasic ! 
! di Amiga Magazine 		 !
! Aprile 1988			      !
! 						 !
!						 !
!					      !			
SET mode "high16"        ! grafica in alta risoluzione
SET window -500,500,-500,500
                         ! origine al centro dello schermo e
SET color "blue"         ! schermo di larghezza ed altezza di
SET back "black"         ! 1000 punti
DO while t<2 or t>10     ! numero degli oggetti
   PRINT "Numero degli oggetti orbitanti (massimo 10)";
   INPUT t
LOOP
!
! definizione array
!
DIM G(10),X(10),Y(10),U(10),V(10),R(10)
!
! valori per tutti gli oggetti
!
FOR i=1 to t
   PRINT "Per oggetto orbitante n. ";i	!valore gravità
   PRINT "Gravità=";
   INPUT G(i)
         let R(i)=G(i)/5
   PRINT "Coordinata X=";    ! coordinata X iniziale
   INPUT X(i)
   PRINT "Coordinata Y=";    ! coordinata Y iniziale
   INPUT Y(i)
   PRINT "X-velocità=";	 ! valore velocità X
   INPUT U(i)
   LET U(i)=(U(i))/100
   PRINT "Y-velocità=";      ! valore velocità Y	
   INPUT V(i)
   LET V(i)=(V(i))/100
NEXT i
CLEAR
!
! calcola e definisci i punti 
!
DO
   FOR i=1 to t
      FOR j=1 to t
         IF i<>j then
            LET X1=X(j)-X(i)
            LET Y1=Y(j)-Y(i)
            LET D2=X1*X1+Y1*Y1
            LET G1=G(j)/(D2*sqr(D2))
            LET U(i)=U(i)+G1*X1
            LET V(i)=V(i)+G1*Y1
         END IF
      NEXT j
      IF i=1 or i=9 then SET color "blue"
      IF i=2 or i=10 then SET color "white"
      IF i=3 then SET color "red"
      IF i=4 then SET color "yellow"
      IF i=5 then SET color "green"
      IF i=6 then SET color "cyan"
      IF i=7 then SET color "magenta"
      IF i=8 then SET color "brown"
      box circle X(i)-(R(i)/2),X(i)+(R(i)/2),Y(i)- (R(i)/2),Y(i)+(R(i)/2)
      !PLOT X(i),Y(i);    ! plot prima posizione
      LET Y(i)=Y(i)+V(i)
      LET X(i)=X(i)+U(i)
      box circle X(i)-(R(i)/2),X(i)+(R(i)/2),Y(i)- (R(i)/2),Y(i)+(R(i)/2)
      !PLOT X(i),Y(i)     ! plot seconda posizione
   NEXT i
! CLEAR             ! rimuovere "!" per cancellare le tracce
LOOP
END
