Beispiel #1
0
static void setup(ulong32 *dk, ulong32 *k, ulong32 *uk)
{
   int n, t;
   ulong32 p[2];

   p[0] = dk[0]; p[1] = dk[1];

   t = 4;
   n = 0;
      pi1(p);
      pi2(p, k);
      uk[n++] = p[0];
      pi3(p, k);
      uk[n++] = p[1];
      pi4(p, k);
      uk[n++] = p[0];
      pi1(p);
      uk[n++] = p[1];
      pi2(p, k+t);
      uk[n++] = p[0];
      pi3(p, k+t);
      uk[n++] = p[1];
      pi4(p, k+t);
      uk[n++] = p[0];
      pi1(p);
      uk[n++] = p[1];
}
Beispiel #2
0
static void encrypt(ulong32 *p, int N, ulong32 *uk)
{
   int n, t;
   for (t = n = 0; ; ) {
      pi1(p); if (++n == N) break;
      pi2(p, uk+t); if (++n == N) break;
      pi3(p, uk+t); if (++n == N) break;
      pi4(p, uk+t); if (++n == N) break;
      t ^= 4;
   }
}
void tst_pods::testConstructors()
{
    PodI pi1;
    QCOMPARE(pi1.i(), 0);

    PodI pi2(1);
    QCOMPARE(pi2.i(), 1);

    PodI pi3(pi2);
    QCOMPARE(pi3.i(), pi2.i());
}
Beispiel #4
0
static void decrypt(ulong32 *p, int N, ulong32 *uk)
{
   int n, t;
   for (t = 4*((N&1)^1), n = N; ;  ) {
      switch (n >= 4 ? 4 : 0) {
         case 4: pi4(p, uk+t); --n;
         case 3: pi3(p, uk+t); --n;
         case 2: pi2(p, uk+t); --n;
         case 1: pi1(p); --n; break;
         case 0: return;
      }
      t ^= 4;
   }
} 
Beispiel #5
0
static bool IsQuadrangle(cv::Point2f p1,
                         cv::Point2f p2,
                         cv::Point2f p3,
                         cv::Point2f p4) {
  cv::Point2d pi1((int)p1.x, (int)p1.y);
  cv::Point2d pi2((int)p2.x, (int)p2.y);
  cv::Point2d pi3((int)p3.x, (int)p3.y);
  cv::Point2d pi4((int)p4.x, (int)p4.y);
  return !(IsOverlapped(pi1, pi2) ||
           IsOverlapped(pi1, pi3) ||
           IsOverlapped(pi1, pi4) ||
           IsOverlapped(pi2, pi3) ||
           IsOverlapped(pi2, pi4) ||
           IsOverlapped(pi3, pi4) ||
           IsLine(pi1, pi2, pi3) ||
           IsLine(pi1, pi2, pi4) ||
           IsLine(pi2, pi3, pi4));
}
void ofDrawRectOutline(const ofRectangle & rect, int thickness, ofDrawRectOutlineMode mode) {
    
    float b0, b1;
    if(mode == ofDrawRectOutlineModeOuter) {
        b0 = thickness;
        b1 = 0;
    } else if(mode == ofDrawRectOutlineModeInner) {
        b0 = 0;
        b1 = thickness;
    } else if(mode == ofDrawRectOutlineModeMiddle) {
        b0 = thickness * 0.5;
        b1 = thickness * 0.5;
    }
    
    ofVec2f po0(rect.x - b0, rect.y - b0);
    ofVec2f po1(rect.x + rect.width + b0, rect.y - b0);
    ofVec2f po2(rect.x + rect.width + b0, rect.y + rect.height + b0);
    ofVec2f po3(rect.x - b0, rect.y + rect.height + b0);
    
    ofVec2f pi0(rect.x + b1, rect.y + b1);
    ofVec2f pi1(rect.x + rect.width - b1, rect.y + b1);
    ofVec2f pi2(rect.x + rect.width - b1, rect.y + rect.height - b1);
    ofVec2f pi3(rect.x + b1, rect.y + rect.height - b1);
    
    ofBeginShape();

    ofVertex(po0.x, po0.y);
    ofVertex(po1.x, po1.y);
    ofVertex(po2.x, po2.y);
    ofVertex(po3.x, po3.y);
    
    ofNextContour();
    
    ofVertex(pi0.x, pi0.y);
    ofVertex(pi1.x, pi1.y);
    ofVertex(pi2.x, pi2.y);
    ofVertex(pi3.x, pi3.y);
    
    ofEndShape(true);
}