Shuttleu
2011-12-29 17:01:59
i renamed the function and this is what i have
program new;
{$i srl/srl.scar}
var
path: TPointArray;
function sps_WindPath(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended): TPointArray;
var
veloX, veloY, windX, windY, veloMag, dist, randomDist, lastDist, step: extended;
lastX, lastY: integer;
sqrt2, sqrt3, sqrt5: extended;
begin
sqrt2:= sqrt(2);
sqrt3:= sqrt(3);
sqrt5:= sqrt(5);
while hypot(xs - xe, ys - ye) > 1 do
begin
dist:= hypot(xs - xe, ys - ye);
wind:= minE(wind, dist);
if dist >= targetArea then
begin
windX:= windX / sqrt3 + (random(round(wind) * 2 + 5) - wind) / sqrt5;
windY:= windY / sqrt3 + (random(round(wind) * 2 + 5) - wind) / sqrt5;
end else
begin
windX:= windX / sqrt2;
windY:= windY / sqrt2;
if (maxStep < 15) then
begin
maxStep:= random(15) + 15;
end else
begin
maxStep:= maxStep / sqrt5;
end;
end;
veloX:= veloX + windX;
veloY:= veloY + windY;
veloX:= veloX + gravity * (xe - xs) / dist;
veloY:= veloY + gravity * (ye - ys) / dist;
if hypot(veloX, veloY) > maxStep then
begin
randomDist:= maxStep / 2.0 + random(round(maxStep) / 2);
veloMag:= sqrt(veloX * veloX + veloY * veloY);
veloX:= (veloX / veloMag) * randomDist;
veloY:= (veloY / veloMag) * randomDist;
end;
lastX:= Round(xs);
lastY:= Round(ys);
xs:= xs + veloX;
ys:= ys + veloY;
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[ High(Result) ] := Point(Round(xs), Round(ys));
step:= hypot(xs - lastX, ys - lastY);
lastdist:= dist;
end;
end;
begin
path:= sps_WindPath(490, 5075, 660, 5030, 25, 12.5, 0.0, 0.0, 22.5, 12.5);
writeln(length(path));
writeln(path);
end.~shut