本文整理汇总了Java中rescuecore2.misc.geometry.Point2D类的典型用法代码示例。如果您正苦于以下问题:Java Point2D类的具体用法?Java Point2D怎么用?Java Point2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Point2D类属于rescuecore2.misc.geometry包,在下文中一共展示了Point2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderClearArea
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
private void renderClearArea(AKClearArea clear) {
try {
Point2D position = Util.getPoint(world.getEntity(clear.getAgentID()).getLocation(world));
Polygon clearPolygon = Util.transform(Util.clearAreaRectangle(position.getX(), position.getY(), clear.getDestinationX(), clear.getDestinationY(), CLEAR_RADIUS), t);
if (clearPolygon == null) {
return;
}
g.setColor(Color.WHITE);
g.draw(clearPolygon);
} catch (Exception ignore) {
ignore.printStackTrace();
}
renderHumanAction(world.getEntity(clear.getAgentID()), CLEAR_COLOUR, null);
}
示例2: intersect
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
private boolean intersect(double agentX, double agentY, double pointX, double pointY, Blockade blockade)
{
List<Line2D> lines = GeometryTools2D.pointsToLines(GeometryTools2D.vertexArrayToPoints(blockade.getApexes()), true);
for (Line2D line : lines)
{
Point2D start = line.getOrigin();
Point2D end = line.getEndPoint();
double startX = start.getX();
double startY = start.getY();
double endX = end.getX();
double endY = end.getY();
if (java.awt.geom.Line2D.linesIntersect(
agentX, agentY, pointX, pointY,
startX, startY, endX, endY
))
{
return true;
}
}
return false;
}
示例3: getVector
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
public Vector2D getVector(Point2D agentPos, Point2D targetPos, Road road) {
EntityID roadID = road.getID();
if (!this.clearListMap.containsKey(roadID)) {
this.analysisRoad(road);
}
List<Edge> edges = road.getEdges();
if (this.canStraightForward(agentPos, targetPos, roadID, edges)) {
return targetPos.minus(agentPos).normalised().scale(1000000);
} else {
Point2D edgePoint;
Point2D min = null;
for (Edge edge : edges) {
edgePoint = PositionUtil.getEdgePoint(edge);
if (this.canStraightForward(agentPos, edgePoint, roadID, edges)) {
min = min != null ? PositionUtil.compareDistance(agentPos, min, edgePoint).translate(0.0D, 0.0D) : edgePoint.translate(0.0D, 0.0D);
}
}
return min == null ? targetPos.minus(agentPos).normalised().scale(1000000) : min.minus(agentPos).normalised().scale(1000000);
}
}
示例4: analysisRoad
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
public void analysisRoad(Road road) {
EntityID roadID = road.getID();
if (this.clearListMap.containsKey(roadID)) {
return;
}
List<List<Edge>> neighbourEdges = new ArrayList<>();
List<Point2D> passablePoint = new ArrayList<>();
road.getEdges().stream().filter(Edge::isPassable).forEach(edge -> {
List<Edge> edges = new ArrayList<>(((Area) this.getWorld().getEntity(edge.getNeighbour())).getEdges());
edges.remove(edge);
neighbourEdges.add(edges);
passablePoint.add(PositionUtil.getEdgePoint(edge));
});
List<Point2D> clearList;
if (road.getBlockades().isEmpty()) {
clearList = new ArrayList<>();
this.impassableSelector.remove(road);
} else {
clearList = new ArrayList<>(passablePoint);
this.impassableSelector.add(road);
}
this.neighbourEdgesMap.put(roadID, neighbourEdges);
this.passablePointMap.put(roadID, passablePoint);
this.clearListMap.put(roadID, clearList);
}
示例5: getVector
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
public Vector2D getVector(Point2D agentPos, Area location, Point2D targetPos) {
EntityID areaID = location.getID();
List<Edge> edges = location.getEdges();
if (this.canStraightForward(agentPos, targetPos, areaID, edges)) {
return targetPos.minus(agentPos).normalised().scale(1000000);
} else {
Point2D edgePoint;
Point2D min = null;
for (Edge edge : edges) {
edgePoint = PositionUtil.getEdgePoint(edge);
if (this.canStraightForward(agentPos, edgePoint, areaID, edges)) {
min = min != null ? PositionUtil.compareDistance(agentPos, min, edgePoint).translate(0.0D, 0.0D) : edgePoint.translate(0.0D, 0.0D);
}
}
return min == null ? targetPos.minus(agentPos).normalised().scale(1000000) : min.minus(agentPos).normalised().scale(1000000);
}
}
示例6: isInside
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
private boolean isInside(double pX, double pY, int[] apex)
{
Point2D p = new Point2D(pX, pY);
Vector2D v1 = (new Point2D(apex[apex.length - 2], apex[apex.length - 1])).minus(p);
Vector2D v2 = (new Point2D(apex[0], apex[1])).minus(p);
double theta = this.getAngle(v1, v2);
for (int i = 0; i < apex.length - 2; i += 2)
{
v1 = (new Point2D(apex[i], apex[i + 1])).minus(p);
v2 = (new Point2D(apex[i + 2], apex[i + 3])).minus(p);
theta += this.getAngle(v1, v2);
}
return Math.round(Math.abs((theta / 2) / Math.PI)) >= 1;
}
示例7: preparation
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
@Override
public void preparation(Config config, MessageManager messageManager) {
this.routeSearcher = new SampleRouteSearcher(this, new RouteManager(this.world));
this.impassableSelector = new SampleImpassableSelector(this);
//Police
this.agentPoint = new Point2D[2];
this.beforeMove = false;
this.neighbourEdgesMap = new HashMap<>();
this.passablePointMap = new HashMap<>();
this.clearListMap = new HashMap<>();
this.beforeMove = false;
this.count = -1;
}
示例8: getClearList
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
public List<Point2D> getClearList(Road road) {
EntityID roadID = road.getID();
if (!this.clearListMap.containsKey(roadID)) {
this.analysisRoad(road);
}
return this.clearListMap.get(roadID);
}
示例9: removeTargetPoint
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
public void removeTargetPoint(Road road, Point2D point) {
EntityID roadID = road.getID();
List<Point2D> clearList = this.clearListMap.get(roadID);
clearList.remove(point);
this.clearListMap.put(roadID, clearList);
if (clearList.isEmpty()) {
this.impassableSelector.remove(road);
}
}
示例10: canStraightForward
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
public boolean canStraightForward(Point2D point, Point2D targetPoint, EntityID roadID, Collection<Edge> edges) {
for (Edge edge : edges) {
if (this.linesIntersect(point, targetPoint, edge)) {
return false;
}
}
for (List<Edge> list : this.neighbourEdgesMap.get(roadID)) {
if (!this.canStraightForward(point, targetPoint, list)) {
return false;
}
}
return true;
}
示例11: linesIntersect
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
public boolean linesIntersect(Point2D point, Point2D targetPoint, Edge edge) {
Point2D start = edge.getStart();
double startX = start.getX();
double startY = start.getY();
Point2D end = edge.getEnd();
double endX = end.getX();
double endY = end.getY();
return Line2D.linesIntersect(point.getX(), point.getY(), targetPoint.getX(), targetPoint.getY(), startX, startY, endX, endY) && !PositionUtil.equalsPoint(targetPoint, ((startX + endX) / 2.0D), (startY + endX) / 2.0D, 10.0D);
}
示例12: getNearPosition
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
public static Point2D getNearPosition(Point2D position, Collection<Point2D> targets) {
Point2D result = null;
for(Point2D target : targets) {
result = (result != null) ? compareDistance(position, result, target) : target;
}
return result;
}
示例13: preparation
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
@Override
public void preparation(Config config, MessageManager messageManager) {
this.routeSearcher = this.initRouteSearcher();
this.impassableSelector = this.initImpassableSelector();
this.agentPoint = new Point2D[2];
this.beforeMove = false;
this.neighbourEdgesMap = new HashMap<>();
this.passablePointMap = new HashMap<>();
this.clearListMap = new HashMap<>();
this.beforeMove = false;
this.count = -1;
}
示例14: getAction
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
public ActionClear getAction(TacticsPolice tactics, Point2D targetPos) {
Vector2D vector = this.getVector(new Point2D(tactics.getOwner().getX(), tactics.getOwner().getY()), (Area)tactics.location, targetPos);
if(vector == null) {
return null;
}
return new ActionClear(
tactics,
(int) (tactics.getOwner().getX() + vector.getX()),
(int) (tactics.getOwner().getY() + vector.getY())
);
}
示例15: canStraightForward
import rescuecore2.misc.geometry.Point2D; //导入依赖的package包/类
public boolean canStraightForward(Point2D point, Point2D targetPoint, EntityID roadID, Collection<Edge> edges) {
for (Edge edge : edges) {
if (this.linesIntersect(point, targetPoint, edge)) {
return false;
}
}
return this.canStraightForward(point, targetPoint, this.points.getNeighbourEdges(roadID));
}