float Ship::Cw(){ switch(e.Faa){ case U: return 0.95 * Cp() + 0.17 * pow(1 - Cp(), 1./3.); case N: return (1. + 2. * Cb())/3.; case V: return pow(Cp(), 2./3.); default: return (1. + 2. * Cb())/3.; } return -1; }
float Ship::KGs(){ float t = 0.01 * (v.D + v.fB) * (46.6 + 0.135 * (0.81 - Cb()) * pow(v.Lpp / v.D, 2.)) + 0.008 * (v.D + v.fB) * (v.Lpp / v.B - 6.5); if (v.Lpp >= 120.) return t; else return t + 0.001 * (v.D + v.fB) * (1. - (v.Lpp - 60.)/60.); }
/********************************************************************** * FSA stuff **********************************************************************/ State * Pen::create_fsa( CEvent &d, CEvent &m, CEvent &u, callback_meth_t down_cb, callback_meth_t move_cb, callback_meth_t up_cb ) { State *beg_state = new State; State *mid_state = new State; // This is a subclass of Simple_int, so the callback paramater to // Cb must be a CallMeth_t<Simple_int,Event>::_method), so we do a // cast *beg_state += Arc(d, Cb((_callb::_method) down_cb, mid_state )); *mid_state += Arc(m, Cb((_callb::_method) move_cb )); *mid_state += Arc(u, Cb((_callb::_method) up_cb, (State*)-1)); return beg_state; }
float Ship::w(){ float M = v.Lpp / pow(Vol(), 1./3.); int Fa; switch(e.Faa){ case N: Fa = 0; break; case U: Fa = -2; break; case V: Fa = 2; break; default: Fa = 0; } float BL = v.B / v.Lpp; float a = 0.1 * BL + 0.149; float b = 0.05 * BL + 0.449; float c = 585. - 5027. * BL + 11700. * pow(BL, 2.); float w1 = a + b / (c * pow(0.98 - Cb(), 3.) + 1); float w2 = 0.025 * Fa / (100. * pow(Cb() - 0.7, 2.) + 1); float w3 = min(0.1, -0.18 + 0.00756 / (Dprop()/v.Lpp + 0.002)); float S1 = e.Shafts > 1 ? 1. : 0.7; return 0.7 * (w1 + w2 + w3) - 0.45 + 0.08 * M * S1; }
float Ship::t(){ float M = v.Lpp / pow(Vol(), 1./3.); int Fa; switch(e.Faa){ case N: Fa = 0; break; case U: Fa = -2; break; case V: Fa = 2; break; default: Fa = 0; } float BL = v.B / v.Lpp; float d = 0.625 * BL + 0.08; float e = 0.165 - 0.25 * BL; float f = 525. - 8060. * BL + 20300. * pow(BL, 2.); float t1 = d + e / (f * pow(0.98 - Cb(), 3.) + 1.); float t2 = -0.01 * Fa; float t3 = 2. * (Dprop()/v.Lpp - 0.04); return t1 + t2 + t3 - 0.26 + 0.04 * M; }
PlaYUVerPixel PlaYUVerPixel::ConvertPixel( ColorSpace eOutputSpace ) { Int outA, outB, outC; PlaYUVerPixel outPixel( COLOR_INVALID, 0, 0, 0 ); if( ColorSpace() == eOutputSpace || eOutputSpace == COLOR_ARGB || eOutputSpace == COLOR_GRAY ) return *this; if( eOutputSpace == COLOR_RGB ) { YuvToRgb( Y(), Cb(), Cr(), outA, outB, outC ); outPixel.R() = outA; outPixel.G() = outB; outPixel.B() = outC; } if( eOutputSpace == COLOR_YUV ) { rgbToYuv( R(), G(), B(), outA, outB, outC ); outPixel.Y() = outA; outPixel.Cb() = outB; outPixel.Cr() = outC; } return outPixel; }
float Ship::Wdeck(float T, float perc){ return STEELDENSITY * (T/1000.) * v.Lpp * v.B * Cb() * perc / 100.; }
float Ship::KM(){ float Cbw = Cb() / Cw(); return v.B * (13.61 - 45.4* Cbw + 52.17 * pow(Cbw, 2.) - 19.88 * pow(Cbw, 3.)); }
void Ship::output(){ ofstream file; file.open("Report.txt"); file << "[table]" << endl; cout << fixed << setprecision(2) << "Length: \t\t\t\t" << v.Lpp << " m" << endl; file << fixed << setprecision(2) << "[tr][td]Length: \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[/td][td]" << v.Lpp << " m[/td][/tr]" << endl; cout << "Beam: \t\t\t\t\t" << v.B << " m" << endl; file << "[tr][td]Beam: [/td][td]" << v.B << " m[/td][/tr]" << endl; cout << "Draft: \t\t\t\t\t" << v.D << " m" << endl; file << "[tr][td]Draft: [/td][td]" << v.D << " m[/td][/tr]" << endl; cout << "Freeboard: \t\t\t\t" << v.fB << " m" << endl; file << "[tr][td]Freeboard: [/td][td]" << v.fB << " m[/td][/tr]" << endl; cout << setprecision(3) << "Block Coefficient: \t\t\t" << Cb() << endl; file << setprecision(3) << "[tr][td]Block Coefficient: [/td][td]" << Cb() << "[/td][/tr]" << endl; cout << setprecision(0) << "Displacement: \t\t\t\t" << Vol() << " t" << endl; file << setprecision(0) << "[tr][td]Displacement: [/td][td]" << Vol() << " t[/td][/tr]" << endl; cout << "Lightship: \t\t\t\t" << Wh() + Wwo() + Wm() + We() + Wspus() + Bunker() << " t" << endl; file << "[tr][td]Lightship: [/td][td]" << Lightship() << " t[/td][/tr]" << endl; cout << setprecision(1) << "\nMax Speed: \t\t\t\t" << v.Vk << " kn" << endl; file << setprecision(1) << "\n[tr][td]Max Speed: [/td][td]" << v.Vk << " kn[/td][/tr]" << endl; cout << "Cruise Speed: \t\t\t\t" << v.Vc << " kn / " << v.Range << " nm" << endl; file << "[tr][td]Cruise Speed: [/td][td]" << v.Vc << " kn / " << v.Range << " nm[/td][/tr]" << endl; cout << "Engine: \t\t\t\t"; file << "[tr][td]Engine: [/td][td]"; switch(e.Gear){ case Direct: cout << "Direct "; file << "Direct "; break; case Geared: cout << "Geared "; file << "Geared "; break; case Turbo_Electric: cout << "Turbo-Electric "; file << "Turbo-Electric "; break; default: cout << "Unknown"; file << "Unknown"; } switch(e.Eng){ case Diesel2stk: cout << "Two Stroke Diesel" << endl; file << "Two Stroke Diesel"; break; case Diesel4stk: cout << "Four Stroke Diesel" << endl; file << "Four Stroke Diesel" << endl; break; case QuadExp: cout << "Quadruple Expansion Reciprocating Engine" << endl; file << "Quadruple Expansion Reciprocating Engine"; break; case TripExp: cout << "Triple Expansion Reciprocating Engine" << endl; file << "Triple Expansion Reciprocating Engine"; break; case SimExp: cout << "Simple Reciprocating Engine" << endl; file << "Simple Reciprocating Engine"; break; case SteamTur: cout << "Steam Turbine" << endl; file << "Steam Turbine"; break; default: cout << endl; } file << "[/td][/tr]" << endl; cout << setprecision(0) << "Power Delivered: \t\t\t" << Pd(v.Vk) << " hp" << endl; file << setprecision(0) << "[tr][td]Power Delivered: [/td][td]" << Pd(v.Vk) << " hp[/td][/tr]" << endl; cout << setprecision(2) << "Total Efficiency: \t\t\t" << NUt()*100 << "%" << endl; file << setprecision(2) << "[tr][td]Total Efficiency: [/td][td]" << NUt()*100 << "%[/td][/tr]" << endl; cout << setprecision(3) << "Froude Number: \t\t\t\t" << Fn() << endl; file << setprecision(3) << "[tr][td]Froude Number: [/td][td]" << Fn() << "[/td][/tr]" << endl; cout << setprecision(0) << "Bunker Size: \t\t\t\t" << Bunker() << " t" << endl; file << setprecision(0) << "[tr][td]Bunker Size: [/td][td]" << Bunker() << " t[/td][/tr]" << endl; cout << "Service Allowance: \t\t\t" << e.SA << "%" << endl; file << "[tr][td]Service Allowance: [/td][td]" << e.SA << "%[/td][/tr]" << endl; cout << setprecision(2); file << setprecision(2); cout << "Length of Superstructure: \t\t" << v.Lspus << " m" << endl; file << "[tr][td]Length of Superstructure: [/td][td]" << v.Lspus << " m[/td][/tr]" << endl; cout << "Aftbody Shape: \t\t\t\t"; file << "[tr][td]Aftbody Shape: [/td][td]"; switch(e.Faa){ case V: cout << "V" << endl; file << "V"; break; case U: cout << "U" << endl; file << "U"; break; case N: cout << "N" << endl; file << "N"; break; default: cout << "N" << endl; file << "N"; } file << "[/td][/tr]"; cout << "\nLongitudinal Center of Buoyancy: \t" << lcb() << "%" << endl; file << "\n[tr][td]Longitudinal Center of Buoyancy: [/td][td]" << lcb() << "% / " << lcb()*v.Lpp << " m from midpoint[/td][/tr]" << endl; cout << "Longitudinal Center of Gravity: \t" << lcg() << "%" << endl; file << "[tr][td]Longitudinal Center of Gravity: [/td][td]" << lcg() << "% / " << lcg()*v.Lpp << " m from midpoint[/td][/tr]" << endl; cout << "Vertical Center of Gravity: \t\t" << KGh() << " m" << endl; file << "[tr][td]Vertical Center of Gravity: [/td][td]" << KGh() << " m[/td][/tr]" << endl; cout << "Metacentric Height: \t\t\t" << GM() << " m" << endl; file << "[tr][td]Metacentric Height: [/td][td]" << GM() << " m[/td][/tr]" << endl; cout << "Roll Period: \t\t\t\t" << TR() << " s" << endl; file << "[tr][td]Roll Period: [/td][td]" << TR() << " s[/td][/tr]" << endl; cout << "\nBow Entrance Angle: \t\t\t" << iE() << " deg" << endl; file << "\n[tr][td]Bow Entrance Angle: [/td][td]" << iE() << " deg[/td][/tr]" << endl; cout << "Length of Engine Room: \t\t\t" << Lcm() << " m" << endl; file << "[tr][td]Length of Engine Room: [/td][td]" << Lcm() << " m[/td][/tr]" << endl; cout << setprecision(0) << "\nMain Belt: \t\t\t\t" << arm.mb_Ttop << " / " << arm.mb_Tbot << " mm at " << arm.b_deg << " degrees, " << arm.b_L << " m long with " << arm.b_H << " m above and " << arm.b_Db << " m below water" << endl; file << setprecision(0) << "\n[tr][td]Main Belt: [/td][td]" << arm.mb_Ttop << " / " << arm.mb_Tbot << " mm, " << arm.b_L << " m long with " << arm.b_H << " m above and " << arm.b_Db << " m below water[/td][/tr]" << endl; cout << "End Belt: \t\t\t\t" << arm.eb_Ttop << " / " << arm.eb_Tbot << " mm" << endl; file << "[tr][td]End Belt: [/td][td]" << arm.eb_Ttop << " / " << arm.eb_Tbot << " mm[/td][/tr]" << endl; cout << "Upper Belt: \t\t\t\t" << arm.ub_Ttop << " / " << arm.ub_Tbot << " mm, " << arm.b_uL << " m long" << endl; file << "[tr][td]Upper Belt: [/td][td]" << arm.ub_Ttop << " / " << arm.ub_Tbot << " mm, " << arm.b_uL << " m long[/td][/tr]" << endl; cout << "Main Deck: \t\t\t\t" << arm.md_T << " mm covering " << arm.md_P << "% / " << arm.md_P * v.Lpp << " m of deck" << endl; file << "[tr][td]Main Deck: [/td][td]" << arm.md_T << " m covering " << arm.md_P << "% / " << arm.md_P * v.Lpp << " m of deck[/td][/tr]" << endl; cout << "Weather Deck: \t\t\t\t" << arm.wd_T << " mm covering " << arm.wd_P << "% / " << arm.wd_P * v.Lpp << " m of deck" << endl; file << "[tr][td]Weather Deck: [/td][td]" << arm.wd_T << " m covering " << arm.wd_P << "% / " << arm.wd_P * v.Lpp << " m of deck[/td][/tr]" << endl; cout << "Splinter Deck: \t\t\t\t" << arm.sd_T << " mm covering " << arm.sd_P << "% / " << arm.sd_P * v.Lpp << " m of deck" << endl; file << "[tr][td]Splinter Deck: [/td][td]" << arm.sd_T << " m covering " << arm.sd_P << "% / " << arm.sd_P * v.Lpp << " m of deck[/td][/tr]" << endl; cout << "Ends Deck: \t\t\t\t" << arm.ed_T << " mm" << endl; file << "[tr][td]Ends Deck: [/td][td]" << arm.ed_T << " mm[/td][/tr]" << endl; cout << "Bulkhead: \t\t\t\t" << arm.blk_T << " mm in " << arm.blk_Lct << "x" << arm.blk_D << " m layers, " << arm.blk_L << " m long, " << arm.blk_H << " m tall" << endl; file << "[tr][td]Bulkhead: [/td][td]" << arm.blk_T << " mm in " << arm.blk_Lct << "x" << arm.blk_D << " m layers, " << arm.blk_L << " m long, " << arm.blk_H << " m tall[/td][/tr]" << endl; file << "[/table]" << endl; file.close(); }
PlaYUVerPixel PlaYUVerPixel::operator-( const PlaYUVerPixel& in ) { PlaYUVerPixel out( m_iColorSpace, Y() - in.Y(), Cb() - in.Cb(), Cr() - in.Cr() ); return out; }
float Ship::Lcm(){ float Bmod = v.B - (2 * arm.blk_T/1000. * arm.blk_Lct * arm.blk_D); return Ve() / (Bmod * (v.D + v.fB) * Cb() * 0.85); }
float Ship::Wspus(){ return Havg()/2.4 * 0.19 * (v.Lspus * v.B * 0.8 * (Cb() + Cm())/2.0); }
float Ship::Wh(){ return pow(Cb()/0.8, 1./3.) * pow(10., -5.) * ((5.11 * pow(v.Lpp, 3.3) * v.B/v.D) + (2.56 * pow(v.Lpp, 2.) * pow(v.B + v.D + v.fB, 2.))); }
static YCbCr getYCbCr(const Color& src) throw() { return YCbCr(Y(src), Cb(src), Cr(src)); }
float Ship::Vblk(){ return arm.blk_L * arm.blk_H * (2 * arm.blk_T/1000. * arm.blk_Lct) * (2*Cb() + Cm())/3; }
float Ship::Cp(){ return Cb()/Cm(); }
float Ship::Vol(){ return v.Lpp * v.B * v.D * Cb(); }
float Ship::Cm(){ // Kerlen 1970 return 1.006 - 0.0056 * pow(Cb(), -3.56); }
PlaYUVerPixel PlaYUVerPixel::operator*( const Double& op ) { PlaYUVerPixel out( m_iColorSpace, Y() * op, Cb() * op, Cr() * op ); return out; }
void BlockMatrixTest::testOperators1() { std::cout << "--> Test: operators1." <<std::endl; double tol = 1e-10; SP::SiconosMatrix Ab(new BlockMatrix(m, 2, 3)); SP::SiconosMatrix Cb(new BlockMatrix(*Ab)); SP::SiconosMatrix A(new SimpleMatrix(5, 7)); for (unsigned int i = 0; i < 5 ; ++i) for (unsigned int j = 0; j < 7; ++j) (*A)(i, j) = i + j; double a = 2.3; int a1 = 2; // Block *= scal or /= scal *Cb *= a; for (unsigned int i = 0; i < Cb->size(0); ++i) for (unsigned int j = 0 ; j < Cb->size(1); ++j) CPPUNIT_ASSERT_EQUAL_MESSAGE("testOperators1: ", fabs((*Cb)(i, j) - a * (*Ab)(i, j)) < tol , true); *Cb *= a1; for (unsigned int i = 0; i < Cb->size(0); ++i) for (unsigned int j = 0 ; j < Cb->size(1); ++j) CPPUNIT_ASSERT_EQUAL_MESSAGE("testOperators1: ", fabs((*Cb)(i, j) - a1 * a * (*Ab)(i, j)) < tol , true); *Cb /= a; for (unsigned int i = 0; i < Cb->size(0); ++i) for (unsigned int j = 0 ; j < Cb->size(1); ++j) CPPUNIT_ASSERT_EQUAL_MESSAGE("testOperators1: ", fabs((*Cb)(i, j) - a1 * (*Ab)(i, j)) < tol , true); *Cb /= a1; for (unsigned int i = 0; i < Cb->size(0); ++i) for (unsigned int j = 0 ; j < Cb->size(1); ++j) CPPUNIT_ASSERT_EQUAL_MESSAGE("testOperators1: ", fabs((*Cb)(i, j) - (*Ab)(i, j)) < tol , true); // Block += Simple *Cb += *A; for (unsigned int i = 0; i < Cb->size(0); ++i) for (unsigned int j = 0 ; j < Cb->size(1); ++j) CPPUNIT_ASSERT_EQUAL_MESSAGE("testOperators1: ", fabs((*Cb)(i, j) - (*Ab)(i, j) - (*A)(i, j)) < tol , true); // Block -= Block *Cb -= *Ab; for (unsigned int i = 0; i < Cb->size(0); ++i) for (unsigned int j = 0 ; j < Cb->size(1); ++j) CPPUNIT_ASSERT_EQUAL_MESSAGE("testOperators1: ", fabs((*Cb)(i, j) - (*A)(i, j)) < tol , true); // Block += Block *Cb += *Ab; for (unsigned int i = 0; i < Cb->size(0); ++i) for (unsigned int j = 0 ; j < Cb->size(1); ++j) CPPUNIT_ASSERT_EQUAL_MESSAGE("testOperators1: ", fabs((*Cb)(i, j) - (*Ab)(i, j) - (*A)(i, j)) < tol , true); // Block -= Simple *Cb -= *A; for (unsigned int i = 0; i < Cb->size(0); ++i) for (unsigned int j = 0 ; j < Cb->size(1); ++j) CPPUNIT_ASSERT_EQUAL_MESSAGE("testOperators1: ", fabs((*Cb)(i, j) - (*Ab)(i, j)) < tol , true); std::cout << "--> test operators1 ended with success." <<std::endl; }
void AmiNotification::clear() { mLockPtr.reset(); mMutexPtr.reset(); mCb = Cb(); }