Example #1
0
void GpsNmea::bLRauenberg(double x, double y, double z,
                          double *b, double *l, double *h)
{
    double f, f1, f2, ft;
    double p, eq;
    const double abes = 6377397.155;      // Bessel Semi-Major Axis =
                                          // Equatorial Radius in meter
    const double bbes = 6356078.962;      // Bessel Semi-Minor Axis =
                                          // Polar Radius in meter

    f  = M_PI * 50.0 / 180.0;
    p  = z / sqrt(x*x + y*y);
    eq = (abes*abes - bbes*bbes) / (abes*abes);

    do
    {
        f1 = newF(f, x, y, p, eq, abes);
        f2 = f;
        f  = f1;
        ft = 180.0 * f1 / M_PI;
    }
    while(!(fabs(f2 - f1) < 10E-10));

    *b = f;
    *l = atan(y/x);
    *h = sqrt(x*x + y*y)/cos(f1) - abes/
         sqrt(1 - eq * sin(f1) * sin(f1));
}
Example #2
0
    forAllConstIter(Map<point>, cellToMidPoint, iter)
    {
        label celli = iter.key();

        label midPointi = addedPoints_[celli];

        const cell& cFaces = mesh_.cells()[celli];

        const labelList& cEdges = mesh_.cellEdges()[celli];

        forAll(cEdges, i)
        {
            label edgeI = cEdges[i];
            const edge& e = mesh_.edges()[edgeI];

            // Get the faces on the cell using the edge
            label face0, face1;
            meshTools::getEdgeFaces(mesh_, celli, edgeI, face0, face1);

            // Get the cells on both sides of the face by indexing into cFaces.
            // (since newly created cells are stored in cFaces order)
            const labelList& newCells = cellToCells[celli];

            label cell0 = newCells[findIndex(cFaces, face0)];
            label cell1 = newCells[findIndex(cFaces, face1)];

            if (cell0 < cell1)
            {
                // Construct face to midpoint that is pointing away from
                // (pyramid split off from) celli

                const face& f0 = mesh_.faces()[face0];

                label index = findIndex(f0, e[0]);

                bool edgeInFaceOrder = (f0[f0.fcIndex(index)] == e[1]);

                // Check if celli is the face owner

                face newF(3);
                if (edgeInFaceOrder == (mesh_.faceOwner()[face0] == celli))
                {
                    // edge used in face order.
                    newF[0] = e[1];
                    newF[1] = e[0];
                    newF[2] = midPointi;
                }
                else
                {
                    newF[0] = e[0];
                    newF[1] = e[1];
                    newF[2] = midPointi;
                }

                // Now newF points away from cell0
                meshMod.setAction
                (
                    polyAddFace
                    (
                        newF,                       // face
                        cell0,                      // owner
                        cell1,                      // neighbour
                        -1,                         // master point
                        -1,                         // master edge
                        face0,                      // master face for addition
                        false,                      // flux flip
                        -1,                         // patch for face
                        -1,                         // zone for face
                        false                       // face zone flip
                    )
                );
            }
            else
            {
                // Construct face to midpoint that is pointing away from
                // (pyramid split off from) celli

                const face& f1 = mesh_.faces()[face1];

                label index = findIndex(f1, e[0]);

                bool edgeInFaceOrder = (f1[f1.fcIndex(index)] == e[1]);

                // Check if celli is the face owner

                face newF(3);
                if (edgeInFaceOrder == (mesh_.faceOwner()[face1] == celli))
                {
                    // edge used in face order.
                    newF[0] = e[1];
                    newF[1] = e[0];
                    newF[2] = midPointi;
                }
                else
                {
                    newF[0] = e[0];
                    newF[1] = e[1];
                    newF[2] = midPointi;
                }

                // Now newF points away from cell1
                meshMod.setAction
                (
                    polyAddFace
                    (
                        newF,                       // face
                        cell1,                      // owner
                        cell0,                      // neighbour
                        -1,                         // master point
                        -1,                         // master edge
                        face0,                      // master face for addition
                        false,                      // flux flip
                        -1,                         // patch for face
                        -1,                         // zone for face
                        false                       // face zone flip
                    )
                );
            }
        }
void DoComparison(TString newFileName, TString oldFileName, vector<TString> newHistName, vector<TString> oldHistName)
{
  TFile newF(newFileName,"read");
  TDirectory *newDir = newF.GetDirectory("Merged");

  TFile old(oldFileName);

  TFile output("Comparison.root","update");

  assert(newHistName.size() == oldHistName.size());


  vector<TH1D*> newHists;
  vector<TH1D*> oldHists;
  
  for(UInt_t i = 0; i < newHistName.size(); i++) {
    TH1D *newH = (TH1D*)newDir->Get(newHistName[i]);
    if(!newH) {
      cout<<"Could not find "<<newHistName[i]<< " in "<<newDir->GetName()<<endl;
      return;
    }
    TH1D *oldH = (TH1D*)old.Get(oldHistName[i]);
    if(!oldH) {
      cout<<"Could not find "<<oldHistName[i]<< " in "<<old.GetName()<<endl;
      return;
    }
    
    newHists.push_back(newH);
    oldHists.push_back(oldH);
  }

  for(UInt_t i = 0; i < newHists.size(); i++) {

    // Make ratio
    TH1D *ratio = (TH1D*)newHists[i]->Clone();
    ratio->Divide(oldHists[i]);

    ratio->SetDirectory(0);
    TString newName = newHists[i]->GetName();
    newName += "Ratio";
    ratio->SetName(newName);
    ratio->SetTitle(newName);
    ratio->SetMarkerStyle(20);
    output.cd();
    ratio->Write(newName, TObject::kOverwrite);
    cout<<"Wrote "<<newName<<" to "<< output.GetName()<<endl;

    // Make difference
    TH1D *difference = (TH1D*)newHists[i]->Clone();
    difference->Add(oldHists[i],-1.);
    difference->SetDirectory(0);
    newName = newHists[i]->GetName();
    newName += "Difference";
    difference->SetName(newName);
    difference->SetTitle(newName);
    difference->SetMarkerStyle(20);
    output.cd();
    difference->Write(newName, TObject::kOverwrite);
    cout<<"Wrote "<<newName<<" to "<< output.GetName()<<endl;

    // Make side by side plot
    TString canName = "Canvas";
    canName += newHists[i]->GetName();
    canName += "Comparison";
    TCanvas *can = new TCanvas(canName, canName);
    newHists[i]->SetLineColor(kBlack);
    newHists[i]->SetMarkerStyle(20);
    newHists[i]->SetMarkerColor(kBlack);
    oldHists[i]->SetLineColor(kRed);
    oldHists[i]->SetMarkerStyle(20);
    oldHists[i]->SetMarkerColor(kRed);
    oldHists[i]->Draw();
    newHists[i]->Draw("same");
    can->Write(canName, TObject::kOverwrite);
    delete can; can = NULL;
  }

}