Commit 66147784 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

improve the visualization of the target potential field (no more flickering),...

improve the visualization of the target potential field (no more flickering), refector some of the classes implementing the potential field
parent a42f6690
......@@ -13,14 +13,10 @@ import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.Collection;
import java.util.function.Function;
import org.vadere.gui.components.model.IDefaultModel;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import org.vadere.util.math.MathUtil;
import org.vadere.util.potential.CellGrid;
......@@ -58,13 +54,12 @@ public abstract class DefaultRenderer {
}
public void render(final Graphics2D targetGraphics2D, final int x, final int y, final int width, final int height) {
/*
* if(doubleBuffering) {
* targetGraphics2D.drawImage(renderImage(width, height), x, y, null);
* } else {
*/
targetGraphics2D.translate(x, y);
renderGraphics(targetGraphics2D, width, height);
//if(doubleBuffering) {
targetGraphics2D.drawImage(renderImage(width, height), x, y, null);
//} else {
//targetGraphics2D.translate(x, y);
//renderGraphics(targetGraphics2D, width, height);
// }
targetGraphics2D.dispose();
}
......@@ -86,7 +81,6 @@ public abstract class DefaultRenderer {
Graphics2D bufferGraphics2D = (Graphics2D) image.getGraphics();
renderGraphics(bufferGraphics2D, width, height);
return image;
}
......
......@@ -7,10 +7,9 @@ import org.jetbrains.annotations.Nullable;
import org.vadere.gui.onlinevisualization.model.OnlineVisualizationModel;
import org.vadere.gui.onlinevisualization.view.MainPanel;
import org.vadere.gui.onlinevisualization.view.OnlineVisualisationWindow;
import org.vadere.gui.onlinevisualization.view.OnlinevisualizationRenderer;
import org.vadere.simulator.control.PassiveCallback;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid;
import org.vadere.simulator.models.potential.fields.IPotentialField;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.state.scenario.Topography;
public class OnlineVisualization implements PassiveCallback {
......@@ -24,9 +23,9 @@ public class OnlineVisualization implements PassiveCallback {
public class ObservationAreaSnapshotData {
public final double simTimeInSec;
public final Topography scenario;
public final PotentialFieldTarget potentialFieldTarget;
public final IPotentialField potentialFieldTarget;
public ObservationAreaSnapshotData(double simTimeInSec, @NotNull Topography scenario, @Nullable PotentialFieldTarget potentialFieldTarget) {
public ObservationAreaSnapshotData(double simTimeInSec, @NotNull Topography scenario, @Nullable IPotentialField potentialFieldTarget) {
this.simTimeInSec = simTimeInSec;
this.scenario = scenario;
this.potentialFieldTarget = potentialFieldTarget;
......@@ -37,7 +36,7 @@ public class OnlineVisualization implements PassiveCallback {
private OnlineVisualisationWindow onlineVisualisationPanel;
private OnlineVisualizationModel model;
private Topography scenario;
private PotentialFieldTarget potentialFieldTarget;
private IPotentialFieldTarget potentialFieldTarget;
private boolean enableVisualization;
public OnlineVisualization(boolean enableVisualization) {
......@@ -56,7 +55,7 @@ public class OnlineVisualization implements PassiveCallback {
}
@Override
public void setPotentialFieldTarget(final PotentialFieldTarget potentialFieldTarget) {
public void setPotentialFieldTarget(final IPotentialFieldTarget potentialFieldTarget) {
this.potentialFieldTarget = potentialFieldTarget;
}
......@@ -92,7 +91,10 @@ public class OnlineVisualization implements PassiveCallback {
synchronized (model.getDataSynchronizer()) {
/* Push new snapshot of the observation area to the draw thread. */
model.pushObersavtionAreaSnapshot(
new ObservationAreaSnapshotData(simTimeInSec, scenario.clone(), model.config.isShowPotentialField() ? potentialFieldTarget.clone() : null));
new ObservationAreaSnapshotData(
simTimeInSec,
scenario.clone(),
model.config.isShowPotentialField() ? potentialFieldTarget.copyFields() : null));
}
}
......
......@@ -5,18 +5,15 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Optional;
import java.util.function.Function;
import org.apache.tools.ant.taskdefs.Tar;
import org.vadere.gui.components.model.DefaultSimulationConfig;
import org.vadere.gui.components.model.SimulationModel;
import org.vadere.gui.onlinevisualization.OnlineVisualization;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid;
import org.vadere.simulator.models.potential.fields.IPotentialField;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.state.scenario.*;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.potential.CellGrid;
import org.vadere.util.voronoi.VoronoiDiagram;
public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationConfig> {
......@@ -32,7 +29,7 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
* pontetial field of a certain pedestrian. See 'Simulation' for more
* information. For debug purposes. Updated by popDrawData().
*/
private PotentialFieldTarget potentialField = null;
private IPotentialField potentialField = null;
/**
* Latest snapshot of the jts diagram to be displayed. Updated by
......@@ -108,7 +105,7 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
simTimeInSec = observationAreaSnapshot.simTimeInSec;
// potentialField might be null!
potentialField = observationAreaSnapshot.potentialFieldTarget;
potentialField = observationAreaSnapshot.potentialFieldTarget;
/*
* if(topography == null ||
......@@ -144,11 +141,11 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
}
public void pushObersavtionAreaSnapshot(final OnlineVisualization.ObservationAreaSnapshotData observationAreaSnapshotData) {
if (observationAreaSnapshots.size() > 0) {
observationAreaSnapshots.pop();
}
observationAreaSnapshots.push(observationAreaSnapshotData);
setChanged();
if (observationAreaSnapshots.size() > 0) {
observationAreaSnapshots.pop();
}
observationAreaSnapshots.push(observationAreaSnapshotData);
setChanged();
}
public void reset() {
......@@ -185,7 +182,7 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
if(potentialField != null) {
if(getSelectedElement() instanceof Agent) {
Agent selectedAgent = (Agent)getSelectedElement();
f = pos -> potentialField.getTargetPotential(pos, selectedAgent);
f = pos -> potentialField.getPotential(pos, selectedAgent);
}
}
......
......@@ -29,16 +29,21 @@ public class OnlinevisualizationRenderer extends SimulationRenderer {
@Override
public void render(final Graphics2D targetGraphics2D, int x, int y, int width, int height) {
if (model.popDrawData()) {
super.render(targetGraphics2D, x, y, width, height);
}
synchronized (model.getDataSynchronizer()) {
if (model.popDrawData()) {
super.render(targetGraphics2D, x, y, width, height);
}
}
}
@Override
public void render(final Graphics2D targetGraphics2D, int width, int height) {
if (model.popDrawData()) {
super.render(targetGraphics2D, width, height);
}
synchronized (model.getDataSynchronizer()) {
if (model.popDrawData()) {
super.render(targetGraphics2D, width, height);
}
}
}
@Override
......
package org.vadere.simulator.control;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.state.scenario.Topography;
/**
......@@ -20,5 +20,5 @@ public interface PassiveCallback {
void setTopography(Topography scenario);
default void setPotentialFieldTarget(PotentialFieldTarget potentialFieldTarget){}
default void setPotentialFieldTarget(IPotentialFieldTarget potentialFieldTarget){}
}
......@@ -6,7 +6,7 @@ import org.vadere.simulator.models.DynamicElementFactory;
import org.vadere.simulator.models.MainModel;
import org.vadere.simulator.models.Model;
import org.vadere.simulator.models.potential.PotentialFieldModel;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.simulator.projects.ScenarioStore;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.state.attributes.AttributesSimulation;
......@@ -86,7 +86,7 @@ public class Simulation {
this.topographyController = new TopographyController(topography, dynamicElementFactory);
PotentialFieldTarget pft = null;
IPotentialFieldTarget pft = null;
if(mainModel instanceof PotentialFieldModel) {
pft = ((PotentialFieldModel) mainModel).getPotentialFieldTarget();
}
......
......@@ -5,10 +5,10 @@ import org.vadere.simulator.models.ode.IntegratorFactory;
import org.vadere.simulator.models.ode.ODEModel;
import org.vadere.simulator.models.potential.FloorGradientProviderFactory;
import org.vadere.simulator.models.potential.PotentialFieldModel;
import org.vadere.simulator.models.potential.fields.IPotentialTargetGrid;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTargetGrid;
import org.vadere.simulator.models.potential.fields.PotentialFieldAgent;
import org.vadere.simulator.models.potential.fields.PotentialFieldObstacle;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.models.AttributesGNM;
import org.vadere.state.attributes.scenario.AttributesAgent;
......@@ -33,7 +33,7 @@ public class GradientNavigationModel extends ODEModel<Pedestrian, AttributesAgen
private AttributesGNM attributes;
private GradientProvider floorGradient;
private Map<Integer, Target> targets;
private IPotentialTargetGrid potentialFieldTarget;
private IPotentialFieldTargetGrid potentialFieldTarget;
private PotentialFieldObstacle potentialFieldObstacle;
private PotentialFieldAgent potentialFieldPedestrian;
private int pedestrianIdCounter;
......@@ -44,7 +44,7 @@ public class GradientNavigationModel extends ODEModel<Pedestrian, AttributesAgen
final AttributesGNM attributes,
final PotentialFieldObstacle potentialFieldObstacle,
final PotentialFieldAgent potentialFieldPedestrian,
final IPotentialTargetGrid potentialFieldTarget,
final IPotentialFieldTargetGrid potentialFieldTarget,
final AttributesAgent attributesPedestrian, final Random random) {
super(Pedestrian.class, scenario, IntegratorFactory.createFirstOrderIntegrator(attributes
.getAttributesODEIntegrator()), new GNMEquations(),
......@@ -78,7 +78,7 @@ public class GradientNavigationModel extends ODEModel<Pedestrian, AttributesAgen
attributes.getAttributesODEIntegrator()),
new GNMEquations(), attributesPedestrian, topography, random);
IPotentialTargetGrid iPotentialTargetGrid = IPotentialTargetGrid.createPotentialField(
IPotentialFieldTargetGrid iPotentialTargetGrid = IPotentialFieldTargetGrid.createPotentialField(
modelAttributesList, topography, attributesPedestrian, attributes.getTargetPotentialModel());
this.potentialFieldTarget = iPotentialTargetGrid;
......@@ -169,7 +169,7 @@ public class GradientNavigationModel extends ODEModel<Pedestrian, AttributesAgen
}
@Override
public PotentialFieldTarget getPotentialFieldTarget() {
public IPotentialFieldTarget getPotentialFieldTarget() {
return potentialFieldTarget;
}
......
......@@ -6,7 +6,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.util.geometry.shapes.VPoint;
......@@ -25,10 +25,10 @@ public class CentroidGroup implements Group {
private final List<Pedestrian> lostMembers;
private Map<Pedestrian, Map<Pedestrian, VPoint>> lastVision;
private final Map<Pedestrian, Integer> noVisionOfLeaderCount;
private final PotentialFieldTarget potentialFieldTarget;
private final IPotentialFieldTarget potentialFieldTarget;
public CentroidGroup(int id, int size,
PotentialFieldTarget potentialFieldTarget) {
IPotentialFieldTarget potentialFieldTarget) {
this.id = id;
this.size = size;
this.potentialFieldTarget = potentialFieldTarget;
......@@ -198,8 +198,8 @@ public class CentroidGroup implements Group {
double result;
VPoint pedLocation = ped.getPosition();
double pedDistance = potentialFieldTarget.getTargetPotential(pedLocation, ped);
double centroidDistance = potentialFieldTarget.getTargetPotential(getCentroidOthers(ped), ped);
double pedDistance = potentialFieldTarget.getPotential(pedLocation, ped);
double centroidDistance = potentialFieldTarget.getPotential(getCentroidOthers(ped), ped);
result = centroidDistance - pedDistance;
......@@ -213,10 +213,10 @@ public class CentroidGroup implements Group {
public Pedestrian getLeader(Pedestrian ped) {
Pedestrian result = members.get(0);
double smallestDistance = potentialFieldTarget.getTargetPotential(result.getPosition(), ped);
double smallestDistance = potentialFieldTarget.getPotential(result.getPosition(), ped);
for (Pedestrian p : members) {
double pedDistance = potentialFieldTarget.getTargetPotential(p.getPosition(), p);
double pedDistance = potentialFieldTarget.getPotential(p.getPosition(), p);
if (pedDistance < smallestDistance) {
result = p;
smallestDistance = pedDistance;
......
......@@ -7,7 +7,7 @@ import java.util.Random;
import java.util.TreeMap;
import org.vadere.simulator.models.Model;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.models.AttributesCGM;
import org.vadere.state.attributes.scenario.AttributesAgent;
......@@ -22,7 +22,7 @@ public class CentroidGroupModel implements GroupModel {
private Map<ScenarioElement, CentroidGroup> pedestrianGroupData;
private Topography topography;
private PotentialFieldTarget potentialFieldTarget;
private IPotentialFieldTarget potentialFieldTarget;
private AttributesCGM attributesCGM;
private int nextFreeGroupId = 0;
......@@ -41,7 +41,7 @@ public class CentroidGroupModel implements GroupModel {
this.topography = topography;
}
public void setPotentialFieldTarget(PotentialFieldTarget potentialFieldTarget) {
public void setPotentialFieldTarget(IPotentialFieldTarget potentialFieldTarget) {
this.potentialFieldTarget = potentialFieldTarget;
}
......
......@@ -17,10 +17,10 @@ import org.vadere.simulator.models.osm.optimization.StepCircleOptimizerPowell;
import org.vadere.simulator.models.osm.updateScheme.ParallelWorkerOSM;
import org.vadere.simulator.models.osm.updateScheme.UpdateSchemeOSM.CallMethod;
import org.vadere.simulator.models.potential.PotentialFieldModel;
import org.vadere.simulator.models.potential.fields.IPotentialTargetGrid;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTargetGrid;
import org.vadere.simulator.models.potential.fields.PotentialFieldAgent;
import org.vadere.simulator.models.potential.fields.PotentialFieldObstacle;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.models.AttributesOSM;
import org.vadere.state.attributes.scenario.AttributesAgent;
......@@ -66,7 +66,7 @@ public class OptimalStepsModel implements MainModel, PotentialFieldModel {
private AttributesAgent attributesPedestrian;
private Random random;
private StepCircleOptimizer stepCircleOptimizer;
private PotentialFieldTarget potentialFieldTarget;
private IPotentialFieldTarget potentialFieldTarget;
private PotentialFieldObstacle potentialFieldObstacle;
private PotentialFieldAgent potentialFieldPedestrian;
private List<SpeedAdjuster> speedAdjusters;
......@@ -97,7 +97,7 @@ public class OptimalStepsModel implements MainModel, PotentialFieldModel {
subModelBuilder.buildSubModels(attributesOSM.getSubmodels());
subModelBuilder.addBuildedSubModelsToList(models);
IPotentialTargetGrid iPotentialTargetGrid = IPotentialTargetGrid.createPotentialField(
IPotentialFieldTargetGrid iPotentialTargetGrid = IPotentialFieldTargetGrid.createPotentialField(
modelAttributesList, topography, attributesPedestrian, attributesOSM.getTargetPotentialModel());
this.potentialFieldTarget = iPotentialTargetGrid;
......@@ -151,7 +151,7 @@ public class OptimalStepsModel implements MainModel, PotentialFieldModel {
private StepCircleOptimizer createStepCircleOptimizer(
AttributesOSM attributesOSM, Random random, Topography topography,
IPotentialTargetGrid potentialFieldTarget) {
IPotentialFieldTargetGrid potentialFieldTarget) {
StepCircleOptimizer result;
double movementThreshold = attributesOSM.getMovementThreshold();
......@@ -297,7 +297,7 @@ public class OptimalStepsModel implements MainModel, PotentialFieldModel {
}
@Override
public PotentialFieldTarget getPotentialFieldTarget() {
public IPotentialFieldTarget getPotentialFieldTarget() {
return potentialFieldTarget;
}
......
......@@ -16,7 +16,7 @@ import org.vadere.simulator.models.osm.updateScheme.UpdateSchemeSequential;
import org.vadere.simulator.models.osm.updateScheme.UpdateSchemeOSM.CallMethod;
import org.vadere.simulator.models.potential.fields.PotentialFieldAgent;
import org.vadere.simulator.models.potential.fields.PotentialFieldObstacle;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.PotentialFieldTargetRingExperiment;
import org.vadere.state.attributes.models.AttributesOSM;
import org.vadere.state.attributes.scenario.AttributesAgent;
......@@ -35,7 +35,7 @@ public class PedestrianOSM extends Pedestrian {
private final transient StepCircleOptimizer stepCircleOptimizer;
private final transient UpdateSchemeOSM updateScheme;
private transient PotentialFieldTarget potentialFieldTarget;
private transient IPotentialFieldTarget potentialFieldTarget;
private transient PotentialFieldObstacle potentialFieldObstacle;
private transient PotentialFieldAgent potentialFieldPedestrian;
......@@ -66,7 +66,7 @@ public class PedestrianOSM extends Pedestrian {
@SuppressWarnings("unchecked")
PedestrianOSM(AttributesOSM attributesOSM,
AttributesAgent attributesPedestrian, Topography topography,
Random random, PotentialFieldTarget potentialFieldTarget,
Random random, IPotentialFieldTarget potentialFieldTarget,
PotentialFieldObstacle potentialFieldObstacle,
PotentialFieldAgent potentialFieldPedestrian,
List<SpeedAdjuster> speedAdjusters,
......@@ -217,7 +217,7 @@ public class PedestrianOSM extends Pedestrian {
public double getPotential(VPoint newPos) {
double targetPotential = potentialFieldTarget.getTargetPotential(newPos, this);
double targetPotential = potentialFieldTarget.getPotential(newPos, this);
double pedestrianPotential = potentialFieldPedestrian
.getAgentPotential(newPos, this, relevantPedestrians);
......@@ -235,10 +235,10 @@ public class PedestrianOSM extends Pedestrian {
// Getters...
public double getTargetPotential(VPoint pos) {
return potentialFieldTarget.getTargetPotential(pos, this);
return potentialFieldTarget.getPotential(pos, this);
}
public PotentialFieldTarget getPotentialFieldTarget() {
public IPotentialFieldTarget getPotentialFieldTarget() {
return potentialFieldTarget;
}
......
......@@ -49,11 +49,11 @@ public class SpeedAdjusterWeidmann implements SpeedAdjuster {
*
* HashSet<ScenarioElement> visiblePedestrians = new
* HashSet<ScenarioElement>(); double targetPotentialPed =
* potentialFieldTarget.getTargetPotential(targetIds, ped.getPosition());
* potentialFieldTarget.getPotential(targetIds, ped.getPosition());
*
* for (Pedestrian neighbor : closePedestrians) { double
* targetPotentialNeighbor =
* potentialFieldTarget.getTargetPotential(targetIds,
* potentialFieldTarget.getPotential(targetIds,
* neighbor.getPosition());
*
* // See OSM Paper if (targetPotentialPed - 0.1 > targetPotentialNeighbor)
......
......@@ -5,9 +5,7 @@ import java.util.LinkedList;
import java.util.List;
import org.vadere.simulator.models.osm.PedestrianOSM;
import org.vadere.simulator.models.potential.fields.IPotentialTargetGrid;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTargetGrid;
import org.vadere.state.attributes.models.AttributesOSM;
import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Topography;
......@@ -20,12 +18,12 @@ import org.vadere.util.potential.gradients.GradientProvider;
public class StepCircleOptimizerGradient implements StepCircleOptimizer {
private final AttributesOSM attributesOSM;
private final IPotentialTargetGrid potentialFieldTarget;
private final IPotentialFieldTargetGrid potentialFieldTarget;
private final List<Integer> targetIds;
private final Topography topography;
public StepCircleOptimizerGradient(Topography topography,
IPotentialTargetGrid potentialFieldTarget,
IPotentialFieldTargetGrid potentialFieldTarget,
AttributesOSM attributesOSM) {
this.attributesOSM = attributesOSM;
......
......@@ -5,7 +5,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.vadere.simulator.models.potential.fields.IPotentialTargetGrid;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTargetGrid;
import org.vadere.state.scenario.Obstacle;
import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Topography;
......@@ -33,7 +33,7 @@ public class FloorGradientProviderFactory {
*/
public static GradientProvider createFloorGradientProvider(
GradientProviderType type, Topography scenario,
Map<Integer, Target> targets, IPotentialTargetGrid potentialField) {
Map<Integer, Target> targets, IPotentialFieldTargetGrid potentialField) {
GradientProvider result = null;
// TODO [priority=low] [task=refactoring] refactor
......
......@@ -2,10 +2,10 @@ package org.vadere.simulator.models.potential;
import org.vadere.simulator.models.potential.fields.PotentialFieldAgent;
import org.vadere.simulator.models.potential.fields.PotentialFieldObstacle;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
public interface PotentialFieldModel {
PotentialFieldTarget getPotentialFieldTarget();
IPotentialFieldTarget getPotentialFieldTarget();
PotentialFieldObstacle getPotentialFieldObstacle();
PotentialFieldAgent getPotentialFieldAgent();
}
......@@ -10,17 +10,16 @@ import org.vadere.state.scenario.TargetPedestrian;
import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VShape;
import org.vadere.util.math.InterpolationUtil;
import org.vadere.util.potential.CellGrid;
import org.vadere.util.potential.calculators.EikonalSolver;
import java.awt.*;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
public abstract class AbstractPotentialFieldTarget implements IPotentialTargetGrid {
public abstract class AbstractPotentialFieldTarget implements IPotentialFieldTargetGrid {
protected static double EPSILON_SIM_TIME = 1e-100; // TODO [priority=medium] [task=fix] 1e-100 comparisons with values that are O(1e-8) are dangerous. Better use 1e-8 here.
protected double lastUpdateTimestamp;
......@@ -41,35 +40,33 @@ public abstract class AbstractPotentialFieldTarget implements IPotentialTargetGr
this.targetPotentialFields = new HashMap<>();
}
/**
*
* Returns the potential value of the static or dynamic target floor field.
* This does not take obstacle repulsion and pedestrian repulsion into
* account. This is specific to pedestrians. See pedestrian perception for
* more information.
*
*/
/**
* Returns the potential value of the static or dynamic target potential field.
* This does not take obstacle repulsion and pedestrian repulsion into
* account. This is specific to agents. See pedestrian perception for more information.
* The target potential does not exists (i.e. is equal to 0) if the agent has reached
* his target (geometrically) or the agent does not have a next target or there is no
* target potential field computed for the target of the agent (error!).
*
* @param pos the position for which the potential will be evaluated
* @param agent the agent for which the potential will be evaluated
* @return the target potential of the agent at position pos if it exists, and 0 otherwise.
*/
@Override
public double getTargetPotential(final VPoint pos, final Agent ped) {
public double getPotential(final VPoint pos, final Agent agent) {
if(!ped.hasNextTarget())
{
if(!agent.hasNextTarget()) {
return 0.0;
}
CellGrid potentialField;
double targetPotential = Double.MAX_VALUE;
int targetId = agent.getNextTargetId();
int targetId = ped.getNextTargetId();
// Pedestrian has reached the target
// TODO Is this necessary? The target controller changes the
// pedestrian's target as soon the pedestrian arrives it.
// the agent has reached his current target
if (topography.getTarget(targetId).getShape().contains(pos)) {
return 0; // the arrival time is zero
return 0.0;
}