Modifica il codice del cerchio in coordinate polari utilizzando insieme le funzioni coseno e seno.
1 2 3 |
RAGGIO =0.6*DIM GIRI =1/2 ro =Math.Cos(phi)*Math.Sin(2*phi) |
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="#30900090" COLORE2="#60000000" SPESSORE=1 r=2 d=2*r '------------------------------------------------------ RAGGIO =0.4*DIM GIRI =2 NUMERO =360*GIRI RITARDO=10 '------------------------------------------------------ GraphicsWindow.Title ="CP - cos(x)*sin(3/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.Sin(3/2*phi) '------------------------------------------------------ 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 |