void cNewO_OrInit2Im::CalcAmbig()
{
    if (! mBestSolIsInit) 
    {
        std::cout << "For Im " << mI1->Name() << " " << mI2->Name() << "\n";
        ELISE_ASSERT(false,"No sol cNewO_OrInit2Im::CalcAmbig");
    }

    CalcSegAmbig();


    if (mShow)
    {
       std::cout << "BOnH " << euclid(mIA)  << " " << euclid(mBestSol.tr()) << "\n";
       for (int aK=-8 ; aK<=8 ; aK++)
       {
            double aTeta = 0.0006 * aK;
            ElRotation3D aRes = SolOfAmbiguity(aTeta);
            double aCost = PixExactCost(aRes,0.1);
            std::cout << "Ambig " << aTeta 
                      << " Cost " << aCost ;
            if (mTestC2toC1) 
               std::cout << " DRef " <<  DistRot(*mTestC2toC1,aRes) ;
            // std::cout          << " Tr " << aRes.tr() ;
            std::cout          << "\n";
       }
    }
}
Pt3dr cCameraTiepRed::BundleIntersection(const Pt2df & aPH1,const cCameraTiepRed & aCam2,const Pt2df & aPH2,double & Precision) const
{

     Pt2dr aPC1 = Hom2Cam(aPH1);
     Pt2dr aPC2 = aCam2.Hom2Cam(aPH2);

     ElSeg3D aSeg1 = mCS->Capteur2RayTer(aPC1);
     ElSeg3D aSeg2 = aCam2.mCS->Capteur2RayTer(aPC2);

     bool Ok;
     double aD;
     Pt3dr aRes= InterSeg(aSeg1.P0(),aSeg1.P1(),aSeg2.P0(),aSeg2.P1(),Ok,&aD);

     if (Ok)
     {
         Pt2dr aRP1 = mCS->Ter2Capteur(aRes);
         Pt2dr aRP2 = aCam2.mCS->Ter2Capteur(aRes);
         Precision = (euclid(aRP1-aPC1)+euclid(aRP2-aPC2)) / 2.0;
     }
     else
     {
        Precision = 1e20;
     }
     
     return aRes;
    
}
Esempio n. 3
0
template <class T> INT get_best_intexe(const ElFifo<T> & fp,bool EnvConv)
{
   if (! fp.circ())
      return 0;

   if (fp.nb() < 4)
      return 0;


   INT delta = EnvConv ? 1 : std::min(5,(fp.nb()-2)/2);
   REAL min_cos = 10.0;
   INT best_index = 0;

   std::vector<INT> aVOk;
   std::vector<INT> aVPrec;
   std::vector<INT> aVSucc;

   for(INT aK=0 ; aK<INT(fp.size()) ; aK++)
   {
       aVOk.push_back(EnvConv ? 0 : 1);
       aVPrec.push_back(aK-delta);
       aVSucc.push_back(aK+delta);
   }
   if (EnvConv)
   {
      ElFilo<Pt2dr> aFLP;
      for(INT aK=0 ; aK<INT(fp.size()) ; aK++)
         aFLP.pushlast(fp[aK]);
      ElFifo<INT> Ind;
      env_conv(Ind,aFLP,true);
      for (INT aK=0 ; aK<Ind.nb() ; aK++)
      {
          aVOk[Ind[aK]] = 1;
          aVPrec[Ind[aK]] = Ind[(aK-1+Ind.nb())%Ind.nb()];
          aVSucc[Ind[aK]] = Ind[(aK+1)%Ind.nb()];
      }
   }

   for (INT k =0 ; k<fp.nb() ; k++)
   {
       if (aVOk[k])
       {
            T u1 = fp[k]-fp[aVPrec[k]];
            T u2 = fp[aVSucc[k]]-fp[k];
            double d1 = euclid(u1);
            double d2 = euclid(u2);
            if (d1 && d2)
            {
               double cosin = scal(u1,u2) / (d1*d2);
               if (cosin < min_cos)
               {
                  min_cos = cosin; 
                  best_index = k;
               }
            }
       }
   }
   return best_index ;
}
Esempio n. 4
0
int TD_Exemple_main(int argc,char ** argv)
{
    std::string aNameCam,aNameAppuis;
    std::string toto;

    ElInitArgMain
    (
        argc,argv,
        LArgMain()  << EAMC(aNameCam,"Name of camera")
                    << EAMC(aNameAppuis,"Name of GCP"),
        LArgMain()  << EAM(toto,"toto",true,"Do no stuff")
    );

	//On créé un objet camera (aCam) et un objet liste de points d'appui (aSetGCP)
    cTD_Camera aCam(aNameCam);
    cTD_SetAppuis aSetGCP(aNameAppuis);

	//Pour chaque point d'appui, on calcul la distance entre la coordonnée image données par le fichier et la coordonnée image projetée à partir du point 3D et des infos de camera
    for (int aKP=0 ; aKP<int(aSetGCP.PTer().size()) ; aKP++)
    {
         Pt3dr aPTer = aSetGCP.PTer()[aKP];//Point 3D
         Pt2dr aPIm  = aSetGCP.PIm()[aKP];//Point image

         Pt2dr aPProj = aCam.Ter2Image(aPTer);//Point projeté

         std::cout  << "dist[" << aKP << "]= " << euclid (aPIm,aPProj) << "\n";
    }

	//On créé 3 int correspondant à des identifiants de points d'appui
    int aK1,aK2,aK3;
    std::cout << "ENTER K1 K2 K3 \n";
    cin >>  aK1 >> aK2 >>  aK3;
	//Avec ces 3 points, on calcule les positions et orientations possibles de la caméra
	
    std::vector<cTD_Camera> aSols = aCam.RelvtEspace
                                    (
                                          aSetGCP.PTer()[aK1], aSetGCP.PIm()[aK1],
                                          aSetGCP.PTer()[aK2], aSetGCP.PIm()[aK2],
                                          aSetGCP.PTer()[aK3], aSetGCP.PIm()[aK3]
                                    );

	//Pour chaque solution, on calcul la distance entre la coordonnée image données par le fichier et la coordonnée image projetée à partir du point 3D et des infos calculées
    for (int aKS=0 ; aKS<int(aSols.size()) ; aKS++)
    {
         for (int aKP=0 ; aKP<int(aSetGCP.PTer().size()) ; aKP++)
         {
              Pt3dr aPTer = aSetGCP.PTer()[aKP];
              Pt2dr aPIm  = aSetGCP.PIm()[aKP];

              Pt2dr aPProj = aSols[aKS].Ter2Image(aPTer);

              std::cout  << "   dist " << euclid (aPIm,aPProj) << "\n";
         }
         std::cout << "========================================\n";
    }

    return 0;
}
template <class Type,class TBase> cElNuage3DMaille * cElN3D_EpipGen<Type,TBase>::V_ReScale
                                    (
                                        const Box2dr &aBox,
                                        double aScale,
                                        const cXML_ParamNuage3DMaille & aNewParam,
                                        Im2D_REAL4 anImPds,
                                        std::vector<Im2DGen*> aVNewAttr,
                                        std::vector<Im2DGen*> aVOldAttr
                                    ) 
{
    // RatioResolAltiPlani();

    // Im2DGen * anOld = this->mAttrs[0]->Im();


   // Fonc_Num aFoncProf = this->ReScaleAndClip(this->mImDef.in(0)*this->mIm.in(0),aBox._p0,aScale)/Max(1e-5,anImPds.in());

    /*
       for (int aKA=0 ; aKA<int(mAttrs.size()) ; aKA++)
       {
            Im2DGen * anOld = this->mAttrs[aKA]->Im();
            Im2DGen * aNew = anOld->ImOfSameType(Pt2di(aSz));

            aRes->mAttrs.push_back(new cLayerNuage3DM(aNew,mAttrs[aKA]->Name()));
        }
        aRes->mGrpAttr = mGrpAttr;
    */

   double aDifStd = 0.5;
   if (aNewParam.RatioResolAltiPlani().IsInit() && (aNewParam.Image_Profondeur().IsInit()))
   {
        ElAffin2D aAfM2C = Xml2EL(this->mParams.Orientation().OrIntImaM2C());
        double aResol = (euclid(aAfM2C.I10()) + euclid(aAfM2C.I01()))/2.0;

        aDifStd  = (1/aResol) * (1/this->mParams.Image_Profondeur().Val().ResolutionAlti())   * (this->mParams.RatioResolAltiPlani().Val()) ;
        aDifStd *= 0.5;
   }

   Im2D_REAL4 aRedProf = ReduceImageProf(aDifStd,this->mImDef,this->mIm,aBox,aScale,anImPds,aVNewAttr,aVOldAttr);
   Fonc_Num  aFoncProf = aRedProf.in();



   cElN3D_EpipGen<float,double> * aRes = new cElN3D_EpipGen<float,double>
                                             (
                                                 this->mDir,
                                                 aNewParam,
                                                 anImPds.in(0) > 0.1,
                                                 aFoncProf,
                                                 //   this->ReScaleAndClip(this->mImDef.in(0)*this->mIm.in(0),aBox._p0,aScale)/Max(1e-5,anImPds.in()),
                                                 mProfIsZ,
                                                 this->mEmptyData,
                                                 false
                                             );

   return aRes;
}
// Calcul les vecteur qui sont |_  dans un plan contenant la base
void cMEPCoCentrik::ComputePlanBase(const ElMatrix<REAL>  & aMat)
{
    Pt3di aRouge(255,0,0);
    Pt3di aVert(0,255,0);

    Pt3di aGrayFonc(64,64,64);
    Pt3di aGrayClair(180,180,180);
    double aMulP = 1.1;

    std::vector<Pt3dr> aVpt;
    for (int aKP =0 ; aKP< int(mVP1.size()) ; aKP++)
    {
         Pt3dr aQ1 = vunit(PZ1(mVP1[aKP]));
         Pt3dr aQ2 = aMat * vunit(PZ1(mVP2[aKP]));
         Pt3dr anOB = aQ1^aQ2;
         if (euclid(anOB) != 0)
         {
            anOB = vunit(anOB);
            if (mDoPly)
            {
                 mColPly.push_back(aRouge);
                 mPtsPly.push_back(anOB);


                 mColPly.push_back(aGrayFonc);
                 mPtsPly.push_back(aQ1*aMulP);
                 mColPly.push_back(aGrayClair);
                 mPtsPly.push_back(aQ2*aMulP);
            } 
            mVPlanBase.push_back(anOB);
          }
    }


    if (mDoPly)
    {
         for (int aK=0 ; aK<10000  ; aK++)
         {
              int aKA = NRrandom3(mVPlanBase.size());
              int aKB = NRrandom3(mVPlanBase.size());

             
              Pt3dr aBase = mVPlanBase[aKA] ^  mVPlanBase[aKB];
              if (euclid (aBase)>1e-6)
              {
                  mColPly.push_back(aVert);
                  mPtsPly.push_back(vunit(aBase));
              }

         }
    }
}
void  cEqObsRotVect::AddObservation
      (
           Pt3dr aDir1,
           Pt3dr aDir2,
           double aPds,
           bool WithD2
      )
{
    mN1.SetEtat(aDir1/euclid(aDir1));
    mN2.SetEtat(aDir2/euclid(aDir2));

    mSet.AddEqFonctToSys(mFoncEqResidu,aPds,WithD2);
}
Esempio n. 8
0
/**
 * Precompute GCD and bounds transformations
 */
