/** * Computes the distance that can be traveled between <code>from</code> and * <code>to</code> at the specified <code>speed</code> and using the available * <code>time</code>. This method can optionally be overridden to change the * move behavior of the model. The return value of the method is interpreted * in the following way: * <ul> * <li><code>if travelableDistance < distance(from,to)</code> then there is * either: * <ul> * <li>not enough time left to travel the whole distance</li> * <li>another reason (e.g. an obstacle on the way) that prevents traveling * the whole distance</li> * </ul> * <li><code>if travelableDistance ≥ distance(from,to)</code> then it is * possible to travel the whole distance at once.</li> * </ul> * @param from The start position for this travel. * @param to The destination position for this travel. * @param speed The travel speed. * @param timeLeft The time available for traveling. * @param timeUnit Unit in which <code>timeLeft</code> is expressed. * @return The distance that can be traveled, must be ≥ 0. */ protected double computeTravelableDistance(Point from, Point to, double speed, long timeLeft, Unit<Duration> timeUnit) { return speed * unitConversion.toInTime(timeLeft, timeUnit); }
return speed * unitConversion.toInTime(timeLeft, timeUnit);
/** * Constructs a new instance. * @param b The builder with configuration options. * @param c A reference to the clock. */ protected CollisionPlaneRoadModel(CollisionPlaneRMB b, Clock c) { super(b); objRadius = b.getObjectRadius(); deltaMax = maxSpeed * unitConversion.toInTime(c.getTickLength(), c.getTimeUnit()); checkArgument(deltaMax <= DMAX_RAD_RATIO * objRadius, "Incompatible parameters. The following condition should hold: deltaMax " + "(%s) <= %s * objRadius (%s), where deltaMax = maxSpeed (%s %s) * " + "tickLength (%s %s).", deltaMax, DMAX_RAD_RATIO, objRadius, maxSpeed, getSpeedUnit(), c.getTickLength(), c.getTimeUnit()); blockingRegistry = MapSpatialRegistry.create(); }