// RGBVec: private methods void RGBVec::normalise() { // simply clip the colour if (r() > 1.0) setR(1.0); if (g() > 1.0) setG(1.0); if (b() > 1.0) setB(1.0); if (r() < 0.0) setR(0.0); if (g() < 0.0) setG(0.0); if (b() < 0.0) setB(0.0); }
/**afichage de la bombe*/ void Bomb::draw(int n, float rad, bool fill){ float x_ = 0.0; float y_ = 0.0; std::vector<float> *vx = new std::vector<float>; std::vector<float> *vy = new std::vector<float>; float a = atan2(y_ - y, x_ - x); int i; for (int j = 0; j < 3; j++) { for (i = 1; i <= n; i++) { a = a + PI * 2 / n; x_ = x + (rad * cos(a) / 6); y_ = y + (rad * sin(a) / 6); vx->push_back(x_); vy->push_back(y_); } if (fill){ GraphicPrimitives::drawFillPolygone2D(*vx, *vy, r, g, b, 1.0f); } else{ GraphicPrimitives::drawOutlinedPolygone2D(*vx, *vy, r, g, b, 1.0f); } if (rad == 0.1){ break; } rad = rad-0.1; setR(1.0); vx->clear(); vy->clear(); } delete vx, vy; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->action_Open,SIGNAL(triggered()),this,SLOT(load())); connect(ui->action_Save,SIGNAL(triggered()),this,SLOT(save())); connect(ui->encryptBtn,SIGNAL(clicked()),this,SLOT(encrypt())); connect(ui->decryptBtn,SIGNAL(clicked()),this,SLOT(decrypt())); connect(ui->actionChange_Median_Blur_Kernel,SIGNAL(triggered()),this,SLOT(setKernel())); connect(ui->actionChange_Eraser_Size,SIGNAL(triggered()),this,SLOT(setR())); setAcceptDrops(true); /* initialization */ setMode(2); // Lasso setStyle(1); // median blur kernel = 51; setR(10); }
void LQRBackup(const Eigen::Matrix<double,xDim,xDim> & A, const Eigen::Matrix<double,xDim,uDim> & B, const Eigen::Matrix<double,xDim,xDim> & Q, const Eigen::Matrix<double,uDim,uDim> & R) { setQ(Q); setR(R); LQRBackup(A, B); }
TranslationRotation3D::TranslationRotation3D(const Type TR_in[6]) : valid_{ true } { double T_in[3], R_in[3]; for (int i = 0; i < 3; i++) { T_in[i] = static_cast<double>(TR_in[i]); R_in[i] = static_cast<double>(TR_in[i + 3]); } setT(T_in); setR(R_in); }
TranslationRotation3D::TranslationRotation3D(Eigen::Vector3d T, Eigen::Vector3d R) { double T_in[3]; double R_in[3]; Eigen::Map<Eigen::Vector3d> T_tmp(T_in); Eigen::Map<Eigen::Vector3d> R_tmp(R_in); T_tmp = T; R_tmp = R; setT(T_in); setR(R_in); }
tLine::tLine(float X1, float Y1, float X2, float Y2) { setX((X1 + X2) / 2); setY((Y1 + Y2) / 2); setR(X1, Y1); setAngle(X1, Y1); setXl(getX()); setYl(getY()); setXr(getX()); setYr(getY()); }
int setParamsN(element *e){ int i,j,k; char buff[256]; if(organizeNodes(e->no)<0){ return(-1); } else{ if(setP(e)<0 || setQ(e)<0 || setR(e)<0) return(-1); } return(0); }
tRhombus::tRhombus(float a, float b) { setR(a); setR2(b); setXtl(this->getX()); setYtl(this->getY()); setXtr(this->getX()); setYtr(this->getY()); setXbl(this->getX()); setYbl(this->getY()); setXbr(this->getX()); setYbr(this->getY()); }
tRectangle::tRectangle(float a, float b) { setR(a, b); setFi(a, b); setXtl(this->getX()); setYtl(this->getY()); setXtr(this->getX()); setYtr(this->getY()); setXbl(this->getX()); setYbl(this->getY()); setXbr(this->getX()); setYbr(this->getY()); }
void MainWindow::rLineVlastniSelected(int a) { if (a == 13)//pokud je v comboboxu zvoleny "Vlastni hodnota" { ui->r_line->show(); //odkryti r_line(vlastni hodnota) ui->r_line->setFocus(); //focus na r_line (vlastni hodnota) ui->r_line->setSelection(0,255); //oznaceni celeho radku ui->r_label_3->show(); //odkryti labelu (p.a.) vedle r_line (vlastni hodnoty) ui->otaznik_button->hide(); //skryti tlacitka otaznik setR(QString("")); //nastaveni registru R na nulu } else { ui->r_line->hide(); //skryti r_line(vlastni hodnota) ui->r_label_3->hide(); //skryti labelu (p.a.) ui->otaznik_button->show(); //odkryti tlacitka Otaznik setR(files->PA(a)); //dosazeni zvolene aktualni hodnoty do registru R } }
EKF::EKF(int _n, int _m, void (*_f_func)(MatrixXd&,MatrixXd&,VectorXd&,const VectorXd&, const float dt), void (*_h_func)(MatrixXd&,VectorXd&,const VectorXd&, const VectorXd&), void (*_c_func)(const VectorXd &, VectorXd &), float _q, float _r) { init_filter( _n, _m); f_func = _f_func; h_func = _h_func; c_func = _c_func; setQ(_q); setR(_r); }
MainWindow::MainWindow(files_control *files) : /*QMainWindow(parent) , */ui(new Ui::MainWindow) { this->files = files; ui->setupUi(this); resize(minimumWidth(), minimumHeight()); seznam_ = new seznam(); PV = new long double(0); R = new double(0); T = new unsigned short int(0); popl = new double(0); popl_last = new double(0); vysledna_hodnota = new QString(); ui->r_line->hide(); ui->r_label_3->hide(); ui->poplatek_line->hide(); ui->skutecny_label->hide(); ui->procento->hide(); ui->poplatek_line->setText("0,00"); //********** doplnovani comboboxu ************ for(int i = 0; i < 13; i++) { ui->r_combo->addItem(QString("MIX %1: %2 %3").arg(i+1).arg(files->PA(i),6, 'f', 2).arg("p.a.", 5)); } ui->r_combo->addItem(QString::fromUtf8("Vlastní hodnota")); //********** dosazovani hodnot ************ connect(this->ui->r_combo, SIGNAL(currentIndexChanged(int)), this , SLOT(rLineVlastniSelected(int))); connect(this->ui->pv_line, SIGNAL(textChanged(QString)), this , SLOT(setPV(QString))); connect(this->ui->t_line, SIGNAL(textChanged(QString)), this, SLOT(setT(QString))); connect(this->ui->r_line, SIGNAL(textChanged(QString)), this, SLOT(setR(QString))); connect(this, SIGNAL(anyValueChanged()), this, SLOT(calculate())); connect(this->ui->otaznik_button, SIGNAL(clicked()), this, SLOT(otaznikClick())); connect(this->ui->action_close_window, SIGNAL(triggered()), this, SLOT(close())); connect(this->ui->poplatek_check, SIGNAL(clicked()), this, SLOT(poplatekChecked())); connect(this->ui->poplatek_line, SIGNAL(textChanged(QString)), this, SLOT(setPopl(QString))); rLineVlastniSelected(1); this->setWindowTitle(APP_NAME); this->ui->otaznik_button->setIcon(QIcon(QPixmap(":/img/info.png"))); }
void TGAImage::initFirstLOD( unsigned char* srcData) { lodData[0] = new unsigned char[ getLODwidth(0) * getLODheight(0) * BPP ] ; for( int i = 0 ; i < getLODwidth(0) ; i++ ) for( int j = 0 ; j < getLODheight(0) ; j++ ) { unsigned char r, g, b, a ; if( srcData ) getRGBA( srcData, i, getLODheight(0) - 1 - j, r, g, b, a ) ; else r = g = b = a = 0 ; setR( 0, i, j, r ) ; setG( 0, i, j, g ) ; setB( 0, i, j, b ) ; setA( 0, i, j, a ) ; } goodLOD = 0 ; }
CSeaData::CSeaData( const CSeaData &object ) { setWaveInputType( object.waveInputType() ); setWaveAngle( object.waveAngle() ); setWaveHeight( object.waveHeight() ); setWaveMaxHeight( object.waveMaxHeight() ); setWaveSpreading( object.waveSpreading() ); setWaveType( object.waveType() ); setWaveLength( object.waveLength() ); setWavePeriod( object.wavePeriod() ); setCurrentInputType( object.currentInputType() ); setFlowAngle( object.flowAngle() ); setFlowSpeed( object.flowSpeed() ); setSeaTemperature( object.seaTemperature() ); setSeaTemperaturechange( object.seaTemperatureChange() ); setIceThickness( object.iceThickness() ); setR( object.r() ); setB( object.b() ); setG( object.g() ); }
CSeaData::CSeaData(): m_dbWaveInputType( false ), m_dWaveAngle( 0.0 ), m_dWaveHeight( 0.0 ), m_dWaveMaxHeight( 0.0 ), m_diWaveSpreading( 0 ), m_dWaveType( 0.0 ), m_dWaveLength( 0.0 ), m_dWavePeriod( 0.0 ), m_dbCurrentInputType( false ), m_dFlowAngle( 0.0 ), m_dFlowSpeed( 0.0 ), m_dSeaTemperature( 0.0 ), m_dSeaTemperaturechange( 0.0 ), m_dIceThickness( 0.0 ) { setR(0); setB(0); setG(0); }
void main() { initLEDs(); // initialisation of strand, as defined in ws2812b.h --> port pin needs to be set there ! ! ! setR(0,0,0xFF); // only setting red channel (will leave other colors unset) unsigned int x; // used for counting loops // do this repeatedly: while (1) { // change brightness ("pulse"): // 1st up: for (x=0;x<20;x++) { setMaxBrightness(x); // change brightness (color will remain red, because no new set command is being applied) showLEDs(); // show LED color with updated brightness _delay_ms(PAUSE); // little pause for our lazy eyes } // 2nd down: for (x=20;x>0;x--) { setMaxBrightness(x); showLEDs(); _delay_ms(PAUSE); } } }
void TGAImage::generateLOD( int lod ) { int dstW = getLODwidth(lod) ; int dstH = getLODheight(lod); if( lodData[lod] == NULL ) lodData[lod] = new unsigned char[ dstW * dstH * BPP ] ; int s = getLODwidth(0) / dstW ; int t = getLODheight(0) / dstH ; for( int i = 0 ; i < dstW ; i++ ) for( int j = 0 ; j < dstH ; j++ ) { int r = 0, g = 0, b = 0, a = 0 ; for( int k = 0 ; k < s ; k++ ) for( int l = 0 ; l < t ; l++ ) { r += getR( 0, i * s + k, j * t + l ) ; g += getG( 0, i * s + k, j * t + l ) ; b += getB( 0, i * s + k, j * t + l ) ; a += getA( 0, i * s + k, j * t + l ) ; } r /= s * t ; g /= s * t ; b /= s * t ; a /= s * t ; setR( lod, i, j, r ) ; setG( lod, i, j, g ) ; setB( lod, i, j, b ) ; setA( lod, i, j, a ) ; } goodLOD = lod ; }
void RNAMencoding(IplImage *img, double epsilon, vector<GrayLevel> &P, vector<char> &Q, vector<CouplePoints> &blks, int &frag_num, int HWratio, int DIRpriority) { CvMat *R = cvCreateMat(img->height, img->width, CV_32FC1); CvMat *F = cvCreateMat(img->height, img->width, CV_32FC1); cvmSetZero(R); cvmSetZero(F); int r, c; int x1, y1, x2, y2; uchar *ptr; CouplePoints ps; for(r = 0; r < F->rows; r++) { ptr = (uchar *)(F->data.ptr + r*F->step); for(c = 0; c < F->cols; c++) { x1 = c; y1 = r; if(ptr[x1] != 0) continue; x2 = x1; y2 = y1; setPS(ps, x1, y1, x2, y2); if(DIRpriority == DIA_FIRST)//1.对角线搜索 { while(x2<img->width && y2<img->height && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps)) { x2++; y2++; setPS(ps, x1, y1, x2, y2); } x2--; y2--; int temp_x2 = x2 + 1; int temp_y2 = y2 + 1; //对角线方向停止,横向继续 setPS(ps, x1, y1, temp_x2, y2); while(temp_x2<img->width && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps)) { temp_x2++; setPS(ps, x1, y1, temp_x2, y2); } temp_x2--; //对角线方向停止,纵向继续 setPS(ps, x1, y1, x2, temp_y2); while(temp_y2<img->height && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps)) { temp_y2++; setPS(ps, x1, y1, x2, temp_y2); } temp_y2--; if(temp_x2 - x2 > temp_y2 - y2)//[对角线 + 横向] 更大 { x2 = temp_x2; } else//[对角线 + 纵向] 更大 { y2 = temp_y2; } } else { if(DIRpriority == ROW_FIRST)//行优先 { while(x2<img->width && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps)) { x2++; setPS(ps, x1, y1, x2, y2); } x2--; setPS(ps, x1, y1, x2, y2); while(y2<img->height && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps)) { y2++; setPS(ps, x1, y1, x2, y2); } y2--; } else//列优先 { while(y2<img->height && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps)) { y2++; setPS(ps, x1, y1, x2, y2); } y2--; setPS(ps, x1, y1, x2, y2); while(x2<img->width && IsHomogeneousBlock(img, ps, epsilon) == true && canF(F, ps)) { x2++; setPS(ps, x1, y1, x2, y2); } x2--; } } if(HWratio != NO_LIMIT)//有长宽比例限制 { if( (x2-x1+1)/(y2-y1+1) > HWratio ) { //宽度过大 x2 = (y2-y1+1)*HWratio + x1-1; } else { if( (y2-y1+1)/(x2-x1+1) >HWratio ) { //长度过大 y2 = (x2-x1+1)*HWratio + y1-1; } } } setPS(ps, x1, y1, x2, y2); blks.push_back(ps); setF(F, ps); setR(R, ps); setP(P, img, ps); } } frag_num = calFragNum(P, R); switch (METHOD) { case METHOD_NAM: CompressCoordinate(R, Q);//坐标矩阵压缩 break; case METHOD_FRAG_NAM: Fragment_CompressCoordinate(R, Q, frag_num);//分段编码压缩 break; case METHOD_AC_NAM: AC_CompressCoordinate(R, _nsym, _count); break; case METHOD_AC_FRAG_NAM: AC_Fragment_CompressCoordinate(R, _nsym, _count, frag_num); break; } // // // //copyMat(cm1, R); //dispIline(R, 484); }
TranslationRotation3D::TranslationRotation3D(bool valid) : valid_{ valid } { double tmpT[3] = { 0.0, 0.0, 0.0 }; setT(tmpT); double tmpR[3] = { 0.0, 0.0, 0.0 }; setR(tmpR); }
TranslationRotation3D::TranslationRotation3D(const double *T_in, const double *R_in) : valid_{ true } { setT(T_in); setR(R_in); }
void TGAImage::setR( int i, int j, int v ) { setR( 0, i, j, v ) ; }
int OnlineSession::run(istream &in, bool interactive) { map<string, int> commands; _prepareCommands(commands); int res = 0; int count = 0; int cmd; string command; string sarg1, sarg2; int iarg1, iarg2, iarg3, iarg4, iarg5, iarg6, iarg7, iarg8; SeriesDistanceMetric *metric; double darg1; GroupableTimeSeriesSet *t; clock_t time; res = 0; while (!in.eof()) { if (res != 0) getout() << "Command returned with status " << res << "." << endl; if (interactive) { int width = getout().width(); getout() << "["; getout().width(3); getout() << count; getout().width(width); getout() << "] > "; getout().flush(); } in >> command; if (command.size() > 0 && !in.eof()) { cmd = commands[command]; } else { cmd = _EXIT; getout() << endl; } time = clock(); try { res = 0; switch (cmd) { case 0: getout() << "Unknown command '" << command << "'. Type 'help' for help." << endl; res = 1; break; case _EXIT: getout() << "Quitting..." << endl; return 0; case _HELP: _print_help(getout()); break; case _DEBUG: in >> iarg1; getout() << "Setting verbosity to " << iarg1 << "." << endl; verbosity = iarg1; break; case _LOAD_TSS: in >> sarg1; getout() << "Loading Time Series Set from file '" << sarg1 << "'." << endl; res = loaddb(sarg1.c_str()); if (res == 0) { getout() << "Dataset successfully loaded. Index: " << datasets.size()-1 << endl; } else { getout() << "Failed to load dataset." << endl; } break; case _SAVE_TSS: in >> iarg1; in >> sarg2; checkIndex(iarg1); t = datasets[iarg1]; getout() << "Saving Time Series Set " << iarg1 << ":" << t->getName() << " to file '" << sarg2 << "'." << endl; res = savedb(iarg1, sarg2.c_str()); if (res == 0) getout() << "Dataset successfully saved." << endl; else getout() << "Failed to save dataset." << endl; break; case _OLOAD_TSS: in >> sarg1; in >> iarg1 >> iarg2 >> iarg3; getout() << "Loading Time Series Set from file '" << sarg1 << "' with N=" << iarg1 << ", L=" << iarg2 << ", and D=" << iarg3 << "." << endl; res = loadolddb(sarg1.c_str(), iarg1, iarg2, iarg3); if (res == 0) { getout() << "Dataset successfully loaded. Index: " << datasets.size()-1 << endl; } else { getout() << "Failed to load dataset." << endl; } break; case _OSAVE_TSS: in >> iarg1; in >> sarg2; checkIndex(iarg1); t = datasets[iarg1]; getout() << "Saving Time Series Set " << iarg1 << ":" << t->getName() << " to file '" << sarg2 << "'." << endl; res = saveolddb(iarg1, sarg2.c_str()); if (res == 0) getout() << "Dataset successfully saved." << endl; else getout() << "Failed to save dataset." << endl; break; case _DROP_TSS: in >> iarg1; checkIndex(iarg1); t = datasets[iarg1]; getout() << "Dropping Time Series Set " << iarg1 << ":" << t->getName() << "." << endl; killdb(iarg1); break; case _RAND_TSS: in >> iarg1 >> iarg2 >> iarg3; getout() << "Generating random Time Series Set with N=" << iarg1 << ", L=" << iarg2 << ", and range=" << iarg3 << "." << endl; res = randdb(iarg3, iarg1, iarg2); if (res == 0) getout() << "Dataset successfully loaded. Index: " << datasets.size()-1 << endl; else getout() << "Failed to load dataset." << endl; break; case _LIST_TSS: res = printdbs(); break; case _NORM_TSS: in >> iarg1; checkIndex(iarg1); t = datasets[iarg1]; getout() << "Normalizing Time Series Set " << iarg1 << ":" << t->getName() << "." << endl; t->normalize(); break; case _KSIM_TSS: in >> iarg1 >> iarg2 >> iarg3 >> iarg4 >> iarg5 >> iarg6; checkIndex(iarg1); checkIndex(iarg2); t = datasets[iarg1]; getout() << "Searching similar sequences for Time Series Set " << iarg1 << ":" << t->getName(); t = datasets[iarg2]; getout() << ", query string at " << iarg3 << " in dataset " << iarg2 << ":" << t->getName(); getout() << " in interval [" << iarg4 << "," << iarg5 << "] with strategy=" << iarg6 << "." << endl; similar(iarg1, iarg2, iarg3, TimeInterval(iarg4, iarg5), iarg6); break; case _OUTLIER_TSS: in >> iarg1 >> iarg2; checkIndex(iarg1); t = datasets[iarg1]; getout() << "Searching for outlier group in dataset " << iarg1 << ":" << t->getName() << " for length=" << iarg2 << "." << endl; outlier(iarg1, iarg2); break; case _TSS_DIST: in >> iarg1 >> iarg2 >> iarg3 >> iarg4; in >> iarg5 >> iarg6 >> iarg7 >> iarg8; in >> sarg1; checkIndex(iarg1); checkIndex(iarg5); metric = getDistMetric(sarg1.c_str()); if (metric == NULL) { getout() << "Unknown method: " << sarg1.c_str() << endl; res = -1; break; } getout() << "Using distance metric " << metric->name << " to find distance:" << endl; getout() << "A: DB:" << iarg1 << ", " << iarg2 << "@[" << iarg3 << "," << iarg4 << "]." << endl; getout() << "B: DB:" << iarg5 << ", " << iarg6 << "@[" << iarg7 << "," << iarg8 << "]." << endl; getout() << "Distance: " << printdist(iarg1, iarg5, iarg2, iarg6, TimeInterval(iarg3, iarg4), TimeInterval(iarg7, iarg8), metric) << endl; break; case _LS_DIST: printDistMetrics(); break; case _GROUP_TSS: in >> iarg1; checkIndex(iarg1); t = datasets[iarg1]; getout() << "Generating new grouping for Time Series Set " << iarg1 << ":" << t->getName() << " with ST " << defaultST << "." << endl; res = initdbgroups(iarg1, defaultST); break; case _GROUP_ST_TSS: in >> iarg1; in >> darg1; checkIndex(iarg1); t = datasets[iarg1]; getout() << "Generating new grouping for Time Series Set " << iarg1 << ":" << t->getName() << " with ST " << darg1 << "." << endl; res = initdbgroups(iarg1, darg1); break; case _LOAD_GROUP_TSS: in >> iarg1; in >> sarg1; checkIndex(iarg1); t = datasets[iarg1]; getout() << "Loading grouping data for Time Series Set " << iarg1 << ":" << t->getName() << " at " << sarg1 << "." << endl; res = loaddbgroups(iarg1, sarg1.c_str()); break; case _SAVE_GROUP_TSS: in >> iarg1; in >> sarg1; checkIndex(iarg1); t = datasets[iarg1]; getout() << "Saving grouping data for Time Series Set " << iarg1 << ":" << t->getName() << " to " << sarg1 << "." << endl; res = savedbgroups(iarg1, sarg1.c_str()); break; case _DROP_GROUP_TSS: in >> iarg1; checkIndex(iarg1); t = datasets[iarg1]; getout() << "Dropping grouping data for Time Series Set " << iarg1 << ":" << t->getName() << "." << endl; res = killdbgroups(iarg1); break; case _DESC_TSS: in >> iarg1; checkIndex(iarg1); res = descdb(iarg1); break; case _PRINT_TSS: in >> iarg1; checkIndex(iarg1); res = printdb(iarg1); break; case _PRINT_INTERVAL: in >> iarg1 >> iarg2 >> iarg3 >> iarg4; checkIndex(iarg1); res = printint(iarg1, iarg2, TimeInterval(iarg3, iarg4)); break; case _SET_DEF_ST: in >> darg1; getout() << "Setting default ST to " << darg1 << "." << endl; res = setST(darg1); break; case _GET_DEF_ST: getout() << "default ST = " << getST() << "." << endl; break; case _SET_DEF_R: in >> iarg1; getout() << "Setting default R constraint to " << iarg1 << "." << endl; res = setR(iarg1); break; case _GET_DEF_R: getout() << "default R = " << getR() << "." << endl; break; } } catch (exception &e) { getout() << "Caught exception attempting operation:" << endl; getout() << e.what() << endl; } time = clock() - time; getout() << "Command used " << ((float)time/CLOCKS_PER_SEC) << " seconds." << endl << endl; count++; } return 0; }