static int
diophantine_precompute(unsigned int n,
                       diophantine_term_t *E,
                       diophantine_term_t *Ep,
                       npy_int64 *Gamma, npy_int64 *Epsilon)
{
    npy_int64 a_gcd, gamma, epsilon, c1, c2;
    unsigned int j;
    char overflow = 0;

    assert(n >= 2);

    euclid(E[0].a, E[1].a, &a_gcd, &gamma, &epsilon);
    Ep[0].a = a_gcd;
    Gamma[0] = gamma;
    Epsilon[0] = epsilon;

    if (n > 2) {
        c1 = E[0].a / a_gcd;
        c2 = E[1].a / a_gcd;

        /* Ep[0].ub = E[0].ub * c1 + E[1].ub * c2; */
        Ep[0].ub = safe_add(safe_mul(E[0].ub, c1, &overflow),
                            safe_mul(E[1].ub, c2, &overflow), &overflow);
        if (overflow) {
            return 1;
        }
    }

    for (j = 2; j < n; ++j) {
        euclid(Ep[j-2].a, E[j].a, &a_gcd, &gamma, &epsilon);
        Ep[j-1].a = a_gcd;
        Gamma[j-1] = gamma;
        Epsilon[j-1] = epsilon;

        if (j < n - 1) {
            c1 = Ep[j-2].a / a_gcd;
            c2 = E[j].a / a_gcd;

            /* Ep[j-1].ub = c1 * Ep[j-2].ub + c2 * E[j].ub; */
            Ep[j-1].ub = safe_add(safe_mul(c1, Ep[j-2].ub, &overflow),
                                  safe_mul(c2, E[j].ub, &overflow), &overflow);

            if (overflow) {
                return 1;
            }
        }
    }

    return 0;
}
void RationalNumber::normalize() {
	// get gdc
	unsigned short int gcd = euclid(nomi(), deno());
	// normalize with gdc
	m_nomi /= gcd;
	m_deno /= gcd;
}
Esempio n. 10
0
void bench_inter_Hor()
{

   for (INT k=0; k<5000 ; k++)
   {
       Pt2dr p0 = random_pt();
       Pt2dr p1 = random_pt();
       if (std::abs(p0.y-p1.y)<1e-2)
          p1.y += 1;
       SegComp aSp(p0,p1);

       REAL anY =  NRrandom3() *100;
       Pt2dr q0 (0,anY);
       Pt2dr q1 (1,anY);

       SegComp aSq(q0,q1);

       bool OkInter;
       Pt2dr aInter0 = aSp.inter(aSq,OkInter);
       Pt2dr aInter2(aSp.AbsiceInterDroiteHoriz(anY),anY);

       REAL DH = euclid(aInter0,aInter2) ;
       BENCH_ASSERT(DH<BIG_epsilon);
   }
}
Esempio n. 11
0
void bench_seg_mean_square()
{
    for (int i = 0; i<100 ; i++)
    {
        INT nx = (INT) (10 +NRrandom3()*20);
        INT ny = nx  -5;

        Pt2dr  tr = Pt2dr((NRrandom3()-0.5)*1e4,(NRrandom3()-0.5)*1e4);
        Pt2dr  rot = Pt2dr::FromPolar(1.0,NRrandom3() *100);

        RMat_Inertie m;
        for (int x= -nx; x <= nx ; x++)
            for (int y= -ny; y <= ny ; y++)
            {
                 Pt2dr Z = tr+rot*Pt2dr(x,y);
                 m.add_pt_en_place(Z.x,Z.y);
            }

        Seg2d s = seg_mean_square(m,100.0);
        Pt2dr cdg = s.p0();
        Pt2dr all = (s.p1()-s.p0())/ 100.0;

        BENCH_ASSERT
        (
                (euclid(cdg-tr) < BIG_epsilon)
             && (std::abs(all^rot)   < BIG_epsilon)
        );

        // BENCH_ASSERT(Abs(d0 -d1) < BIG_epsilon);
   }
}
Esempio n. 12
0
void bench_dist_InerMat_seg_droite()
{
    for (int i = 0; i<100 ; i++)
    {
        Pt2dr p1  = Pt2dr((NRrandom3()-0.5)*1e4,(NRrandom3()-0.5)*1e4);
        Pt2dr p2 = p1;

        while (euclid(p1-p2) < 1e2)
              p2  = Pt2dr((NRrandom3()-0.5)*1e4,(NRrandom3()-0.5)*1e4);

        SegComp s(p1,p2);
        int nb = (int)(50 * NRrandom3());
        REAL d0 = 0.0;
        RMat_Inertie m;
        for (int j =0; j<nb ; j++)
        {
             Pt2dr q  = Pt2dr((NRrandom3()-0.5)*1e4,(NRrandom3()-0.5)*1e4);
             REAL pds = NRrandom3();
             m = m.plus_cple(q.x,q.y,pds);
             d0 += pds * s.square_dist_droite(q);
        }
        REAL d1 = square_dist_droite(s,m);

        BENCH_ASSERT(std::abs(d0 -d1) < BIG_epsilon);
    }
}
Esempio n. 13
0
/* Extended Euclidean algorithm */
static gcd extended_euclid(int a, int b) {
    #ifndef MAX
        #define MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
        #define MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
    #endif
    return euclid(MAX(a, b), MIN(a, b));
}
Esempio n. 14
0
void  cDistorBilin::Diff(ElMatrix<REAL> & aM,Pt2dr aP) const
{
    // InitEtatFromCorner(ToCoordGrid(aP));

    Pt2dr aPds;
    GetParamCorner(mCurCorner,aPds,ToCoordGrid(aP)); 
    const Pt2dr & aP00 =  Dist(mCurCorner+CamBilinCorn[0] ) ;
    const Pt2dr & aP10 =  Dist(mCurCorner+CamBilinCorn[1] ) ;
    const Pt2dr & aP01 =  Dist(mCurCorner+CamBilinCorn[2] ) ;
    const Pt2dr & aP11 =  Dist(mCurCorner+CamBilinCorn[3] ) ;


    Pt2dr aGx =    ((aP10-aP00)*aPds.y + (aP11-aP01)*(1-aPds.y))  / mStep.x;
    Pt2dr aGy =    ((aP01-aP00)*aPds.x + (aP11-aP10)*(1-aPds.x))  / mStep.y;

    aM.ResizeInside(2,2);
    SetCol(aM,0,aGx);
    SetCol(aM,1,aGy);

    // A conserver, verification par diff std
    if (0)
    {
        ElMatrix<REAL> aM2(2,2);
        DiffByDiffFinies(aM2,aP,euclid(mStep)/1e4);
        static double aDMax = 0;
        double aD = aM.L2(aM2);
        if (aD>aDMax)
        {
            aDMax = aD;
            std::cout << "DDDD " << aD << "\n";
        }
    }
    // InitEtatFromCorner(ToCoordGrid(aP));

}
REAL cDbleGrid::Focale()
{
    Pt2dr aPP = PP();
    Pt2dr aP1 = Direct(aPP+Pt2dr(1,0));
    Pt2dr aP2 = Direct(aPP+Pt2dr(-1,0));
    return  2.0 / euclid(aP1,aP2);
}
template <class Type,class TBase>  void  cElNuage3DMaille_FromImProf<Type,TBase>::VerifParams() const
{
    const cXML_ParamNuage3DMaille&  aNuage =  this->Params(); 

    for
    (
          std::list<cVerifNuage>::const_iterator itVN=aNuage.VerifNuage().begin();
          itVN != aNuage.VerifNuage().end();
          itVN++
    )
    {
          Pt3dr aP1 = itVN->PointEuclid();
          Pt3dr aP2 = Loc_IndexAndProf2Euclid(itVN->IndIm(),PTab2PReel(itVN->Profondeur()));

          double aDist =  euclid(aP1-aP2);
          if (aDist>=aNuage.TolVerifNuage().Val())
          {
               cElWarning::ToVerifNuage.AddWarn
               (
                      "Dist = " + ToString(aDist) + " " + ToString(aP1.x) + " " +ToString(aP1.y) ,
                      __LINE__,
                     __FILE__
               );
          }
    }
}
Esempio n. 17
0
void cEqHomogFormelle::StdRepondere(ElPackHomologue & aPack,REAL aCoeff)
{
    cElHomographie H1 = HF1().HomCur();
    cElHomographie H2 = HF2().HomCur();
    ElDistRadiale_PolynImpair Dist(1e5,Pt2dr(0,0));
    if (DRF()) 
       Dist = DRF()->DistCur();

    for
    (
         ElPackHomologue::iterator it=aPack.begin();
         it!=aPack.end();
         it++
    )
    {
          Pt2dr aP1 = it->P1();
          Pt2dr aP2 = it->P2();
          if (mDRF)
          {
              aP1 = Dist.Direct(aP1);
              aP2 = Dist.Direct(aP2);
          }
          Pt2dr Ec = H1.Direct(Dist.Direct(it->P1())) - H2.Direct(Dist.Direct(it->P2()));

          REAL D = euclid(Ec);
         
          REAL Pds = 1 / (1 + ElSquare(D/aCoeff));
          it->Pds() = Pds;
    }
}
Esempio n. 18
0
int euclid(int m, int n)
{
    if (n == 0)
        return m;

    return euclid(n, m % n);
}
Esempio n. 19
0
int BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx)
	{
	BIGNUM *a,*b,*t;
	int ret=0;

	bn_check_top(in_a);
	bn_check_top(in_b);

	BN_CTX_start(ctx);
	a = BN_CTX_get(ctx);
	b = BN_CTX_get(ctx);
	if (a == NULL || b == NULL) goto err;

	if (BN_copy(a,in_a) == NULL) goto err;
	if (BN_copy(b,in_b) == NULL) goto err;
	a->neg = 0;
	b->neg = 0;

	if (BN_cmp(a,b) < 0) { t=a; a=b; b=t; }
	t=euclid(a,b);
	if (t == NULL) goto err;

	if (BN_copy(r,t) == NULL) goto err;
	ret=1;
err:
	BN_CTX_end(ctx);
	bn_check_top(r);
	return(ret);
	}
