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

some code refactoring inside potentialField-classes.

parent c3f30c06
Pipeline #55213 passed with stage
in 45 seconds
...@@ -5,6 +5,7 @@ import java.util.Collection; ...@@ -5,6 +5,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import org.apache.commons.math.util.MathUtils;
import org.apache.log4j.LogManager; import org.apache.log4j.LogManager;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.vadere.simulator.models.Model; import org.vadere.simulator.models.Model;
...@@ -74,9 +75,17 @@ public class PotentialFieldObstacleCompactSoftshell implements PotentialFieldObs ...@@ -74,9 +75,17 @@ public class PotentialFieldObstacleCompactSoftshell implements PotentialFieldObs
} }
@Override @Override
public Vector2D getObstaclePotentialGradient(VPoint pos, public Vector2D getObstaclePotentialGradient(VPoint pos, Agent pedestrian) {
Agent pedestrian) { throw new UnsupportedOperationException("not jet implemented.");
throw new UnsupportedOperationException("this method is not jet implemented."); /*double epsilon = 0.0000001;
VPoint dxPos = pos.add(new VPoint(pos.getX() + MathUtils.EPSILON, pos.getY()));
VPoint dyPos = pos.add(new VPoint(pos.getX(), pos.getY() + MathUtils.EPSILON));
double potential = getObstaclePotential(pos, pedestrian);
double dx = (getObstaclePotential(dxPos, pedestrian) - potential) / epsilon;
double dy = (getObstaclePotential(dyPos, pedestrian) - potential) / epsilon;
return new Vector2D(dx, dy);*/
} }
@Override @Override
......
...@@ -5,6 +5,7 @@ import java.util.LinkedList; ...@@ -5,6 +5,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import org.apache.commons.math.util.MathUtils;
import org.vadere.simulator.models.Model; import org.vadere.simulator.models.Model;
import org.vadere.simulator.models.potential.fields.PotentialFieldAgent; import org.vadere.simulator.models.potential.fields.PotentialFieldAgent;
import org.vadere.state.attributes.Attributes; import org.vadere.state.attributes.Attributes;
...@@ -39,14 +40,9 @@ public class PotentialFieldPedestrianCompactSoftshell implements PotentialFieldA ...@@ -39,14 +40,9 @@ public class PotentialFieldPedestrianCompactSoftshell implements PotentialFieldA
@Override @Override
public Collection<Pedestrian> getRelevantAgents(VCircle relevantArea, public Collection<Pedestrian> getRelevantAgents(VCircle relevantArea,
Agent pedestrian, Topography scenario) { Agent pedestrian, Topography scenario) {
List<Pedestrian> result = new LinkedList<>();
List<Pedestrian> closePedestrians = scenario.getSpatialMap(Pedestrian.class) List<Pedestrian> closePedestrians = scenario.getSpatialMap(Pedestrian.class)
.getObjects(relevantArea.getCenter(), this.personalWidth + 0.5); .getObjects(relevantArea.getCenter(), this.personalWidth + 0.5);
return closePedestrians;
result = closePedestrians;
return result;
} }
@Override @Override
...@@ -98,6 +94,18 @@ public class PotentialFieldPedestrianCompactSoftshell implements PotentialFieldA ...@@ -98,6 +94,18 @@ public class PotentialFieldPedestrianCompactSoftshell implements PotentialFieldA
public Vector2D getAgentPotentialGradient(VPoint pos, public Vector2D getAgentPotentialGradient(VPoint pos,
Vector2D velocity, Agent pedestrian, Vector2D velocity, Agent pedestrian,
Collection<? extends Agent> otherPedestrians) { Collection<? extends Agent> otherPedestrians) {
throw new UnsupportedOperationException("this method is not jet implemented."); throw new UnsupportedOperationException("not jet implemented.");
/*double epsilon = 0.001;
double dx = 0;
double dy = 0;
VPoint dxPos = pos.add(new VPoint(pos.getX() + MathUtils.EPSILON, pos.getY()));
VPoint dyPos = pos.add(new VPoint(pos.getX(), pos.getY() + MathUtils.EPSILON));
double potential = getAgentPotential(pos, pedestrian, otherPedestrians);
dx = (getAgentPotential(dxPos, pedestrian, otherPedestrians) - potential) / epsilon;
dy = (getAgentPotential(dyPos, pedestrian, otherPedestrians) - potential) / epsilon;
return new Vector2D(dx, dy);*/
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment