NPC
= .1 * SQR(XCells
* YCells
)
DIM VectorField
(XCells
, YCells
) AS FieldLine
DIM Particles
(XCells
, YCells
, NPC
) AS Particle
DIM Charges
(100) AS Charge
ChargeCount = 1
Charges(ChargeCount).Center.x = 0
Charges(ChargeCount).Center.y = 0
Charges(ChargeCount).Gradient.x = .05
Charges(ChargeCount).Gradient.y = .05
Charges(ChargeCount).Curl.x = 0
Charges(ChargeCount).Curl.y = 0
VectorField(i, j).Center.x = (1 / 2) * XSize * (2 * i - XCells) - XSize / 2
VectorField(i, j).Center.y = (1 / 2) * YSize * (2 * j - YCells) - YSize / 2
Particles(i, j, k).Shade = Lime
Particles
(i
, j
, k
).Displacement.x
= XSize
* (RND - .5) Particles
(i
, j
, k
).Displacement.y
= YSize
* (RND - .5)
Charges
(ChargeCount
).Center.x
= (x
- _WIDTH / 2) Charges
(ChargeCount
).Center.y
= (-y
+ _HEIGHT / 2)
Charges(ChargeCount).Gradient.x = .05
Charges(ChargeCount).Gradient.y = .05
Charges(ChargeCount).Curl.x = 0
Charges(ChargeCount).Curl.y = 0
Charges(ChargeCount).Gradient.x = -.05
Charges(ChargeCount).Gradient.y = -.05
Charges(ChargeCount).Curl.x = 0
Charges(ChargeCount).Curl.y = 0
Charges(ChargeCount).Gradient.x = .05
Charges(ChargeCount).Gradient.y = -.05
Charges(ChargeCount).Curl.x = 0
Charges(ChargeCount).Curl.y = 0
Charges(ChargeCount).Gradient.x = -.05
Charges(ChargeCount).Gradient.y = .05
Charges(ChargeCount).Curl.x = 0
Charges(ChargeCount).Curl.y = 0
Charges(ChargeCount).Gradient.x = 0
Charges(ChargeCount).Gradient.y = 0
Charges(ChargeCount).Curl.x = .05
Charges(ChargeCount).Curl.y = -.05
Charges(ChargeCount).Gradient.x = 0
Charges(ChargeCount).Gradient.y = 0
Charges(ChargeCount).Curl.x = -.05
Charges(ChargeCount).Curl.y = .05
ChargeCount = ChargeCount + 1
Charges(ChargeCount).Center.x = Charges(ChargeCount - 1).Center.x
Charges(ChargeCount).Center.y = Charges(ChargeCount - 1).Center.y
Charges(ChargeCount).Gradient.x = Charges(ChargeCount - 1).Gradient.x
Charges(ChargeCount).Gradient.y = Charges(ChargeCount - 1).Gradient.y
Charges(ChargeCount).Curl.x = Charges(ChargeCount - 1).Curl.x
Charges(ChargeCount).Curl.y = Charges(ChargeCount - 1).Curl.y
LOCATE 1, 1:
PRINT "Press 1-6 to change charge type. Press space to fix charge." xc = VectorField(i, j).Center.x
yc = VectorField(i, j).Center.y
xd = 0
yd = 0
xx = Particles(i, j, k).Displacement.x + .1 * Particles(i, j, k).Velocity.x
yy = Particles(i, j, k).Displacement.y + .1 * Particles(i, j, k).Velocity.y
xd = -xx + XSize / 2
xd = -xx - XSize / 2
yd = -yy + YSize / 2
yd = -yy + -YSize / 2
Particles(i, j, k).Displacement.x = xx + xd
Particles(i, j, k).Displacement.y = yy + yd
CALL cpset
(xc
+ Particles
(i
, j
, k
).Displacement.x
, yc
+ Particles
(i
, j
, k
).Displacement.y
, Particles
(i
, j
, k
).Shade
)
ResetVectorField:
xx = 0
yy = 0
dx = VectorField(i, j).Center.x - Charges(k).Center.x
dy = VectorField(i, j).Center.y - Charges(k).Center.y
d2 = 5000 / (dx * dx + dy * dy)
xx = xx + (Charges(k).Gradient.x * dx * d2) + (Charges(k).Curl.x * dy * d2)
yy = yy + (Charges(k).Gradient.y * dy * d2) + (Charges(k).Curl.y * dx * d2)
VectorField(i, j).Tangent.x = xx
VectorField(i, j).Tangent.y = yy
Particles(i, j, k).Velocity.x = VectorField(i, j).Tangent.x
Particles(i, j, k).Velocity.y = VectorField(i, j).Tangent.y
SUB cline
(x1
, y1
, x2
, y2
, col
)