Answer the question
In order to leave comments, you need to log in
How to create points on the map (coordinates - width, longitude)?
Hello! Here such a thing, it is necessary to create the coordinates of points on the map so that they are scattered throughout the map. The starting point is indicated, the rest are already created along it, and at the same time, the points should move smoothly (so that it does not work out, for example, [Moscow, London, Moscow]). Of course, it is difficult to explain what exactly the customers want, but I will try with an example:
The starting points are indicated in the picture filled with color, the algorithm should create the rest ...
In fact, the effect of the flight of aircraft (for the game) should be created, they fly randomly. Therefore, it was decided to initially create random path coordinates on the server side and already transfer them to the client, so that everyone would have the same. If this is not worth doing, then advise the correct solution to this problem! Thanks a lot!
Answer the question
In order to leave comments, you need to log in
For now, I decided to leave this solution, maybe someone will need it:
function generate($from, $to){
$fixed = 6;
$rand = (float)rand()/(float)getrandmax();
return round($rand * ($to - $from) + $from, $fixed) * 1;
}
function generate_coordinate(){
$longitude = generate(-180, 180);
$latitude = generate(-90, 90);
return ['longitude' => $longitude, 'latitude' => $latitude];
}
print_r(generate_coordinate());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question