I tried to compute the distance to a delivery location using a RoadModel
based on a .dot file. However, the calculated distance using Point.distance(currPos, destPos)
gives a result that does not seem to fit. I compared this with the distance from MoveProgress
(RoadModel.moveTo(...)
) and saw that the point distance is about a factor 100 more.
For example, when using the Taxi example from rinsim-example-4.1.1.jar
with the following implementation of the Taxi
class
class Taxi extends Vehicle implements SimulatorUser {
private RandomGenerator rng;
Taxi(Point startPosition, int capacity) {
super(VehicleDTO.builder().capacity(capacity).startPosition(startPosition)
.speed(1000).build());
}
@Override
public void setSimulator(SimulatorAPI api) {
rng = api.getRandomGenerator();
}
@Override
protected void tickImpl(TimeLapse time) {
final RoadModel rm = getRoadModel();
Point start = rm.getPosition(this);
MoveProgress mp;
if (rm.getDestination(this) == null) {
mp = rm.moveTo(this, rm.getRandomPosition(rng), time);
}
if (rm.getPosition(this).equals(rm.getDestination(this)))
mp = rm.moveTo(this, rm.getRandomPosition(rng), time);
else
mp = rm.moveTo(this, rm.getDestination(this), time);
Point after = rm.getPosition(this);
System.out.println("Travelled distance");
System.out.println(mp.distance());
System.out.println("Straight line distance");
System.out.println(Point.distance(start, after));
}
then the travelled distance is around 0.277 whereas the calculated straight line distance is about 27.7. Is there a reason for the factor 100 difference or another way to get the distance between two points in the same measure as MoveProgress
?