Pt3dr cMEPCoCentrik::ComputeBase()
{
    Pt3dr aBest(0,0,0);
    double aScoreMin = 1e20;

    for (int aK1=0 ; aK1<int(mVPlanBase.size()); aK1++)
    {
         Pt3dr aCdtBase = mVPlanBase[aK1];
         double aScore = 0;
         for (int aK2=0 ; aK2<int(mVPlanBase.size()); aK2++)
         {
               Pt3dr aP2 = mVPlanBase[aK2];
               if (scal(aP2,aCdtBase) < 0) aP2 = -aP2;
               double aDist = euclid(aP2-aCdtBase);
               aDist =  CoutAttenueTetaMax(aDist,0.3);
               aScore += aDist;
         }
         if (aScore < aScoreMin)
         {
              aScoreMin = aScore;
              aBest = aCdtBase;
         }
    }
    return aBest;
}
Esempio n. 21
0
void TestOneCorner(ElCamera * aCam,const Pt2dr&  aP, const Pt2dr&  aG)
{
     Pt2dr aQ0 = aCam->DistDirecte(aP);
     Pt2dr aQ1 = aCam->DistDirecte(aP+aG);

     std::cout <<  " Grad " << (aQ1-aQ0 -aG) / euclid(aG) << " For " << aP << "\n";
}
Esempio n. 22
0
double cNewO_CombineCple::CostOneBase(const Pt3dr & aBase)
{
    // mCurBase = mVCdtSel[anArc.x]->NormQ1Q2() ^ mVCdtSel[anArc.y]->NormQ1Q2();
    mCurBase = aBase;
    double aNormBase = euclid(mCurBase);
    if (aNormBase<1e-9) return 1e9;
    mCurBase = mCurBase / aNormBase;

    double aRes = 0;
    double aStepTeta=  ((2*PI*mCurStep) / mNbStepTeta) / 2.0 ;

    // std::cout << "aStepTeta= " << aStepTeta << "\n";


    for (int aK =0 ;  aK < int (mVCdtSel.size()) ; aK++)
    {
         ElSeg3D aS1(Pt3dr(0,0,0),mVCdtSel[aK]->mQ1);
         ElSeg3D aS2(mCurBase,mCurBase+mVCdtSel[aK]->mQ2);

         Pt3dr anI = aS1.PseudoInter(aS2);
         double aDist = aS1.DistDoite(anI);
         double aA1 = ElAbs(aS1.AbscOfProj(anI));
         double aA2 = ElAbs(aS1.AbscOfProj(anI));

         double anEc = aDist/aA1 + aDist/aA2;

          
          aRes +=   (anEc*aStepTeta) / (anEc + aStepTeta);
    }

    return  aRes / mVCdtSel.size();
}
Esempio n. 23
0
int euclid(int a,int b)
{
    if(b==0)
        return a;
    else
        return euclid(b,a%b);
}
Esempio n. 24
0
int main(void)
{
  int a, b;
  scanf("%d%d", &a, &b);
  printf("euclid(%d, %d) = %d\n", a, b, euclid(a, b));

  return 0;
}
Esempio n. 25
0
inline vector<T, REFCNT> euclid
(
    const vector<T, REFCNT>& a,
    const vector<T1, REFCNT1>& b
)
{
    return euclid(a, b, factory<T>());
}
Esempio n. 26
0
int euclidasm(int m, int n){
  int r;
  if (n>0)
    r = euclid(n,m %n);
  else 
    r = m;
  return r;
}
Esempio n. 27
0
void gen_euclid(int n)
{
    int g = a[0];
    FOR(i,1,n) g = euclid(g, a[i], X[i], Y[i]);
    LL mult = 1;
    FORD(i,n,1) v[i] = (mult * Y[i]) % m, mult = (mult * X[i]) % m;
    v[0] = mult;
}
Esempio n. 28
0
INT  Approx_poly::one_pass_pcc()
{
	SomApproxPoly * som;
     for
     (
        som = prem_som()->_next;
        (som != 0);
        som = som->_next
     )
     {
         SomApproxPoly * ancetre = som->_pred;
         bool found = false;

         for
         (
             int step = 0;
             (ancetre!=0) && (step!= _arg._nb_jump);
             ancetre = ancetre->_pred , step++
         )
         {
              Seg2d  seg = _calc_seg(ancetre,som);
              Pt2dr p0 = seg.p0(); 
              Pt2dr p1 = seg.p1(); 
              if (euclid(p0-p1) < 1e-5)
                 p1 = p1 + Pt2dr(1e-5,1e-5);
              SegComp  SComp (p0,p1);

              REAL cost =   ancetre->_cost
                          + _arg._prec
                          + _calc_cout(ancetre,som,SComp,_arg);
              if ((!found) || (cost <  som->_cost))
              {
                   som->_cost = cost;
                   som->_best_anc = ancetre;
                   found = true;
              }
         }
         El_Internal.ElAssert
         (
             found,
             EEM0 << "Incoherence in approx_polygonale"
         );
     }

     INT res = 1;
     som = last_som();
     for
     (
           SomApproxPoly * pred = som->_best_anc    ;
          (pred != 0)                               ;
          som = pred, pred =pred->_best_anc, res++
     )
     {
           som->_pred = pred;
           pred->_next = som;
     }
     return res;
}
Esempio n. 29
0
void PbHom(const std::string & anOri)
{
   const std::string & aDir = "/media/data1/Calib-Sony/FacadePlane-2000/";
   const std::string & aIm1 = "DSC05180.ARW";
   const std::string & aIm2 = "DSC05182.ARW";


   cInterfChantierNameManipulateur * aICNM = cInterfChantierNameManipulateur::BasicAlloc(aDir);
   std::string    aKeyOri =  "[email protected]" + anOri;


    std::string aNameOri1 =  aICNM->Assoc1To1(aKeyOri,aIm1,true);
    std::string aNameOri2 =  aICNM->Assoc1To1(aKeyOri,aIm2,true);


    CamStenope * aCS1 = CamOrientGenFromFile(aNameOri1,aICNM);
    CamStenope * aCS2 = CamOrientGenFromFile(aNameOri2,aICNM);

    Pt2dr aP1 (774,443);
    Pt2dr aP2 (5541,3758);

    Pt3dr aTer1  = aCS1->ImEtProf2Terrain(aP1,1.0);
    Pt2dr aProj1 = aCS1->R3toF2(aTer1);

    std::cout << "P & Proj Init1" << aP1 << aProj1 << " " << euclid(aP1-aProj1) << "\n";


    Pt3dr aTer2  = aCS2->ImEtProf2Terrain(aP2,1.0);
    Pt2dr aProj2 = aCS2->R3toF2(aTer2);

    std::cout << "P & Proj Init2" << aP2 << aProj2 << " " << euclid(aP2-aProj2) << "\n";


    double aDist;
    Pt3dr aTerInter = aCS1->PseudoInter(aP1,*aCS2,aP2,&aDist);

    aProj1 = aCS1->R3toF2(aTerInter);
    aProj2 = aCS2->R3toF2(aTerInter);

    std::cout << "Proj Inter " << aDist << " " << (aP1-aProj1) << " " << (aP2-aProj2) << "\n";



    std::cout << "\n";
}
Esempio n. 30
0
cElHJaSomEmpr::cElHJaSomEmpr
(
     Pt2dr           aPos,
     const cElHJaSomEmpr * aPrec
) :
  mPos    (aPos),
  mACurv  (aPrec ? (aPrec->mACurv + euclid(aPrec->mPos,mPos)) : 0)
{
}