Modifica il codice del cerchio in coordinate polari utilizzando la funzione coseno.
1 2 3 4 |
RAGGIO=0.4*DIM GIRI=1 Math.Abs(Math.cos(phi)) ' --- FUNZIONE |
1 |
GIRI=1/2 |
1 |
GIRI=2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
DIM=600 COLORE1="#30600060" COLORE2="#60000000" SPESSORE=1 r=2 d=2*r '------------------------------------------------------ RAGGIO =0.4*DIM ' scala... GIRI =3 ' 3 giri... NUMERO =360*GIRI RITARDO=10 '------------------------------------------------------ GraphicsWindow.Title ="CP - cos(x)*cos(1/2*x)" GraphicsWindow.Width =DIM GraphicsWindow.Height =DIM GraphicsWindow.PenWidth =SPESSORE GraphicsWindow.PenColor =COLORE1 GraphicsWindow.BrushColor=COLORE2 '------------------------------------------------------ W2 =DIM/2 H2 =DIM/2 pi2=2*Math.Pi '------------------------------------------------------ angolo=0 deltaAngolo=1 For i=1 to NUMERO phi=Math.GetRadians(angolo)+pi2*Math.Floor(angolo/360) ro=Math.Cos(phi)*Math.Cos(1/3*phi) ' FUNZIONE... '------------------------------------------------------ x=W2+ro*RAGGIO*Math.Cos(phi) y=H2-ro*RAGGIO*Math.sin(phi) GraphicsWindow.DrawLine(W2,H2, x,y) GraphicsWindow.FillEllipse(x-r,y-r,d,d) '------------------------------------------------------ '------------------------------------------------------ angolo=angolo+deltaAngolo Program.Delay(RITARDO) EndFor |