| gc mags a v p p3 p2 p4 p1 d q r |
mags := Array with: 300 @ 200 with: 200 @ 300 with: 400 @ 300.
gc := ScheduledControllers activeController view graphicsContext lineWidth: 3.
p1 := p2 := p3 := p4 := nil. p := 200@200. v := 0.01 @ 0.
400 timesRepeat:
[5 timesRepeat:
[a := mags inject: 0@0 into:
[:sum :each | d := each - p. sum + (d / d r squared)].
v := v + a. p := p + v].
q := p rounded.
r := (10 * v transpose) rounded.
p3 := p2. p4 := p1. p1 := q - r. p2 := q + r.
p3 notNil ifTrue:
[gc paint: ColorValue yellow; displayPolygon: (Array with: p1 with: p2 with: p3 with: p4);
paint: ColorValue black; displayLineFrom: p4 to: p1; displayLineFrom: p3 to: p2]].
gc displayLineFrom: p1 to: p2.