| 1 |
-- vim:syntax=lua tabstop=4 |
| 2 |
|
| 3 |
load("functions.lua") |
| 4 |
|
| 5 |
function describe() |
| 6 |
log("One spiral galaxy") |
| 7 |
end |
| 8 |
|
| 9 |
function spawn() |
| 10 |
particlemassmin = randomfloat(1,1000) |
| 11 |
particlemassmax = randomfloat(1,1000) |
| 12 |
estmass = (particlemassmin + particlemassmax) / 2 * spawnparticles |
| 13 |
galaxyradius = randomfloat(10,1000) |
| 14 |
speedbase = .0000001 |
| 15 |
thickness = randomfloat(0.001, 10) |
| 16 |
verticalvelocity = randomfloat(0, 1) |
| 17 |
for i=0,spawnparticles-1 do |
| 18 |
radius = randomfloat(0,galaxyradius) |
| 19 |
speed = speedbase * radius * math.sqrt(estmass) |
| 20 |
angle = randomfloat(0,2*math.pi) |
| 21 |
pos = v(math.cos(angle)*radius, math.sin(angle)*radius, randomfloat(-thickness,thickness)) |
| 22 |
vel = v(math.cos(angle+math.pi/2)*speed*radius, math.sin(angle+math.pi/2)*speed*radius, randomfloat(-verticalvelocity, verticalvelocity)) |
| 23 |
mass = randomfloat(particlemassmin,particlemassmax) |
| 24 |
particle(i, pos, vel, mass) |
| 25 |
end |
| 26 |
end |
| 27 |
|