@Override public Double getValue(final Position p) { final double[] cord = p.getCartesianCoordinates(); return (cord[0] * a) + (cord[1] * b) + c; }
@Override public void moveNode(final Node<T> node, final Position direction) { final Position cur = getPosition(node); final double ox = cur.getCartesianCoordinates()[0]; final double oy = cur.getCartesianCoordinates()[1]; double nx = direction.getCartesianCoordinates()[0] + ox; double ny = direction.getCartesianCoordinates()[1] + oy; if (ox >= 0 && oy <= SIZE) { final Position next = next(ox, oy, nx, ny); nx = next.getCartesianCoordinates()[0] + ox; ny = next.getCartesianCoordinates()[1] + oy; if (nx < 1.0 && ny < 1.0 || nx > UPPER && ny > UPPER) { removeNode(node); } else { super.moveNode(node, next); } } }
@Override protected boolean isAllowed(final Position p) { final double[] coord = p.getCartesianCoordinates(); return allowed(coord[0], coord[1]); }
@Override public void moveNodeToPosition(final Node<T> node, final Position newPos) { final double[] cur = getPosition(node).getCartesianCoordinates(); final double[] np = newPos.getCartesianCoordinates(); // Calculate the next position allowed final Position next = next(cur[0], cur[1], np[0], np[1]); super.moveNodeToPosition(node, next); }
@Override public Tuple getCoordinates() { return DatatypeFactory.createTuple((Object[]) ArrayUtils.toObject(getDevicePosition().getCartesianCoordinates())); }
@Override public void moveNodeToPosition(final Node<Double> node, final Position newPos) { final double[] cur = getPosition(node).getCartesianCoordinates(); final double[] np = newPos.getCartesianCoordinates(); final Position nextWithinLimts = super.next(cur[0], cur[1], np[0], np[1]); if (node instanceof CellWithCircularArea) { final Position nextPos = findNearestFreePosition((CellWithCircularArea) node, new Continuous2DEuclidean(cur[0], cur[1]), nextWithinLimts); super.moveNodeToPosition(node, nextPos); } else { super.moveNodeToPosition(node, nextWithinLimts); } }
@Override public void addPolarization(final Position v) { final double[] tempCor = this.polarizationVersor.add(v).getCartesianCoordinates(); final double module = FastMath.sqrt(FastMath.pow(tempCor[0], 2) + FastMath.pow(tempCor[1], 2)); this.polarizationVersor = module == 0 ? new Continuous2DEuclidean(0, 0) : new Continuous2DEuclidean(tempCor[0] / module, tempCor[1] / module); }
@Override public void execute() { final double[] nodePos = env.getPosition(getNode()).getCartesianCoordinates(); .map(n -> { final double[] nPos = env.getPosition(n).getCartesianCoordinates();