Files
afsim_addfuel/processors/scripts/randomPatrol.txt

61 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

# File generated by Wizard 2.9.0 on Dec 16, 2024.
zone tw
polygonal lat_lon
maximum_altitude 20 km
point 30:03:45.52n 126:02:30.89e
point 30:53:53.49n 126:31:12.66e
point 30:29:11.10n 127:04:22.94e
point 29:36:19.04n 126:22:36.55e
fill_color blue
line_color blue
end_zone
processor randomPatrol WSF_SCRIPT_PROCESSOR
script Array<WsfGeoPoint> GenerateRandomPoints(int numPoints)
WsfZone zone = zone.FindZone("tw");
WsfGeoPoint pMax = zone.MaxPoint();
WsfGeoPoint pMin = zone.MinPoint();
Array<WsfGeoPoint> randomPoints = {};
double minLatitude = pMin.Latitude();
double maxLatitude = pMax.Latitude();
double minLongitude = pMin.Longitude();
double maxLongitude = pMax.Longitude();
while(randomPoints.Size() < numPoints)
{
double randomLatitude = RANDOM.Uniform(minLatitude,maxLatitude);
double randomLongitude = RANDOM.Uniform(minLongitude,maxLongitude);
WsfGeoPoint candidatePoint = candidatePoint.Construct(randomLatitude,randomLongitude,5000);
if( zone.PointIsInside(candidatePoint))
{
randomPoints.PushBack(candidatePoint);
}
}
return randomPoints;
end_script
execute at_time 20 sec relative
Array<WsfGeoPoint> randomPoints = GenerateRandomPoints(10);
WsfRoute route;
WsfRoute r1 = route.Create("lx");
# WsfWaypoint wwp1;
# wwp1.SetLabel("start");
# r1.Insert(0,wwp1);
foreach(WsfGeoPoint vertex in randomPoints)
{
r1.Append(vertex,190);
}
# WsfWaypoint wwp2;
# wwp2.SetLabel("start");
# r1.Insert(r1.Size()-1,wwp2);
# r1.Print();
PLATFORM.FollowRoute(r1);
end_execute
end_processor