app/src/main/java/com/jxlc/tajiproject/algorithm/AntiCollisionAlgorithm.java
// so if isMaster is true, it will be execute twice
so if isMaster is true, it will be execute twice
so if isMaster is true it will be execute twice
private void putAngle2IntersectValue(IntersectValue value, TowerCraneInfo info1,
                                         TowerCraneInfo info2, boolean isMaster) {
        int comType = value.intersectType;
        if (!isMaster) {
            if (comType == INTERSECT_TYPE_2REACH1) comType = INTERSECT_TYPE_1REACH2;
            else if (comType == INTERSECT_TYPE_1REACH2) comType = INTERSECT_TYPE_2REACH1;
        }
        float x1 = info1.getCoordinateX();
        float x2 = info2.getCoordinateX();
        float y1 = info1.getCoordinateY();
        float y2 = info2.getCoordinateY();
        switch (comType) {
            case INTERSECT_TYPE_ONLYFRONT: {
                float L1 = info1.getFrontArmLength();
                float L2 = info2.getFrontArmLength();
                AngleSaver saver = new AngleSaver();
                obtainAngle(x1, x2, y1, y2, L1, L2, saver);
                if (isMaster) {
                    value.towerOneFFAngleMin = saver.min;
                    value.towerOneFFAngleMax = saver.max;
                } else {
                    value.towerTwoFFAngleMin = saver.min;
                    value.towerTwoFFAngleMax = saver.max;
                }
                break;
            }
            case INTERSECT_TYPE_2REACH1: {
                float L1 = info1.getRearArmLength();
                float L2 = info2.getFrontArmLength();
                AngleSaver saver = new AngleSaver();
                obtainAngle(x1, x2, y1, y2, L1, L2, saver);
                if (isMaster) {
                    value.towerOneBFAngleMin = saver.min;
                    value.towerOneBFAngleMax = saver.max;
                } else {
                    value.towerTwoBFAngleMin = saver.min;
                    value.towerTwoBFAngleMax = saver.max;
                }
                break;
            }
            case INTERSECT_TYPE_1REACH2: {
                float L1 = info1.getFrontArmLength();
                float L2 = info2.getRearArmLength();
                AngleSaver saver = new AngleSaver();
                obtainAngle(x1, x2, y1, y2, L1, L2, saver);
                if (isMaster) {
                    value.towerOneFBAngleMin = saver.min;
                    value.towerOneFBAngleMax = saver.max;
                } else {
                    value.towerTwoFBAngleMin = saver.min;
                    value.towerTwoFBAngleMax = saver.max;
                }
                break;
            }
            case INTERSECT_TYPE_REACHEACHOTHER: {
                break;
            }
            default:
                break;
        }
        if (isMaster) {
            putAngle2IntersectValue(value, info2, info1, false);
        }
    }
private void putAngle2IntersectValue ( IntersectValue value , TowerCraneInfo info1 , TowerCraneInfo info2 , boolean isMaster ) { int comType = value . intersectType ; if ( ! isMaster ) { if ( comType == INTERSECT_TYPE_2REACH1 ) comType = INTERSECT_TYPE_1REACH2 ; else if ( comType == INTERSECT_TYPE_1REACH2 ) comType = INTERSECT_TYPE_2REACH1 ; } float x1 = info1 . getCoordinateX ( ) ; float x2 = info2 . getCoordinateX ( ) ; float y1 = info1 . getCoordinateY ( ) ; float y2 = info2 . getCoordinateY ( ) ; switch ( comType ) { case INTERSECT_TYPE_ONLYFRONT : { float L1 = info1 . getFrontArmLength ( ) ; float L2 = info2 . getFrontArmLength ( ) ; AngleSaver saver = new AngleSaver ( ) ; obtainAngle ( x1 , x2 , y1 , y2 , L1 , L2 , saver ) ; if ( isMaster ) { value . towerOneFFAngleMin = saver . min ; value . towerOneFFAngleMax = saver . max ; } else { value . towerTwoFFAngleMin = saver . min ; value . towerTwoFFAngleMax = saver . max ; } break ; } case INTERSECT_TYPE_2REACH1 : { float L1 = info1 . getRearArmLength ( ) ; float L2 = info2 . getFrontArmLength ( ) ; AngleSaver saver = new AngleSaver ( ) ; obtainAngle ( x1 , x2 , y1 , y2 , L1 , L2 , saver ) ; if ( isMaster ) { value . towerOneBFAngleMin = saver . min ; value . towerOneBFAngleMax = saver . max ; } else { value . towerTwoBFAngleMin = saver . min ; value . towerTwoBFAngleMax = saver . max ; } break ; } case INTERSECT_TYPE_1REACH2 : { float L1 = info1 . getFrontArmLength ( ) ; float L2 = info2 . getRearArmLength ( ) ; AngleSaver saver = new AngleSaver ( ) ; obtainAngle ( x1 , x2 , y1 , y2 , L1 , L2 , saver ) ; if ( isMaster ) { value . towerOneFBAngleMin = saver . min ; value . towerOneFBAngleMax = saver . max ; } else { value . towerTwoFBAngleMin = saver . min ; value . towerTwoFBAngleMax = saver . max ; } break ; } case INTERSECT_TYPE_REACHEACHOTHER : { break ; } default : break ; } if ( isMaster ) { putAngle2IntersectValue ( value , info2 , info1 , false ) ; } }
so if isMaster is true, it will be execute twice
so if isMaster is true it will be execute twice