Here's a reply from the ScriptedOrbit thread, which I think it relevant to the discussion here :
chris wrote:As currently implemented, the motion of a particle in particle system must be expressible as a parametric quadratic curve. Is this adequate for your examples?
What do you mean by "quadratic curve" ? Do you mean a simple polynomial of degree 2 ? If yes, this is pretty limited. At least, the jets and volcano I made are quadratic :
The volcano CELXX code I'm using :
Code: Select all
function parabolic_motion(t)
local orbit = {};
orbit.params = t;
orbit.boundingRadius = 2 * t.InitialRadius
local RandomVelocity = t.MinVelocity + (t.MaxVelocity - t.MinVelocity) * math.random();
local Delta = math.rad(t.MinDeclination + (t.MaxDeclination - t.MinDeclination) * math.random());
local Phi = 2 * math.pi * math.random();
local MaxTime = 2.1 * RandomVelocity * math.sin(Delta)/(86400 * t.Gravity);
local RandomDelay = MaxTime * math.random();
function orbit:position(tjd)
local t = tjd - 2451545.0
local Alpha = math.rad(self.params.Longitude);
local Beta = math.rad(self.params.Latitude);
local CyclicTime = (t - RandomDelay) - MaxTime * math.floor((t - RandomDelay) / MaxTime)
local acct = 3732480 * self.params.Gravity * CyclicTime * CyclicTime;
local v0xt = 86.4 * RandomVelocity * math.cos(Delta) * math.cos(Phi) * CyclicTime;
local v0yt = 86.4 * RandomVelocity * math.cos(Delta) * math.sin(Phi) * CyclicTime;
local v0zt = 86.4 * RandomVelocity * math.sin(Delta) * CyclicTime;
local x = (self.params.InitialRadius + v0zt - acct) * math.cos(Beta) * math.cos(Alpha) - v0xt * math.sin(Beta) * math.cos(Alpha) + v0yt * math.sin(Alpha)
local y = (self.params.InitialRadius + v0zt - acct) * math.cos(Beta) * math.sin(Alpha) - v0xt * math.sin(Beta) * math.sin(Alpha) - v0yt * math.cos(Alpha)
local z = (self.params.InitialRadius + v0zt - acct) * math.sin(Beta) + v0xt * math.cos(Beta)
return x, y, z
end
return orbit
end
The jets code (a trivial variation of the previous one) :
Code: Select all
function jet_motion(t)
local orbit = {};
orbit.params = t;
orbit.boundingRadius = 2 * t.InitialRadius
local v0 = 86.4 * (t.MinVelocity + (t.MaxVelocity - t.MinVelocity) * math.random());
local Delta = math.rad(t.MinDeclination + (t.MaxDeclination - t.MinDeclination) * math.random());
local MaxTime = 0.9 * v0 * math.sin(Delta)/(7464960 * t.Deceleration);
local RandomDelay = MaxTime * math.random();
local Phi = 2 * math.pi * math.random();
function orbit:position(tjd)
local t = tjd - 2451545.0
local PeriodicTime = (t - RandomDelay) - MaxTime * math.floor((t - RandomDelay) / MaxTime);
local x = v0 * math.cos(Delta) * math.cos(Phi) * PeriodicTime
local y = v0 * math.cos(Delta) * math.sin(Phi) * PeriodicTime
local z = self.params.Pole * (self.params.InitialRadius + v0 * math.sin(Delta) * PeriodicTime - 3732480 * self.params.Deceleration * PeriodicTime * PeriodicTime)
return x, y, z
end
return orbit
end
In the case of the jets, the SSC code defines the input data. Here's an example for a single particle :
Code: Select all
"Particle 1" "Black Hole experiment"
{
Class "diffuse"
Mesh "blob4_sprites.cmod"
Emissive true
Radius 25000
ScriptedOrbit {
Module "jet_motion"
Function "jet_motion"
InitialRadius 20000 # Altitude of the launch point, in km
Pole 1 # Starting pole. Must be 1 or -1
MinVelocity 4E7 # Minimal launch velocity, in m/s
MaxVelocity 4.25E7 # Maximal launch velocity, in m/s
MinDeclination 85 # Minimal initial velocity declination, in degrees
MaxDeclination 90 # Maximal initial velocity declination, in degrees
Deceleration 700000 # Deceleration effect, in m/s^2
}
}
The curves in these two examples are just quadratic polynomials of the time variable (actually a periodic version of time, defined using the "floor" function), with several angles and velocity parameters as input :
equs.jpg
Here, [tex]\beta[/tex] and [tex]\alpha[/tex] are respectively the Latitude and Longitude of the source. The initial velocity ([tex]v_{0 x}[/tex], [tex]v_{0 y}[/tex] and [tex]v_{0 z}[/tex]) is a random vector which depend on [tex]v_{0}[/tex] (random modulus [tex]v_0 \in [v_{0 min}, v_{0 max} ][/tex]), the declination (random value [tex]\delta \in [\delta_{min}, \delta_{max}][/tex]) and the azimuth (random variable [tex]\phi \in [0, 2 \pi[[/tex]) :
[tex]v_{0 x} = v_{0} \cos\delta \cos\phi[/tex],
[tex]v_{0 y} = v_{0} \cos\delta \sin\phi[/tex],
[tex]v_{0 z} = v_{0} \sin\delta[/tex].
In the case of time, I made it cyclic, using the "floor" function :
[tex]CyclicTime = \tau(t) = t - t_0 - T floor(\frac{t - t_0}{T})[/tex],
where [tex]t_0 \in [0, T][/tex] is a random delay and [tex]T[/tex] is the period of the whole motion.
Chris,
in the case of solar flares, we need more than quadratic functions. For example, a deformation of a circle :
[tex]x(t) =R + a \sin(\omega t + \phi)[/tex]
[tex]y(t) = b \cos(\omega t + \phi)[/tex]
[tex]z(t) = 0[/tex]
This would also be usefull to make accretion disks, with hopefully turbulence and/or differential rotation....