private void ir(int sonarId, float angle) {
        double[][] positions = Environment.inst().getPositions();
        double[] bearings = Environment.inst().getBearings();
        
        double sonarBearing = angle + bearings[robotId];
        
        float x1 = (float) positions[robotId][0];
        float y1 = (float) positions[robotId][1];
        float x2 = max*(float) Math.cos(Math.toRadians(sonarBearing)) + x1;
        float y2 = max*(float) Math.sin(Math.toRadians(sonarBearing)) + y1;
        
        for (int i = 0; i < positions.length; ++i) {
            if (i == robotId) {
                continue;
            }
            
            float distance = Intersection.circleIntersect(x1, y1, x2, y2, (float) positions[i][0], (float) positions[i][1], r);
            
            if (distance < readings[sonarId]) {
                readings[sonarId] = distance;
            }
        }
        
        float width = Environment.inst().getWidth();
        float height = Environment.inst().getHeight();
         
        float distance = Intersection.lineIntersect(x1, y1, x2, y2, 0, 0, width, 0);
        if (distance < readings[sonarId])
            readings[sonarId] = distance;
         
        distance = Intersection.lineIntersect(x1, y1, x2, y2, 0, 0, 0, height);
        if (distance < readings[sonarId])
            readings[sonarId] = distance;
         
        distance = Intersection.lineIntersect(x1, y1, x2, y2, width, height, width, 0);
        if (distance < readings[sonarId])
            readings[sonarId] = distance;
         
        distance = Intersection.lineIntersect(x1, y1, x2, y2, width, height, 0, height);
        if (distance < readings[sonarId])
            readings[sonarId] = distance;
         
        List obstacles = ObstacleContainer.inst().getObstacles();
        Iterator iter = obstacles.iterator();
        while (iter.hasNext()) {
            Obstacle o = (Obstacle) iter.next();
            distance = o.intersect(x1, y1, x2, y2);
            if (distance < readings[sonarId]) {
                readings[sonarId] = distance;
            }
        }
        
        readings[sonarId] -= (Environment.robotDiameter / 2);
    }