/** * Given a co-ord checks to see if a line from it passes through its influence circle to the * subsequent flanks associated with it. If it does then it is a rear unit. */ public void passesThrough(RCSInfluenceMapPosition enemy, String type_REAR) { this.enemy = enemy; this.enemyPos = enemy.getCenter(); RCSInfluenceMapPosition pos1; Rectangle2D.Double rect = new Rectangle2D.Double( center[0] - (totalValue / 2), center[1] - (totalValue / 2), totalValue, totalValue); // i =1 because the first element (0) is the front itself. for (int i = 1; i < owns.size(); i++) { pos1 = (RCSInfluenceMapPosition) owns.elementAt(i); if (rect.intersectsLine(enemyPos[0], enemyPos[1], pos1.getCenter()[0], pos1.getCenter()[1])) { pos1.setType(type_REAR); } } }