Exemple #1
0
/*****************************************************************************
*** Single-Cross Calculus (SCC) 
*****************************************************************************/
std::string getSCC_Relation_String( int m, Point ptOrigin, Point ptRelatum, Point ptReferent) {
  if(ptOrigin == ptRelatum) {
    // return ":error";
    // dou/tri not included in the original definition
    if(ptOrigin == ptReferent) {
      return "tri";      
    } else {
      return "dou";      
    }
  }
  // Point origin( 0,0 );
  
  CAngle angle;
  char cString[20];
  std::string sResult;
  // Teil 1: A,B ? C
  if( ptRelatum == ptReferent) {
    return (std::string)"b";
    // sprintf( cString, "%c\0", 'b');
  } else {
    Point c( ptReferent );
    angle = -ptOrigin.GetAngleTo( ptRelatum );
    c.Rotate( angle.get(), ptRelatum );
    sprintf( cString, "%d\0", calculateOrientationSegmentOPRA( 2, ptRelatum.GetAngleTo( c ) ));
  }
  sResult += cString;
  return sResult;
}
Exemple #2
0
std::vector< int > getOPRA_Relation3(int m,
                                     Point ptA, double oriA,
                                     Point ptB, double oriB) {
    int relAB, relBA;

    Point ptOrigin( 0,0 );

    std::vector< int > result;
    CAngle cangleA(oriA);
    CAngle cangleB(oriB);

    CAngle cangleAB = ptA.GetAngleTo( ptB );
    CAngle cangleBA = ptB.GetAngleTo( ptA );

    CAngle angleI = cangleAB - cangleA + cangleB;
    CAngle angleJ = cangleBA - cangleB + cangleA;

    relAB = calculateOrientationSegmentOPRA( m, angleI.get() );
    relBA = calculateOrientationSegmentOPRA( m, angleJ.get() );

    if( ptA == ptB ) {
        result.push_back( relBA );
    } else {

        result.push_back( relAB );
        result.push_back( relBA );
    }
    return result;
}
Exemple #3
0
std::string getQTC_Relation_String( Point pt_K1, Point pt_K2, Point pt_L1, Point pt_L2){	
   std::string sResult;
   std::vector< int > relation_C13;
   std::vector< int > relation_C24;
   // Result: [Rel_K1_K2, Rel_K2_K1]
   relation_C13 = getOPRA_Relation(2, pt_K1, pt_K1.GetAngleTo(pt_L1), pt_K2, pt_K2.GetAngleTo(pt_K1));
   // Result: [Rel_L1_L2, Rel_L2_L1]
   relation_C24 = getOPRA_Relation(2, pt_L1, pt_K1.GetAngleTo(pt_L1), pt_K2, pt_L2.GetAngleTo(pt_L1));
   // C1: K with respect to L1 (front/back)
   if( relation_C13[0]==0 || relation_C13[0]==1 || relation_C13[0]==7 ){ sResult += "-";}
   else if( relation_C13[0]==2 || relation_C13[0]==6 ){ sResult += "0";}
   else if( relation_C13[0]==3 || relation_C13[0]==4 || relation_C13[0]==5 ){ sResult += "+";}
   else { cout << "PROBLEMS C1" << endl;}
   // C2: L with respect to K1 (front/back)
   if( relation_C24[0]==0 || relation_C24[0]==1 || relation_C24[0]==7 ){ sResult += "-";}
   else if( relation_C24[0]==2 || relation_C24[0]==6 ){ sResult += "0";}
   else if( relation_C24[0]==3 || relation_C24[0]==4 || relation_C24[0]==5 ){ sResult += "+";}
   else { cout << "PROBLEMS C2" << endl;}
   // C3: K with respect to K1/L1 (left/right)
   if( relation_C13[0]==1 || relation_C13[0]==2 || relation_C13[0]==3 ){ sResult += "-";}
   else if( relation_C13[0]==0 || relation_C13[0]==4 ){ sResult += "0";}
   else if( relation_C13[0]==5 || relation_C13[0]==6 || relation_C13[0]==7 ){ sResult += "+";}
   else { cout << "PROBLEMS C3" << endl;}
   // C4: L with respect to L1/¬K1 (left/right)
   if( relation_C24[0]==1 || relation_C24[0]==2 || relation_C24[0]==3 ){ sResult += "-";}
   else if( relation_C24[0]==0 || relation_C24[0]==4 ){ sResult += "0";}
   else if( relation_C24[0]==5 || relation_C24[0]==6 || relation_C24[0]==7 ){ sResult += "+";}
   else { cout << "PROBLEMS C4" << endl;}
   return sResult;
}
Exemple #4
0
std::vector< int > getOPRA_Relation2(int m,
                                     Point ptA, double oriA,
                                     Point ptB, double oriB) {
    int relAB, relBA;
    std::vector< int > result;
    CAngle cangleA(oriA);
    CAngle cangleB(oriB);

    BB_DBG(2) << "Punkt A: " << ptA << ":" << cangleA << " & Punkt B: " << ptB << ":" << cangleB << endl;
    ptB.Rotate( -cangleA.get(), ptA );
    cangleB = cangleB - cangleA;
    BB_DBG(2) << "Punkt A: " << ptA << ":" << cangleA-cangleA << " & Punkt B: " << ptB << ":" << cangleB << endl;

    CAngle cangleAB = ptA.GetAngleTo( ptB );
    CAngle cangleBA = ptB.GetAngleTo( ptA );
    cangleBA -= cangleB;
    BB_DBG(2) << "Relative Angle: (AB:" << cangleAB << ") & (BA:" << cangleBA << ")" << endl;

    relAB = calculateOrientationSegmentOPRA( m, cangleAB.get() );
    relBA = calculateOrientationSegmentOPRA( m, cangleBA.get() );

    if( ptA == ptB ) {
        result.push_back( relBA );
    } else {

        result.push_back( relAB );
        result.push_back( relBA );
    }
    return result;
}
Exemple #5
0
/*****************************************************************************
*** Double-Cross Calculus (DCC) 
*****************************************************************************/
std::string getDCC_Relation_String( int m, Point ptOrigin, Point ptRelatum, Point ptReferent) {

    CAngle angle;
    char cString[20];
    std::string sResult;
    // Now orientation given if origin == relatum => i (following [Fre92])
    if( ptOrigin == ptRelatum) {
      if( ptRelatum == ptReferent) {
        return (std::string)"tri"; // A = B = C => 'tri'
      } else {
	return (std::string)"dou"; // A = B != C => 'dou'
      }
      // sprintf( cString, "%c\0", 'b');
    }
    // Teil 1: A,B ? C
    if( ptRelatum == ptReferent) {
        return (std::string)"b_4";
        // sprintf( cString, "%c\0", 'b');
    } else {
        Point c( ptReferent );
        angle = -ptOrigin.GetAngleTo( ptRelatum );
        c.Rotate( angle.get(), ptRelatum );
        sprintf( cString, "%d_\0", calculateOrientationSegmentOPRA( m, ptRelatum.GetAngleTo( c ) ));
    }
    sResult += cString;

    // Teil 2: B,A ? C
    if( ptOrigin == ptReferent) {
        // sprintf( cString, "%c\0", 'a');
        return (std::string)"4_a";
    } else {
        Point c( ptReferent );
        angle = -ptRelatum.GetAngleTo( ptOrigin );
        c.Rotate( angle.get(), ptOrigin );
        sprintf( cString, "%d\0", calculateOrientationSegmentOPRA( m, ptOrigin.GetAngleTo( c ) ));
    }
    sResult += cString;
    return sResult;
}
Exemple #6
0
std::vector< char > getDC_Relation( int m,
                                    Point ptStartA,
                                    Point ptEndA,
                                    Point ptStartB,
                                    Point ptEndB) {
    std::vector< int > pre_result;
    std::vector< char > result;

    std::vector< Line > lines;
    std::vector< Point > points;

    Line lineA(ptStartA, ptEndA);
    Line lineB(ptStartB, ptEndB);

    lines.push_back( lineA );
    lines.push_back( lineA );
    lines.push_back( lineB );
    lines.push_back( lineB );

    points.push_back( ptStartB );
    points.push_back( ptEndB );
    points.push_back( ptStartA );
    points.push_back( ptEndA );

    pre_result.push_back( lineA.GetSide(ptStartB) );
    pre_result.push_back( lineA.GetSide(ptEndB) );
    pre_result.push_back( lineB.GetSide(ptStartA) );
    pre_result.push_back( lineB.GetSide(ptEndA) );

    // if DRA no 3 points are allowed on a line
    // DRA:	r,l
    // DRA_c:	r,l & e,s
    // DRA_f:	r,l & e,s & b,i,f
    // DRA_fp:	r,l & e,s & b,i,f + 5th position: A,P,+,-

    for( unsigned int index=0; index<4; index++) {
        // calculate relation char
        int side = lines[index].GetSide( points[index] );
        if(  side == (-1)) {
            result.push_back( 'l' );
        } else if( side == 1) {
            result.push_back( 'r' );
        } else { // =0 => on line
            if( lines[index].ptStart == points[index] )
                result.push_back( 's' );
            else if( lines[index].ptEnd == points[index] )
                result.push_back( 'e' );
            else {
                int OnLine = lines[index].PositionOnLineSegment( points[index] );
                if( lines[index].PositionOnLineSegment( points[index] ) == (-1))
                    result.push_back( 'b' );
                else if( lines[index].PositionOnLineSegment( points[index] ) == 0)
                    result.push_back( 'i' );
                else if( lines[index].PositionOnLineSegment( points[index] ) == (1))
                    result.push_back( 'f' );
                else {
                    cout << "( :error )" << endl;
                    exit(-1);
                }
            }
        }
    }
    // Restrictions for the specific Dipole cases
    if( m==DRA ) {
        for( unsigned int i=0; i<4; i++) {
            if(result[i]=='s' || result[i]=='e' || result[i]=='b' || result[i]=='i' || result[i]=='f' ) {
                result.clear();
            }
        }
    }
    if( m==DRA_c ) {
        for( unsigned int i=0; i<4; i++) {
            if( result[i]=='b' || result[i]=='i' || result[i]=='f' ) {
                result.clear();
            }
        }
    }
    //    if( m==DRA ) { // nothing to be done
    //     }


    if( m==DRA_fp ) {
        if( lineA.IsParallelTo( lineB )) {
            string str;
            for( int i=0; i<result.size();i++ ) {
                str += result[i];
                if( str=="sese" || str=="ffbb" || str=="efbs" || str=="ifbi" ||
                        str=="bfii" || str=="sfsi" || str=="beie" || str=="bbff" ||
                        str=="bsef" || str=="biif" || str=="iibf" || str=="sisf" ||
                        str=="iebe" || str=="rrll"  || str=="llrr" ) {
                    result.push_back( 'P' ); // Allen cases
                }
                if( str=="eses" || str=="ffff" || str=="fefe" || str=="fifi" ||
                        str=="fbii" || str=="fsei" || str=="ebis" || str=="iifb" ||
                        str=="eifs" || str=="iseb" || str=="bbbb" || str=="sbsb" ||
                        str=="ibib" || str=="rrrr" || str=="llll") {
                    result.push_back( 'A' ); // Converse Allen cases
                }
            }
        } else {
            //         Point ptCut;
            //         if( lineA.IsParallelTo( lineB )) {
            //             // now is the question if A or P
            //             if( lineA == lineB ) {
            //                 string str;
            //                 for( int i=0; i<result.size();i++ ) {
            //                     str += result[i];
            //                 }
            //                 result.push_back( '*' );
            //             } else {
            //                 Line lineX( ptStartA, ptStartB);
            //                 Line lineY( ptEndA, ptEndB);
            //                 if( lineX.GetCut( lineY, ptCut ) <= 0 ) { // no cut => P
            //                     result.push_back( 'A' );
            //                 } else {
            //                     result.push_back( 'P' );
            //                 }
            //             }
            //         } else {
            //             // calculate mathematical orientation
            //             if( lineB.GetAngle()-lineA.GetAngle() > 0 ) {
            //                 result.push_back( '-' );
            //             } else { // lineB.GetAngle()-lineA.GetAngle() < 0
            //                 result.push_back( '+' );
            //             }
            //         }
            // Shift all points by -sA
            Point ptOrigin( 0,0);
            //cout << "Line A: " << ptStartA << ptEndA << "  & Line B: " << ptStartB << ptEndB << endl;
            ptEndA.Shift( ptOrigin - ptStartA );
            ptStartB.Shift( ptOrigin - ptStartA );
            ptEndB.Shift( ptOrigin - ptStartA );
            ptStartA.Shift( ptOrigin - ptStartA );
            //cout << "Line A: " << ptStartA << ptEndA << "  & Line B: " << ptStartB << ptEndB << endl;
            // Rotate all points by -phi(eA)
            float angle = ptStartA.GetAngleTo( ptEndA );
            ptStartA.Rotate( -angle );
            ptEndA.Rotate( -angle );
            ptStartB.Rotate( -angle );
            ptEndB.Rotate( -angle );
            //cout << "Line A: " << ptStartA << ptEndA << "  & Line B: " << ptStartB << ptEndB << endl;
            // Shift eB by -sB
            ptEndB.Shift( ptOrigin - ptStartB );
            ptStartB.Shift( ptOrigin - ptStartB );
            //cout << "Line A: " << ptStartA << ptEndA << "  & Line B: " << ptStartB << ptEndB << endl;
            //             if(ptEndB.Y()>-0.0001 && ptEndB.Y()<0.0001) {
            //                 // lines are parallel => A or P (epsilon due to shift/rotate errors)
            //                 if( ptEndB.X()>0 ) {
            //                     result.push_back( 'P' );
            //                 } else if( ptEndB.X()<0 ) {
            //                     result.push_back( 'A' );
            //                 } else {
            //                     result.push_back( '*' );
            //                 }
            //             } else
            if(ptEndB.Y()>0) {
                result.push_back( '+' );
            } else if(ptEndB.Y()<0) {
                result.push_back( '-' );
            }
        }
    }
    return result;
}