I have a Drone
class implemented as a Thread that is called from a Map
class and every X milliseconds the movement()
function of the Drone
class is called to update the position and show it on the map.
Currently the movement()
function looks as follows.
public void moveDrone() {
double increment = 0.000007;
// Straight line movement
if(this.mode == true)
p.setX(this.p.getX() + increment);
if(this.mode == false)
p.setX(p.getX() - increment);
if(p.getX()>38.88602||p.getX()<38.88453)
this.mode = !this.mode;
Which creates a movement in a straight line that looks pretty simple.
I would like to simulate a random motion that looks kind of natural. I've been reading about different implementations like brownian motion and boids but I couldn't find how to implement them for a single particle (drone in this case) that moves randomly inside a bounding box.
Any link or pseudocode will help.
Aucun commentaire:
Enregistrer un commentaire