/** * \brief Pulling : The movement of agents by a shrinking biofilm. Move calculated and added to * the agents movement vector. * * <p>The movement of agents by a shrinking biofilm. Move calculated and added to the agents * movement vector. * * @param aNeighbor Reference to the potentially shoving neighbour * @param isMutual Whether movement is shared between two agents or applied only to this one * @param gain Double noting change in position * @return Boolean stating whether pulling is detected (true) or not (false) */ public boolean addSpringMovement(LocatedAgent aNeighbor, boolean isMutual, double gain) { double d, distance, delta; if (aNeighbor == this) return false; // Build the escape vector and find the distance between you and your // neighbourhood d = computeDifferenceVector(_location, aNeighbor._location); _diff.normalizeVector(); distance = getShoveRadius() + aNeighbor.getShoveRadius(); distance += getSpeciesParam().shoveLimit; delta = d - distance; double lMax = _totalRadius; if (delta > 0) gain *= Math.exp(-delta * 5 / (lMax)); if (delta > lMax) gain = 0; /* Apply shoving _________________________________________________ */ if (isMutual) { _diff.times(-0.5 * delta * gain); this._movement.add(_diff); aNeighbor._movement.subtract(_diff); } else { _diff.times(-delta * gain); this._movement.add(_diff); } return (_movement.norm() > _radius * gain); }
/** * \brief With the agent move calculated, apply this movement, taking care to respect boundary * conditions * * <p>With the agent move calculated, apply this movement, taking care to respect boundary * conditions */ public double move() { if (!_movement.isValid()) { LogFile.writeLog("Incorrect movement coordinates"); _movement.reset(); } if (!_agentGrid.is3D && _movement.z != 0) { _movement.z = 0; _movement.reset(); LogFile.writeLog("Try to move in z direction !"); } // No movement planned, finish here if (_movement.isZero()) return 0; // Test the boundaries checkBoundaries(); // Now apply the movement _location.set(_newLoc); _agentGrid.registerMove(this); double delta = _movement.norm(); _movement.reset(); return delta / _totalRadius; }
/** * \brief Determine if an agent has a move to perform * * <p>Determine if an agent has a move to perform * * @return Boolean noting whether the agent has a move to perform */ public boolean isMoving() { return (_movement.norm() > _totalRadius / 10); }