E
E
Empty User2017-01-23 12:12:11
PHP
Empty User, 2017-01-23 12:12:11

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 ...
6f59d8dffe0e4fb2b27a408bb4792e71.png
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

2 answer(s)
E
Empty User, 2017-01-23
@dimash07

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());

X
x67, 2017-01-23
@x67

Generate an array of airports around the world to start with. Give them names. It is easier for the player and easier for you. According to them, you already choose the starting point and formalize the conditions (otherwise, no way!) Make up the route.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question