int main() { TruckCarrier tr1, tr2("Pink", "Jaguar", 30, "BB-3333", "BREAK", "Samuel", 14, 14, 56, -4); tr1.showAllInfo(); tr2.showAllInfo(); return 0; }
void TestQgsCoordinateTransform::isShortCircuited() { QgsCoordinateTransform tr; //invalid transform shortcircuits QVERIFY( tr.isShortCircuited() ); QgsCoordinateReferenceSystem srs1; srs1.createFromSrid( 3994 ); QgsCoordinateReferenceSystem srs2; srs2.createFromSrid( 4326 ); // valid source, invalid destination QgsCoordinateTransform tr2( srs1, QgsCoordinateReferenceSystem() ); QVERIFY( tr2.isShortCircuited() ); // invalid source, valid destination QgsCoordinateTransform tr3( QgsCoordinateReferenceSystem(), srs2 ); QVERIFY( tr3.isShortCircuited() ); // equal, valid source and destination QgsCoordinateTransform tr4( srs1, srs1 ); QVERIFY( tr4.isShortCircuited() ); // valid but different source and destination QgsCoordinateTransform tr5( srs1, srs2 ); QVERIFY( !tr5.isShortCircuited() ); // try to short circuit by changing dest tr5.setDestinationCrs( srs1 ); QVERIFY( tr5.isShortCircuited() ); }
bool egcd(const bigint &b1, const bigint &b2, bigint &dr, bigint &r1, bigint &r2) const { bool scs; bigint dd(0), ppr1(0), ppr2(0), pr1(0), pr2(0), q, r(0), tr1(0), tr2(0); if(compare(b1, b2) > 0) { dd = b1; dr = b2; pr1 = one; pr2.init(); } else { dd = b2; dr = b1; pr1.init(); pr2 = one; } r1 = pr2; r2 = pr1; while((scs = divide(dd, dr, q, r)) && r.capacity() > 0) { ppr1 = pr1; ppr2 = pr2; pr1 = r1; pr2 = r2; tr1.init(); tr2.init(); if(!(scs = (signedmultiply(q, pr1, tr1) && signedsubtract(ppr1, tr1, r1) && signedmultiply(q, pr2, tr2) && signedsubtract(ppr2, tr2, r2)))) { break; } dd = dr; dr = r; q.init(); r.init(); } return scs; }
void TestQgsCoordinateTransform::isValid() { QgsCoordinateTransform tr; QVERIFY( !tr.isValid() ); QgsCoordinateReferenceSystem srs1; srs1.createFromSrid( 3994 ); QgsCoordinateReferenceSystem srs2; srs2.createFromSrid( 4326 ); // valid source, invalid destination QgsCoordinateTransform tr2( srs1, QgsCoordinateReferenceSystem() ); QVERIFY( !tr2.isValid() ); // invalid source, valid destination QgsCoordinateTransform tr3( QgsCoordinateReferenceSystem(), srs2 ); QVERIFY( !tr3.isValid() ); // valid source, valid destination QgsCoordinateTransform tr4( srs1, srs2 ); QVERIFY( tr4.isValid() ); // try to invalidate by setting source as invalid tr4.setSourceCrs( QgsCoordinateReferenceSystem() ); QVERIFY( !tr4.isValid() ); QgsCoordinateTransform tr5( srs1, srs2 ); // try to invalidate by setting destination as invalid tr5.setDestinationCrs( QgsCoordinateReferenceSystem() ); QVERIFY( !tr5.isValid() ); }
vector<vector<double> > getTransformadaMundo(Coordenada wCentro, Window * window){ Coordenada tr(-1*wCentro.getX(),-1*wCentro.getY(),1); vector<vector<double> > m = manipulaMtr->getTranslacao(tr); m = manipulaMtr->multiplicaMatriz(m, manipulaMtr->getRotacao(-1*angulo)); Coordenada tr2(2/window->getLargura(),2/window->getAltura(),1); m = manipulaMtr->multiplicaMatriz(m, manipulaMtr->getEscalonamento(tr2)); return m; }
int main() { std::thread tr1(stepLeft); std::thread tr2(stepRight); tr1.join(); tr2.join(); }
bool InverseTransformationElement::getTransformation(const base::Time& atTime, bool doInterpolation, transformer::TransformationType& tr) { if(nonInverseElement->getTransformation(atTime, doInterpolation, tr)){ Eigen::Affine3d tr2(Eigen::Affine3d::Identity()); tr2 = tr; tr2 = tr2.inverse(); tr.setTransform(tr2); std::swap(tr.sourceFrame, tr.targetFrame); return true; } return false; };
void test_SHARC2() { SumOfSines vox1(196), vox2(196), vox3(196), vox4(196), vox5(196); SHARC_Library * lib; SHARC_Spectrum * sp1, * sp2, * sp3, * sp4, * sp5; lib = new SHARC_Library("../../../Code/sharc"); // access a spectrum, load it into a SumOfSines, and scale it by a triangle envelope sp1 = lib->spectrum_named("altoflute_vibrato", "g3"); vox1.add_partials(csl_min(sp1->_num_partials, 20), sp1->_partials); vox1.create_cache(); // cache the waveform (since it's a harmonic overtone spectrum) Triangle tr1(3, 0.75); vox1.set_scale(tr1); // repeat for 3 other delayed examples sp2 = lib->spectrum_named("bass_clarinet", "g3"); vox2.add_partials(csl_min(sp2->_num_partials, 20), sp2->_partials); vox2.create_cache(); // cache the waveform Triangle tr2(3, 0.75); vox2.set_scale(tr2); sp3 = lib->spectrum_named("cello_vibrato", "g3"); vox3.add_partials(csl_min(sp3->_num_partials, 20), sp3->_partials); vox3.create_cache(); // cache the waveform Triangle tr3(3, 0.75); vox3.set_scale(tr3); sp4 = lib->spectrum_named("trombone", "g3"); vox4.add_partials(csl_min(sp4->_num_partials, 20), sp4->_partials); vox4.create_cache(); // cache the waveform Triangle tr4(3, 0.75); vox4.set_scale(tr4); sp5 = lib->spectrum_named("violin_martele", "g3"); vox5.add_partials(csl_min(sp4->_num_partials, 20), sp4->_partials); vox5.create_cache(); // cache the waveform Triangle tr5(3, 0.75); vox5.set_scale(tr5); Mixer mix(2); // create a stereo mixer mix.add_input(vox1); mix.add_input(vox2); mix.add_input(vox3); mix.add_input(vox4); mix.add_input(vox5); logMsg("playing SumOfSines mix..."); // I don't use run_test() here because I need to trigger the envelopes while it's playing gIO->set_root(mix); // turn it on tr1.trigger(); // trigger the 1st envelope usleep(1500000); // wait 1.5 sec tr2.trigger(); // trigger the 2nd envelope usleep(1500000); // wait 1.5 sec tr3.trigger(); // trigger the 3rd envelope usleep(1500000); // wait 1.5 sec tr4.trigger(); // trigger the 4th envelope usleep(1500000); // wait 1.5 sec tr5.trigger(); // trigger the 5th envelope usleep(3000000); // wait 3 seconds gIO->clear_root(); // turn it off logMsg("SumOfSines done."); }
void ObjectTransactiontestUnit::test_nested_rollback() { matador::object_store store; store.attach<person>("person"); matador::transaction tr1(store); try { tr1.begin(); auto hans = store.insert(new person("Hans", matador::date(12, 3, 1980), 180)); UNIT_ASSERT_GREATER(hans->id(), 0UL, "id must be valid"); tr1.commit(); tr1.begin(); UNIT_ASSERT_EQUAL(hans->height(), 180U, "height must be valid"); hans->height(183); UNIT_ASSERT_EQUAL(hans->height(), 183U, "height must be valid"); matador::transaction tr2(store); try { tr2.begin(); UNIT_ASSERT_EQUAL(hans->height(), 183U, "height must be valid"); hans->height(159); UNIT_ASSERT_EQUAL(hans->height(), 159U, "height must be valid"); tr2.rollback(); UNIT_ASSERT_EQUAL(hans->height(), 183U, "height must be valid"); } catch (std::exception &) { tr2.rollback(); } tr1.commit(); } catch (std::exception &) { tr1.rollback(); } matador::object_view<person> pview(store); auto p = pview.front(); UNIT_ASSERT_GREATER(p->id(), 0UL, "id must be valid"); UNIT_ASSERT_EQUAL(p->name(), "Hans", "name must be 'Hans'"); }
void loop() { stateChanged=false; int pn1=random(0,11); switch (pn1) { case 0: //None tr2(); break; case 1: //None tr3(); break; case 2: //None tr4(); break; case 3: //None tr5(); break; case 4: //None tr7(); break; case 5: //wait 1 milli tr8(); break; case 6: //None tr9(); break; case 7: //None tr10(); break; case 8: //None tr11(); break; case 9: //None tr6(); break; case 10: //None tr12(); break; } if (stateChanged){ outputStatusLine();} }
/** * Given a Geom::Rect that may, for example, correspond to the bbox of an object, * this function fits the canvas to that rect by resizing the canvas * and translating the document root into position. */ void SPDocument::fitToRect(Geom::Rect const &rect) { double const w = rect.width(); double const h = rect.height(); double const old_height = sp_document_height(this); SPUnit const &px(sp_unit_get_by_id(SP_UNIT_PX)); sp_document_set_width(this, w, &px); sp_document_set_height(this, h, &px); Geom::Translate const tr(Geom::Point(0, (old_height - h)) - to_2geom(rect.min())); SP_GROUP(root)->translateChildItems(tr); SPNamedView *nv = sp_document_namedview(this, 0); if(nv) { Geom::Translate tr2(-rect.min()); nv->translateGuides(tr2); // update the viewport so the drawing appears to stay where it was nv->scrollAllDesktops(-tr2[0], tr2[1], false); } }
void scestart(int unit) { sce_softc_t ssc = scegetssc(unit); scsit_return_t sr; struct ifnet *ifp; io_req_t ior; TR_DECL("scestart"); tr2("enter: unit = 0x%x", unit); assert(ssc != NULL_SSC); ifp = &ssc->sce_if; IF_DEQUEUE(&ifp->if_snd, ior); dequeued: while(ior) { struct ether_header *ehp = (struct ether_header *)ior->io_data; scsit_handle_t handle; bcopy((const char *)sce_fake_addr,(char *)&ehp->ether_shost,6); sr = scsit_handle_alloc(&handle); assert(sr == SCSIT_SUCCESS); tr1("sending"); sr = scsit_send(handle, ssc->node, sce_lun, (void *)ior, (char *)ehp, ior->io_count, FALSE); assert(sr == SCSIT_SUCCESS); IF_DEQUEUE(&ifp->if_snd, ior); } tr1("exit"); }
void scerecv(sce_softc_t ssc, ipc_kmsg_t new_kmsg, vm_size_t size) { register struct ether_header *ehp, *ehp2; register struct packet_header *psce, *psce2; TR_DECL("scerecv"); tr2("size = 0x%x", size); ehp = (struct ether_header *)(&net_kmsg(new_kmsg)->header[0]); psce = (struct packet_header *)(&net_kmsg(new_kmsg)->packet[0]); ehp2 = ((struct ether_header *)(&net_kmsg(new_kmsg)->packet[0])) - 1; psce2 = ((struct packet_header *)ehp2) + 1; bcopy((const char *)psce2, (char *)ehp, sizeof(struct ether_header)); psce->type = ehp->ether_type; psce->length = size - sizeof(struct ether_header) + sizeof(struct packet_header); net_packet(&ssc->sce_if, new_kmsg, psce->length, ethernet_priority(new_kmsg), (io_req_t)0); }
int testTriangle() { int numErr = 0; logMessage(_T("TESTING - class GM_3dTriangle ...\n\n")); // Default constructor, triangle must be invalid GM_3dTriangle tr; if (tr.isValid()) { logMessage(_T("\tERROR - Default constructor creates valid triangle\n")); numErr++; } else { logMessage(_T("\tOK - Default constructor creates invalid triangle\n")); } // Get/Set GM_3dPoint v1(getRandomDouble(), getRandomDouble(), getRandomDouble()); GM_3dPoint v2(getRandomDouble(), getRandomDouble(), getRandomDouble()); GM_3dPoint v3(getRandomDouble(), getRandomDouble(), getRandomDouble()); tr[0] = GM_3dLine(v1, v2); tr[1] = GM_3dLine(v2, v3); tr[2] = GM_3dLine(v3, v1); if (!tr.isValid() || tr[0].begin() != v1 || tr[0].end() != v2 || tr[1].begin() != v2 || tr[1].end() != v3 || tr[2].begin() != v3 || tr[2].end() != v1) { logMessage(_T("\tERROR - Get/Set not working\n")); numErr++; } else { logMessage(_T("\tOK - Get/Set working\n")); } // Copy constructor GM_3dTriangle tr1(tr); if (!tr1.isValid() || tr[0] != tr1[0] || tr[1] != tr1[1] || tr[2] != tr1[2]) { logMessage(_T("\tERROR - Copy constructor not working\n")); numErr++; } else { logMessage(_T("\tOK - Copy constructor working\n")); } // Constructor (points) GM_3dTriangle tr2(v1, v2, v3); if (!tr1.isValid() || tr[0] != tr2[0] || tr[1] != tr2[1] || tr[2] != tr2[2]) { logMessage(_T("\tERROR - Constructor (points) not working\n")); numErr++; } else { logMessage(_T("\tOK - Constructor (points) working\n")); } // Constructor (lines) GM_3dTriangle tr3(tr[0], tr[1], tr[2]); if (!tr1.isValid() || tr[0] != tr3[0] || tr[1] != tr3[1] || tr[2] != tr3[2]) { logMessage(_T("\tERROR - Constructor (lines) not working\n")); numErr++; } else { logMessage(_T("\tOK - Constructor (lines) working\n")); } // Inversion tr1.invert(); if (!tr1.isValid() || tr1[0].begin() != tr[0].end() || tr1[0].end() != tr[0].begin() || tr1[1].begin() != tr[1].end() || tr1[1].end() != tr[1].begin() || tr1[2].begin() != tr[2].end() || tr1[2].end() != tr[2].begin()) { logMessage(_T("\tERROR - Triangle inversion not working\n")); numErr++; } else { logMessage(_T("\tOK - Triangle inversion working\n")); } // Vertical check GM_3dPoint vPoint = GM_3dLine(v1, v2).center(); vPoint.z(vPoint.z() + getRandomDouble()); GM_3dTriangle VTr(v1, v2, vPoint); if (!VTr.isValid() || !VTr.isVertical()) { logMessage(_T("\tERROR - Vertical check not working\n")); numErr++; } else { logMessage(_T("\tOK - Vertical check working\n")); } // Horizontal check GM_3dTriangle HTr(tr); double z = getRandomDouble(); for (unsigned int i = 0 ; i < 3 ; i++) { HTr[i].begin().z(z); HTr[i].end().z(z); } if (!HTr.isValid() || !HTr.isHorizontal()) { logMessage(_T("\tERROR - Horizontal check not working\n")); numErr++; } else { logMessage(_T("\tOK - Horizontal check working\n")); } // Connection check GM_3dTriangle discTr(tr); discTr[0].begin().x(discTr[0].begin().x() + 2.0 * GM_DIFF_TOLERANCE); if (!discTr.isValid() || discTr.isConnected() || !tr.isConnected()) { logMessage(_T("\tERROR - Connection check not working\n")); numErr++; } else { logMessage(_T("\tOK - Connection check working\n")); } // Max/Min z double maxZ = tr.maxZ(); double minZ = tr.minZ(); double checkMaxZ = -DBL_MAX; double checkMinZ = DBL_MAX; for (unsigned int i = 0 ; i < 3 ; i++) { if (tr[i].begin().z() > checkMaxZ) checkMaxZ = tr[i].begin().z(); if (tr[i].begin().z() < checkMinZ) checkMinZ = tr[i].begin().z(); if (tr[i].end().z() > checkMaxZ) checkMaxZ = tr[i].end().z(); if (tr[i].end().z() < checkMinZ) checkMinZ = tr[i].end().z(); } if (checkMinZ != minZ || checkMaxZ != maxZ) { logMessage(_T("\tERROR - Min/Max z not working\n")); numErr++; } else { logMessage(_T("\tOK - Min/Max z working\n")); } return numErr; }
void ZShape2dMC(){ double signal_weight = 3531.89/30459500.;//3504 if (!doMG) signal_weight = 1966.7 / 42705454.; // TH1D* mc_truegen; vector<TH1D*> mc_truegen_cteq, mc_truegen_fsr_pileup; GetGen(signal_weight, mc_truegen, mc_truegen_cteq, mc_truegen_fsr_pileup); cout<<"Get MC distribution"<<endl; vector<TGraphAsymmErrors*> g_MC_phistar; TGraphAsymmErrors* g_MC_phistar_temp1=ConvertToTGraph(mc_truegen); g_MC_phistar.push_back(g_MC_phistar_temp1); vector<TGraphAsymmErrors*> g_MC_phistar_cteq; for (size_t u=0; u<mc_truegen_cteq.size(); u++){ TGraphAsymmErrors* g_MC_phistar_temp=ConvertToTGraph(mc_truegen_cteq[u]); g_MC_phistar_cteq.push_back(g_MC_phistar_temp); } vector<TGraphAsymmErrors*> g_MC_phistar_fsr_pileup; for (size_t u=0; u<mc_truegen_fsr_pileup.size(); u++){ TGraphAsymmErrors* g_MC_phistar_temp=ConvertToTGraph(mc_truegen_fsr_pileup[u]); g_MC_phistar_fsr_pileup.push_back(g_MC_phistar_temp); } vector<TGraphAsymmErrors *> g_MC_norm = CreateCopy(g_MC_phistar); vector<TGraphAsymmErrors *> g_MC_norm_cteq = CreateCopy(g_MC_phistar_cteq); vector<TGraphAsymmErrors *> g_MC_norm_fsr_pileup = CreateCopy(g_MC_phistar_fsr_pileup); NormalizeGraph(g_MC_phistar, 0); NormalizeGraph(g_MC_phistar_cteq, 0); NormalizeGraph(g_MC_phistar_fsr_pileup, 0); NormalizeGraph(g_MC_norm, 1); NormalizeGraph(g_MC_norm_cteq, 1); NormalizeGraph(g_MC_norm_fsr_pileup, 1); TGraphAsymmErrors* g_syst_mc_cteq = CalcTotalSysU_updown(g_MC_phistar_cteq,g_MC_phistar_cteq[0],1,1); TGraphAsymmErrors* g_syst_mc_fsr = CalcTotalSysU_fsr(g_MC_phistar_fsr_pileup[0],g_MC_phistar[0]); TGraphAsymmErrors* g_syst_norm_mc_cteq = CalcTotalSysU_updown(g_MC_norm_cteq,g_MC_norm_cteq[0],1,1); TGraphAsymmErrors* g_syst_norm_mc_fsr = CalcTotalSysU_fsr(g_MC_norm_fsr_pileup[0],g_MC_norm[0]); vector<TGraphAsymmErrors *> g_mc_syst; g_mc_syst.push_back(g_MC_phistar[0]); g_mc_syst.push_back(g_syst_mc_fsr); if (!doMG) g_mc_syst.push_back(g_syst_mc_cteq); vector<std::string> syst_mc_list; syst_mc_list.push_back("unfolding"); syst_mc_list.push_back("fsr"); if (!doMG) syst_mc_list.push_back("cteq"); TGraphAsymmErrors* g_mc_final=GetMCFinal(g_mc_syst, syst_mc_list, 0); vector<TGraphAsymmErrors *> g_mc_syst_norm; g_mc_syst_norm.push_back(g_MC_norm[0]); g_mc_syst_norm.push_back(g_syst_norm_mc_fsr); if (!doMG) g_mc_syst_norm.push_back(g_syst_norm_mc_cteq); vector<std::string> syst_mc_list_norm; syst_mc_list_norm.push_back("unfolding"); syst_mc_list_norm.push_back("fsr"); if (!doMG) syst_mc_list_norm.push_back("cteq"); TGraphAsymmErrors* g_mc_final_norm=GetMCFinal(g_mc_syst_norm, syst_mc_list_norm, 1); string textn="Output/TESTMC_Graph_Abs_"; if (doMG) textn+="MG_"; else textn+="PH_"; if (elec==0)textn+="Dressed.root"; if (elec==1)textn+="Born.root"; if (elec==2)textn+="Naked.root"; TFile tr2(textn.c_str(),"RECREATE"); g_mc_final->Write(); textn="Output/TESTMC_Graph_Norm_"; if (doMG) textn+="MG_"; else textn+="PH_"; if (elec==0)textn+="Dressed.root"; if (elec==1)textn+="Born.root"; if (elec==2)textn+="Naked.root"; TFile tr3(textn.c_str(),"RECREATE"); g_mc_final_norm->Write(); }
void TestMatrix() { TGeoHMatrix identity; /** translations **/ TGeoTranslation tr1(1., 2., 3.); // Copy ctor TGeoTranslation tr2(tr1); myassert(tr2 == tr1, "translation copy ctor wrong"); // Assignment tr2 = tr1; myassert(tr2 == tr1, "translation assignment wrong"); myassert(tr2.IsTranslation(), "translation flag not set"); // Composition TGeoTranslation trref1(2., 4., 6.); TGeoTranslation tr3 = tr1 * tr2; myassert(tr3 == trref1, "translation multiplication wrong"); tr2 *= tr1; myassert(tr2 == trref1, "translation inplace multiplication wrong"); tr2 *= tr2.Inverse(); myassert(tr2 == identity, "translation inverse wrong"); /** rotations **/ TGeoRotation r1; r1.RotateZ(90.); // Copy ctor TGeoRotation r2(r1); myassert(r2 == r1, "rotation copy ctor wrong"); // Assignment r2 = r1; myassert(r2 == r1, "rotation assignment wrong"); myassert(r2.IsRotation(), "rotation flag not set"); // Composition TGeoRotation r3 = r1 * r1 * r1 * r1; myassert(r3 == identity, "rotation multiplication wrong"); r2 *= r2.Inverse(); myassert(r2 == identity, "rotation inplace multiplication wrong"); /** scale **/ TGeoScale scl1(1., 2., 3.); // Copy ctor TGeoScale scl2(scl1); myassert(scl2 == scl1, "scale copy ctor wrong"); // Assignment scl2 = scl1; myassert(scl2 == scl1, "scale assignment wrong"); myassert(scl2.IsScale(), "scale flag not set"); // Composition TGeoScale sclref1(1., 4., 9.); TGeoScale scl3 = scl1 * scl2; myassert(scl3 == sclref1, "scale multiplication wrong"); scl2 *= scl1; myassert(scl2 == sclref1, "scale inplace multiplication wrong"); scl2 *= scl2.Inverse(); myassert(scl2 == identity, "scale inverse wrong"); /** HMatrix **/ // Copy constructor TGeoHMatrix h1(tr1); myassert(h1 == tr1 && h1.IsTranslation(), "hmatrix constructor from translation wrong"); // Assignment TGeoHMatrix h2 = r1; TGeoHMatrix h3 = scl1; myassert(h2 == r1 && h3 == scl1 && h2.IsRotation() && h3.IsScale(), "hmatrix assignment wrong"); TGeoHMatrix h4 = h1 * h2; myassert(tr1 == h4 && r1 == h4 && h4.IsTranslation() && h4.IsRotation(), "hmatrix multiplication wrong"); h4 *= h4.Inverse(); myassert(h4 == identity, "hmatrix inverse wrong"); /** Combi trans **/ // Copy constructor TGeoCombiTrans c1(tr1); myassert(c1 == tr1 && c1.IsTranslation(), "combi trans constructor from translation wrong"); // Assignment TGeoCombiTrans c2 = r1; myassert(c2 == r1 && c2.IsRotation(), "combi trans assignment wrong"); TGeoCombiTrans c3 = c1 * c2; myassert(tr1 == c3 && r1 == c3 && c3.IsTranslation() && c3.IsRotation(), "combi trans multiplication wrong"); c3 *= c3.Inverse(); myassert(c3 == identity, "combi trans inverse wrong"); TGeoCombiTrans c4(1., 2., 3., &r1); c4.Print(); TGeoCombiTrans c5(c4); c5.Print(); myassert(c4.GetRotation() == &r1 && c5.GetRotation() != &r1, "combi trans copy constructor wrong"); // Test for Wolfgang Korsch's case TGeoHMatrix href = tr1; href *= TGeoRotation("", 0, 120, 0); TGeoRotation r4; r4.SetAngles(0, 90, 0); TGeoRotation r5 = r4; r4.SetAngles(0, 30, 0); r5 = r5 * r4; TGeoHMatrix combiH1TB = tr1 * r5; myassert(combiH1TB == href, "translation multiplication demoted"); // Test for David Rohr's case TGeoHMatrix h5 = href, h6 = href; h5 *= h6.Inverse(); h6.Multiply(h6.Inverse()); myassert(h5 == h6 && h5 == identity, "inverse not matching"); }
// this is the real one void AtmosphericDrag::doCompute(UTCTime utc, EarthBody& rb, Spacecraft& sc) { // To consist with STK double omega_e = 7.292115E-05; // IERS 1996 conventions //double omega_e = rb.getSpinRate(utc); Vector<double> r = sc.R(); // satellite position in m Vector<double> v = sc.V(); // satellite velocity in m/s const double cd = sc.getDragCoeff(); const double area = sc.getDragArea(); const double mass = sc.getDryMass(); double rmag = norm(r); double beta = cd * area / mass; // [m^2/kg] // compute the atmospheric density double rho = computeDensity(utc, rb, r, v); // [kg/m^3] // debuging... //rho = 6.3097802844338E-12; // compute the relative velocity vector and magnitude Vector<double> we(3,0.0); we(2)= omega_e; Vector<double> wxr = cross(we,r); Vector<double> vr = v - wxr; double vrmag = norm(vr); // form -1/2 (Cd*A/m) rho double coeff = -0.5 * beta * rho; double coeff2 = coeff * vrmag; // compute the acceleration in ECI frame (km/s^2) a = vr * coeff2; ///////// a // Partial reference: Montenbruck,P248 // form partial of drag wrt v // da_dv = -0.5*Cd*(A/M)*p*(vr*transpose(vr)/vr+vr1) Matrix<double> tr(3,1,0.0); tr(0,0)=vr(0); tr(1,0)=vr(1); tr(2,0)=vr(2); Matrix<double> vrvrt = tr*transpose(tr); vrvrt = vrvrt / vrmag; double eye3[3*3] = {1,0,0,0,1,0,0,0,1}; Matrix<double> vrm(3,3,0.0); vrm = eye3; vrm = vrm * vrmag; da_dv = (vrvrt + vrm) * coeff; //////// da_dv // da_dr // da_dr = -0.5*Cd*(A/M)*vr*dp_dr-da_dv*X(w) da_dr.resize(3,3,0.0); Matrix<double> X(3,3,0.0); X(0,1) = -we(2); // -wz X(0,2) = +we(1); // wy X(1,0) = +we(2); // +wz X(1,2) = -we(0); // -wx X(2,0) = -we(1); // -wy X(2,1) = +we(0); // +wx Matrix<double> part1(3,3,0.0); Matrix<double> part2(3,3,0.0); // Get the J2000 to TOD transformation Matrix<double> N = ReferenceFrames::J2kToTODMatrix(utc); // Transform r from J2000 to TOD Vector<double> r_tod = N * r; Position geoidPos(r_tod(0),r_tod(1),r_tod(3)); // Satellite height double height = geoidPos.getAltitude()/1000.0; // convert to [km] const int n = CIRA_SIZE; ; int bracket = 0; if (height >= h0[n-1]) { bracket = n - 1; } else { for (int i = 0; i < (n-1); i++) { if ((height >= h0[i]) && (height < h0[i+1])) { bracket = i; } } } // End 'if (height >= h0[n-1]) ' double Hh = H[bracket]; double coeff4 = -1.0 / (Hh * rmag); Vector<double> drhodr = r*coeff4; Matrix<double> tr2(3,1,0.0); tr2(0,0) = drhodr(0); tr2(1,0) = drhodr(1); tr2(2,0) = drhodr(2); part1 = tr*transpose(tr2); // //Matrix part1 = vr.outerProduct(drhodr); part1 = part1*coeff2; //part1 = dp_dr*a/rho; part2 =-da_dv*X; da_dr = part1-part2; // form partial of drag wrt cd double coeff3 = coeff2 / cd; this->dadcd = vr*coeff3; //////// da_dcd this->da_dcd(0,0) = dadcd(0); this->da_dcd(1,0) = dadcd(1); this->da_dcd(2,0) = dadcd(2); } // End of method 'AtmosphericDrag::doCompute()'
int main(int argc, char **argv) { uint64 genomeSize = 0; char *atacFileName = 0L; char *prefix = 0L; char *trFile1 = 0L; char *trFile2 = 0L; char prefixFull[1024]; bool error = false; int arg=1; while (arg < argc) { if (strcmp(argv[arg], "-g") == 0) { ++arg; if (argv[arg][0] == 'A') { genomeSize = 0; } else if (argv[arg][0] == 'B') { genomeSize = 1; } else { genomeSize = strtouint64(argv[arg], 0L); } } else if (strcmp(argv[arg], "-a") == 0) { atacFileName = argv[++arg]; } else if (strcmp(argv[arg], "-p") == 0) { prefix = argv[++arg]; } else if (strcmp(argv[arg], "-ta") == 0) { trFile1 = argv[++arg]; } else if (strcmp(argv[arg], "-tb") == 0) { trFile2 = argv[++arg]; } else { error = true; } arg++; } if (!atacFileName || !prefix || error) { fprintf(stderr, "usage: %s -a <file.atac> -p <outprefix> [-ta trfile] [-tb trfile] [-g {A | B | g}]\n", argv[0]); fprintf(stderr, " -a read input from 'file.atac'\n"); fprintf(stderr, " -p write stats to files prefixed with 'outprefix'\n"); fprintf(stderr, " -g use a genome size of g for the Nx computation, defaults to\n"); fprintf(stderr, " the length of the A sequence. Or use the actual length\n"); fprintf(stderr, " of sequence A or B.\n"); fprintf(stderr, " -ta read tandem repeats for A from trfile\n"); fprintf(stderr, " -tb read tandem repeats for B from trfile\n"); exit(1); } atacFile AF(atacFileName); atacMatchList &matches = *AF.matches(); atacMatchList &runs = *AF.runs(); atacMatchList &clumps = *AF.clumps(); // We end up using sequences a lot here, so just bite it and load them in a cache. // seqCache *A = new seqCache(AF.assemblyFileA(), 0, true); seqCache *B = new seqCache(AF.assemblyFileB(), 0, true); A->loadAllSequences(); B->loadAllSequences(); fprintf(stdout, "\nSEQUENCE\n"); totalLength(AF, A, B); if (trFile1 && trFile2) { atacFileStream tr1(trFile1); atacFileStream tr2(trFile2); tandemRepeatStats(tr1, tr2, AF, A, B); } // XXX unmappedInRuns only works on runs, and if we have clumps in // the input it fails. // if ((runs.numberOfMatches() > 0) && (clumps.numberOfMatches() == 0)) { fprintf(stdout, "\nMATCHES IN RUNS\n"); unmappedInRuns(AF, A, B, prefix); } if (matches.numberOfMatches() > 0) { fprintf(stdout, "\nMATCHES\n"); sprintf(prefixFull, "%s-matches", prefix); mappedLengths(AF, matches, A, B, prefixFull); NxOfMapped(AF, matches, genomeSize, prefixFull); MappedByChromosome(AF, matches, A, B, prefixFull); } if (runs.numberOfMatches() > 0) { fprintf(stdout, "\nRUNS\n"); sprintf(prefixFull, "%s-runs", prefix); mappedLengths(AF, runs, A, B, prefixFull); NxOfMapped(AF, runs, genomeSize, prefixFull); MappedByChromosome(AF, runs, A, B, prefixFull); } if (clumps.numberOfMatches() > 0) { fprintf(stdout, "\nCLUMPS\n"); sprintf(prefixFull, "%s-clumps", prefix); mappedLengths(AF, clumps, A, B, prefixFull); NxOfMapped(AF, clumps, genomeSize, prefixFull); MappedByChromosome(AF, clumps, A, B, prefixFull); } delete A; delete B; return(0); }
// This one is odd. // [[Rcpp::export]] forest::forest_tree forest_tree__copy(const forest::forest_tree& tr) { forest::forest_tree tr2(tr); // may not actually be needed. return tr2; }
void CTTypes::RunTestCaseL(TInt aCurTestCase) { switch(aCurTestCase) { case 1: { __UHEAP_MARK; TestRgb tr1(0,0,0, this); TestRgb tr2(100,100,100, this); TestRgb tr3(10,20,30, this); TestRgb tr4(110,160,210, this); TestRgb tr5(255,255,255, this); INFO_PRINTF1(_L("TRgb")); tr1.Test(); tr2.Test(); tr3.Test(); tr4.Test(); tr5.Test(); ((CTTypesStep*)iStep)->CloseTMSGraphicsStep(); __UHEAP_MARKEND; } break; case 2: { INFO_PRINTF1(_L("TTypeface")); TestTypeface ttf1(_L(""), 0, this); TestTypeface ttf2(_L("Font name"), 1, this); TestTypeface ttf3(_L("Font name"), 2, this); TestTypeface ttf4(_L("Font name"), 3, this); TestTypeface ttf5(_L("Font name"), 4, this); TestTypeface ttf6(_L("Font name"), 5, this); TestTypeface ttf7(_L("Font name"), 6, this); TestTypeface ttf8(_L("Another font name"), 7, this); ttf1.Test(); ttf2.Test(); ttf3.Test(); ttf4.Test(); ttf5.Test(); ttf6.Test(); ttf7.Test(); ttf8.Test(); } break; case 3: { TestMargins tm1(0,0,0,0, this); TestMargins tm2(10,20,30,40, this); TestMargins tm3(-10,-20,-30,-40, this); INFO_PRINTF1(_L("TMargins")); tm1.Test(); tm2.Test(); tm3.Test(); } break; case 4: { TestPageSpec tps1(TPageSpec::EPortrait,TSize(0,0), this); TestPageSpec tps2(TPageSpec::ELandscape,TSize(0,0), this); TestPageSpec tps3(TPageSpec::EPortrait,TSize(10,-5), this); TestPageSpec tps4(TPageSpec::ELandscape,TSize(15,-20), this); TestPageSpec tps5(TPageSpec::EPortrait,TSize(1000,1500), this); TestPageSpec tps6(TPageSpec::ELandscape,TSize(2000,500), this); INFO_PRINTF1(_L("TPageSpec")); tps1.Test(); tps2.Test(); tps3.Test(); tps4.Test(); tps5.Test(); tps6.Test(); } break; case 5: { INFO_PRINTF1(_L("FontEffect")); ((CTTypesStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-0002")); TestFontEffect te(this); ((CTTypesStep*)iStep)->RecordTestResultL(); te.Test(); } break; case 6: { INFO_PRINTF1(_L("TFontSyle")); TestTFontStyle ts(this); ts.Test(); } break; case 7: { TTypeface typeface; typeface.iName=_L("Font name"); TFontStyle fontstyle; TestFontSpec tfspec(typeface,200,fontstyle, this); INFO_PRINTF1(_L("TFontSpec")); tfspec.Test(); } break; case 8: { /* TestLine tl1(TPoint(10,10),TPoint(90,90), this); TestLine tl2(TPoint(100,150),TPoint(50,-50), this); TestLine tl3(TPoint(-50,50),TPoint(60,-40), this); TestLine tl4(TPoint(-100,0),TPoint(0,200), this); TestLine tl5(TPoint(150,-50),TPoint(50,75), this); TestLine tl6(TPoint(0,-100),TPoint(-50,-150), this); TestLine tl7(TPoint(-1000,-1000),TPoint(1000,1000), this); TestLine tl8(TPoint(1000,-1000),TPoint(-1000,1000), this); TestLine tl9(TPoint(500,-1000),TPoint(-500,1000), this); TestLine tl10(TPoint(-500,-1000),TPoint(500,1000), this); TestLine tl11(TPoint(1000,-500),TPoint(-1000,500), this); TestLine tl12(TPoint(1000,500),TPoint(-1000,-500), this); INFO_PRINTF1(_L("TLinearDDA")); tl1.Test(); tl2.Test(); tl3.Test(); tl4.Test(); tl5.Test(); tl6.Test(); tl7.Test(); tl8.Test(); tl9.Test(); tl10.Test(); tl11.Test(); tl12.Test(); */ INFO_PRINTF1(_L("TLinearDDA is only for Graphics team. Removed.")); } break; case 9: { INFO_PRINTF1(_L("CTypefaceStore")); TestTFStore ttfs(this); ttfs.Test(); } break; case 10: { INFO_PRINTF1(_L("CFontCache")); TestFontCache tfc(this); tfc.Test(); } break; case 11: { /* INFO_PRINTF1(_L("CScaleCropPicture")); TestPicture tp(this); tp.Test(); */ INFO_PRINTF1(_L("CScaleCropPicture is only for Graphics team. Removed.")); } break; case 12: { /* INFO_PRINTF1(_L("CPalette")); TestPalette tpal(this); tpal.Test(); */ INFO_PRINTF1(_L("CPalette is only for Graphics team. Removed.")); } break; case 13: { INFO_PRINTF1(_L("TDisplayModeUtils")); TestDisplayModeUtils tdmu(this); tdmu.Test(); } break; case 14: ((CTTypesStep*)iStep)->SetOverallTestStepID(_L("GRAPHICS-GDI-0001")); ((CTTypesStep*)iStep)->RecordTestResultL(); ((CTTypesStep*)iStep)->CloseTMSGraphicsStep(); TestComplete(); break; } }
virtual void on_draw() { double img_width = rbuf_img(0).width(); double img_height = rbuf_img(0).height(); typedef agg::pixfmt_bgr24 pixfmt; typedef agg::renderer_base<pixfmt> renderer_base; pixfmt pixf(rbuf_window()); pixfmt img_pixf(rbuf_img(0)); renderer_base rb(pixf); rb.clear(agg::rgba(1.0, 1.0, 1.0)); agg::trans_affine src_mtx; src_mtx *= agg::trans_affine_translation(-img_width/2, -img_height/2); src_mtx *= agg::trans_affine_rotation(m_angle.value() * agg::pi / 180.0); src_mtx *= agg::trans_affine_translation(img_width/2 + 10, img_height/2 + 10 + 40); src_mtx *= trans_affine_resizing(); agg::trans_affine img_mtx; img_mtx *= agg::trans_affine_translation(-img_width/2, -img_height/2); img_mtx *= agg::trans_affine_rotation(m_angle.value() * agg::pi / 180.0); img_mtx *= agg::trans_affine_scaling(m_scale.value()); img_mtx *= agg::trans_affine_translation(img_width/2 + 10, img_height/2 + 10 + 40); img_mtx *= trans_affine_resizing(); img_mtx.invert(); typedef agg::span_allocator<agg::rgba8> span_alloc_type; span_alloc_type sa; typedef agg::span_interpolator_adaptor<agg::span_interpolator_linear<>, periodic_distortion> interpolator_type; periodic_distortion* dist = 0; distortion_wave dist_wave; distortion_swirl dist_swirl; distortion_wave_swirl dist_wave_swirl; distortion_swirl_wave dist_swirl_wave; switch(m_distortion.cur_item()) { case 0: dist = &dist_wave; break; case 1: dist = &dist_swirl; break; case 2: dist = &dist_wave_swirl; break; case 3: dist = &dist_swirl_wave; break; } dist->period(m_period.value()); dist->amplitude(m_amplitude.value()); dist->phase(m_phase); double cx = m_center_x; double cy = m_center_y; img_mtx.transform(&cx, &cy); dist->center(cx, cy); interpolator_type interpolator(img_mtx, *dist); typedef agg::image_accessor_clip<pixfmt> img_source_type; img_source_type img_src(img_pixf, agg::rgba(1,1,1)); /* // Version without filtering (nearest neighbor) //------------------------------------------ typedef agg::span_image_filter_rgb_nn<img_source_type, interpolator_type> span_gen_type; span_gen_type sg(img_src, interpolator); //------------------------------------------ */ // Version with "hardcoded" bilinear filter and without // image_accessor (direct filter, the old variant) //------------------------------------------ typedef agg::span_image_filter_rgb_bilinear_clip<pixfmt, interpolator_type> span_gen_type; span_gen_type sg(img_pixf, agg::rgba(1,1,1), interpolator); //------------------------------------------ /* // Version with arbitrary 2x2 filter //------------------------------------------ typedef agg::span_image_filter_rgb_2x2<img_source_type, interpolator_type> span_gen_type; agg::image_filter<agg::image_filter_kaiser> filter; span_gen_type sg(img_src, interpolator, filter); //------------------------------------------ */ /* // Version with arbitrary filter //------------------------------------------ typedef agg::span_image_filter_rgb<img_source_type, interpolator_type> span_gen_type; agg::image_filter<agg::image_filter_spline36> filter; span_gen_type sg(img_src, interpolator, filter); //------------------------------------------ */ agg::rasterizer_scanline_aa<> ras; agg::scanline_u8 sl; double r = img_width; if(img_height < r) r = img_height; agg::ellipse ell(img_width / 2.0, img_height / 2.0, r / 2.0 - 20.0, r / 2.0 - 20.0, 200); agg::conv_transform<agg::ellipse> tr(ell, src_mtx); ras.add_path(tr); agg::render_scanlines_aa(ras, sl, rb, sa, sg); src_mtx *= ~trans_affine_resizing(); src_mtx *= agg::trans_affine_translation(img_width - img_width/10, 0.0); src_mtx *= trans_affine_resizing(); ras.add_path(tr); agg::render_scanlines_aa_solid(ras, sl, rb, agg::rgba8(0,0,0)); typedef agg::span_gradient<agg::rgba8, interpolator_type, agg::gradient_circle, color_array_type> gradient_span_gen; agg::gradient_circle gradient_function; color_array_type gradient_colors(m_gradient_colors); gradient_span_gen span_gradient(interpolator, gradient_function, gradient_colors, 0, 180); agg::trans_affine gr1_mtx; gr1_mtx *= agg::trans_affine_translation(-img_width/2, -img_height/2); gr1_mtx *= agg::trans_affine_scaling(0.8); gr1_mtx *= agg::trans_affine_rotation(m_angle.value() * agg::pi / 180.0); gr1_mtx *= agg::trans_affine_translation(img_width - img_width/10 + img_width/2 + 10, img_height/2 + 10 + 40); gr1_mtx *= trans_affine_resizing(); agg::trans_affine gr2_mtx; gr2_mtx *= agg::trans_affine_rotation(m_angle.value() * agg::pi / 180.0); gr2_mtx *= agg::trans_affine_scaling(m_scale.value()); gr2_mtx *= agg::trans_affine_translation(img_width - img_width/10 + img_width/2 + 10 + 50, img_height/2 + 10 + 40 + 50); gr2_mtx *= trans_affine_resizing(); gr2_mtx.invert(); cx = m_center_x + img_width - img_width/10; cy = m_center_y; gr2_mtx.transform(&cx, &cy); dist->center(cx, cy); interpolator.transformer(gr2_mtx); agg::conv_transform<agg::ellipse> tr2(ell, gr1_mtx); ras.add_path(tr2); agg::render_scanlines_aa(ras, sl, rb, sa, span_gradient); agg::render_ctrl(ras, sl, rb, m_angle); agg::render_ctrl(ras, sl, rb, m_scale); agg::render_ctrl(ras, sl, rb, m_amplitude); agg::render_ctrl(ras, sl, rb, m_period); agg::render_ctrl(ras, sl, rb, m_distortion); }