void bench_dist_chamfrain() { bench_env_klip(Pt2di(200,300)); { Im2D<U_INT1,INT> I(300,300,0); //ELISE_COPY(disc(Pt2di(150,150),120),1,I.out()); ELISE_COPY(disc(Pt2dr(150,150),120),1,I.out()); // __NEW dist_chamfer_cabl(I,35); } { Im2D<U_INT1,INT> I(600,600,0); //ELISE_COPY(disc(Pt2di(300,300),290),1,I.out()); //ELISE_COPY(disc(Pt2di(300,300),5),0,I.out()); ELISE_COPY(disc(Pt2dr(300,300),290),1,I.out()); // __NEW ELISE_COPY(disc(Pt2dr(300,300),5),0,I.out()); // __NEW dist_chamfer_cabl(I,144); } cout << "OK chamfer TEST \n"; }
void Board::initMovable() { Disc disc(0, 0, CurrentColor); int dir; MovablePos[Turns].clear(); for(int x=1; x<=BOARD_SIZE; x++) { disc.x = x; for(int y=1; y<=BOARD_SIZE; y++) { disc.y = y; dir = checkMobility(disc); if(dir != NONE) { // 置ける MovablePos[Turns].push_back(disc); } MovableDir[Turns][x][y] = dir; } } }
TEST(TestSplineUtils, ProjectSurface) { Go::Disc disc(Go::Point(0.0, 0.0, 0.0), 1.0, Go::Point(1.0/sqrt(2.0), 1.0/sqrt(2.0), 0.0), Go::Point(0.0, 0.0, 1.0)); Go::SplineSurface* srf = disc.createSplineSurface(); srf->setParameterDomain(0.0, 1.0, 0.0, 1.0); EvalFunction func("sin(x)*sin(y)*t"); VecFuncExpr func2("sin(x)*sin(y)*t|cos(x)*cos(y)*t"); Go::SplineSurface* prjSrf = SplineUtils::project(srf, func, 0.1); Go::SplineSurface* prjSrf2 = SplineUtils::project(srf, func2, 2, 0.1); Vec3 result1, result2, result3, result4; SplineUtils::point(result1, 0.5, 0.5, prjSrf); SplineUtils::point(result2, 0.8, 0.8, prjSrf); SplineUtils::point(result3, 0.5, 0.5, prjSrf2); SplineUtils::point(result4, 0.8, 0.8, prjSrf2); ASSERT_FLOAT_EQ(result1[0], 0.02110140763086564); ASSERT_FLOAT_EQ(result2[0], -0.02189938149140131); ASSERT_FLOAT_EQ(result3[0], 0.02110140763086564); ASSERT_FLOAT_EQ(result3[1], 0.07889859236913437); ASSERT_FLOAT_EQ(result4[0], -0.02189938149140131); ASSERT_FLOAT_EQ(result4[1], 0.06514225417205573); }
void ProcessSignal() { signal.Scale(3); signal.WriteHSpiceSignalInclude("../ASDBLR/hspice.inc","isource","n1a","0"); system("hspice ../ASDBLR/ASDSigs.hsp >hspice.out"); Signals::Signal Ternary(0.5); std::vector<std::string> TernaryVar; TernaryVar.push_back("ternary"); TernaryVar.push_back(""); TernaryVar.push_back(""); Ternary.ReadSignalFromHSpicelis("hspice.out",TernaryVar); Ternary.Shift(-Ternary.GetSignalBin(0)); Signals::Discriminate disc(0.5,0.4); Signals::Rebin rebin(25); Signals::Discriminate lowdisc(0.5,0.1); Signals::Rebin lowrebin(3.125); Ternary>>disc>>rebin; Ternary>>lowdisc>>lowrebin; std::cout<<"FirstBins:"<<rebin.FirstBinBlock()<<std::endl; std::cout<<"LowFirstBins:"<<lowrebin.FirstBinBlock()<<std::endl; std::cout<<"Ternary"<<Ternary.IntegralBelow(0)<<std::endl; std::cout<<lowdist<<std::endl; lowdist->Fill(lowrebin.FirstBinBlock()); std::cout<<highdist<<std::endl; highdist->Fill(rebin.FirstBinBlock()); std::cout<<"FILL//"<<std::endl; }
//現在の局面で、現在の番手(黒or白)が置ける場所を計算する //MovableDirとMovablePosを再計算する void Board::initMovable() { Disc disc(0, 0, CurrentColor);//構造体のインスタンスを現在色で作成 int dir; //ポジションクリア MovablePos[Turns].clear(); //盤の全ての目において、置けるかどうかを調べる。 for(int x=1; x<=BOARD_SIZE; x++)//x=0の時は壁なので1から開始する { disc.x = x; for(int y=1; y<=BOARD_SIZE; y++) { disc.y = y; //石を置ける場所か判定 dir = checkMobility(disc); //discの位置に置けるなら、discから見て石が返る方向を表したビットを取得 if(dir != NONE) { // 置ける MovablePos[Turns].push_back(disc); //末尾に格納(discのコピーが格納される?) } MovableDir[Turns][x][y] = dir; //置ける方向を表したビット(NONEでもNONE以外でも結果を格納) } } }
void update( genetic_space_type * parents, unsigned int count ) { // pre-scan fitness typedef typename genetic_space_type::fitness_iterator iterator; iterator first = parents->fitness_begin(), last = parents->fitness_end(); bool constant_fitness = true; unsigned int N = 0; if( first != last ) { typename genetic_space_type::fitness_score_type prev = *first++; ++N; while( constant_fitness && first != last ) { constant_fitness = (prev == *first++); ++N; } } if( constant_fitness ) { uniform_distribution_type uni( 0, N - 1 ); generate( uni, count ); } else { discrete_distribution_type disc( parents->fitness_begin(), parents->fitness_end() ); generate( disc, count ); } }
unsigned int ProcessSignal(Signals::Signal& signal,std::string signalid) { signal.Graph()->Draw("AL"); canvas->Update(); canvas->Print(("debs/"+signalid+"sig.pdf").c_str()); signal.WriteHSpiceSignalInclude("../ASDBLR/hspice.inc","isource","n1a","0"); system("hspice ../ASDBLR/ASDSigs.hsp >hspice.out"); Signals::Signal Ternary(0.5); std::vector<std::string> TernaryVar; TernaryVar.push_back("ternary"); TernaryVar.push_back(""); TernaryVar.push_back(""); Ternary.ReadSignalFromHSpicelis("hspice.out",TernaryVar); Ternary.Shift(-Ternary.GetSignalBin(0)); Ternary.Graph()->Draw("AL"); canvas->Update(); canvas->Print(("debs/"+signalid+"ter.pdf").c_str()); Signals::Discriminate disc(0.5,0.4); Signals::Rebin rebin(25); Signals::Discriminate lowdisc(0.5,0.1); Signals::Rebin lowrebin(3.125); Ternary>>disc>>rebin; Ternary>>lowdisc>>lowrebin; leadingb=disc.LeadingBin()*disc.GetSignalBinTime(); trailingb=disc.TrailingBin()*disc.GetSignalBinTime(); lastbinblock=disc.LastBinBlock()*disc.GetSignalBinTime(); return disc.FirstBinBlock()*disc.GetSignalBinTime(); }
int main() { float i, j, k, x1, x2; int less=0, more_equal=0, error=0; float min = 1, max = 20; // FILE* discOut = fopen("disc.txt", "w"); for(i = min; i<max; i++){ for(j = min; j<max; j++){ for(k = min; k<max; k++){ printf("a = %.0f, b = %0.f, c = %0.f, D = %.3f", i, j, k, disc(i, j, k)); if(disc(i, j, k) < 0) { less++; printf(" Discriminant less than zero"); } else { x1 = (-j-sqrt(disc(i, j, k)))/(2*i); x2 = (-j+sqrt(disc(i, j, k)))/(2*i); int tempx1 = (int) i*(x1*x1)+j*x1+k; int tempx2 = (int) i*(x2*x2)+j*x2+k; if(tempx1 == 0 && tempx2 == 0){ more_equal++; printf(" %0.f*(%0.f^2) + %0.f*(%0.f) + %0.f = %0.f*%0.f^2 + %0.f*%0.f + k = 0", i, x1, j, x1, k, i, x2, j, x2, k); }else error++; } printf("\n"); } } } // fclose(discOut); printf("Done!"); if ((error + more_equal + less) != (max-min)*(max-min)*(max-min)) {printf ("\n CHISLO URAVNENIY NE SOVPADAET"); return 2; } else if (error > 0) { return 1; printf("\n ERROR = %d", error); } else return 0; }
int ContentUI::getDiscLength(EPanels panel) const { SettingsManager settingsManager; QString disc(settingsManager.accountDisc(settingsManager.currentAccount(static_cast <int> (panel)))); disc += QString(":"); disc += QDir::toNativeSeparators("/"); return disc.length(); }
void MQFunctions::disc(PMQHCONN conn) { MQLONG cc = MQCC_OK; MQLONG rc = MQRC_NONE; disc(conn, &cc, &rc); if ( cc != MQCC_OK ) { throw MQException("", "MQDISC", cc, rc); } }
int main() { double radius; double area; // don't declare as pointers double circum; printf("Enter the radius: "); scanf("%lf", &radius); // just pass the pointers using & disc(radius, &area, &circum); printf("Radius = %lf\n", radius); printf("Area = %lf\n", area); printf("Circumference = %lf\n", circum); return 0; }
void bench_disque_cercle ( Pt2di c, REAL r ) { Pt2dr c_r( (REAL)c.x, (REAL)c.y ); bench_front_to_surf ( //circle(c,r,true), //circle(c,r,false), //disc(c,r,true), //disc(c,r,false), circle(c_r,r,true), // __NEW circle(c_r,r,false), // __NEW disc(c_r,r,true), // __NEW disc(c_r,r,false), // __NEW Square(FX-c.x)+Square(FY-c.y) < ElSquare(r), true, true, c+round_ni(Pt2dr(r,r)+Pt2dr(6,6)) ); }
bool VistleConnection::disconnect(const Port *from, const Port *to) const { message::Disconnect disc(from->getModuleID(), from->getName(), to->getModuleID(), to->getName()); return sendMessage(disc); }
void DMGeneralLeakDeriv::pdfseq(size_t n, ExtArray& g1, ExtArray& g2) { assert(n > 0); /* precompute some constants */ const double sqrt_2_pi = 1 / sqrt(2 * PI); const double dt_sqrt_2_pi = dt_ * sqrt_2_pi; const double exp_leak = exp(- dt_ * invleak_); const double exp2_leak = exp(- 2 * dt_ * invleak_); /* cumulative mu and sig2, and discount (leak) */ std::vector<double> cum_drift(n); std::vector<double> cum_sig2(n); std::vector<double> disc(n); double curr_cum_drift = dt_ * drift_[0]; cum_drift[0] = curr_cum_drift; double curr_cum_sig2 = dt_ * sig2_[0]; cum_sig2[0] = curr_cum_sig2; double curr_disc = exp_leak; disc[0] = curr_disc; for (int j = 1; j < n; ++j) { curr_cum_drift = exp_leak * curr_cum_drift + dt_ * drift_[j]; cum_drift[j] = curr_cum_drift; curr_cum_sig2 = exp2_leak * curr_cum_sig2 + dt_ * sig2_[j]; cum_sig2[j] = curr_cum_sig2; curr_disc *= exp_leak; disc[j] = curr_disc; } /* double discount (leak), * note that disc[k - j - 1] = exp(- invleak dt (k - j)) * disc2[k - j - 1] = exp(- 2 invleak dt (k - j)) * such that half of disc can be used to compute disc2 */ std::vector<double> disc2(n); int k = (int) floor(((double) (n - 1)) / 2); for (int j = 0; j <= k; ++j) disc2[j] = disc[2 * j + 1]; curr_disc = disc2[k]; for (int j = k + 1; j < n; ++j) { curr_disc *= exp2_leak; disc2[j] = curr_disc; } /* fill up g1 and g2 recursively */ for (k = 0; k < n; ++k) { /* speed increase by reducing array access */ const double sig2_k = sig2_[k]; const double b_up_k = b_up_[k]; const double b_lo_k = b_lo_[k]; const double cum_drift_k = cum_drift[k]; const double cum_sig2_k = cum_sig2[k]; const double sqrt_cum_sig2_k = sqrt(cum_sig2_k); const double b_up_deriv_k = b_up_deriv_[k] + invleak_ * b_up_k - drift_[k]; const double b_lo_deriv_k = b_lo_deriv_[k] + invleak_ * b_lo_k - drift_[k]; /* initial values */ double g1_k = -sqrt_2_pi / sqrt_cum_sig2_k * exp(-0.5 * (b_up_k - cum_drift_k) * (b_up_k - cum_drift_k) / cum_sig2_k) * (b_up_deriv_k - sig2_k * (b_up_k - cum_drift_k) / cum_sig2_k); double g2_k = sqrt_2_pi / sqrt_cum_sig2_k * exp(-0.5 * (b_lo_k - cum_drift_k) * (b_lo_k - cum_drift_k) / cum_sig2_k) * (b_lo_deriv_k - sig2_k * (b_lo_k - cum_drift_k) / cum_sig2_k); /* relation to previous values */ for (int j = 0; j < k; ++j) { /* reducing array access + pre-compute values */ const double disc_j = disc[k - j - 1]; const double cum_sig2_diff_j = cum_sig2_k - disc2[k - j - 1] * cum_sig2[j]; const double sqrt_cum_sig2_diff_j = sqrt(cum_sig2_diff_j); const double cum_drift_diff_j = disc_j * cum_drift[j] - cum_drift_k; const double b_up_k_up_j_diff = b_up_k - disc_j * b_up_[j] + cum_drift_diff_j; const double b_up_k_lo_j_diff = b_up_k - disc_j * b_lo_[j] + cum_drift_diff_j; const double b_lo_k_up_j_diff = b_lo_k - disc_j * b_up_[j] + cum_drift_diff_j; const double b_lo_k_lo_j_diff = b_lo_k - disc_j * b_lo_[j] + cum_drift_diff_j; /* add values */ g1_k += dt_sqrt_2_pi / sqrt_cum_sig2_diff_j * (g1[j] * exp(-0.5 * b_up_k_up_j_diff * b_up_k_up_j_diff / cum_sig2_diff_j) * (b_up_deriv_k - sig2_k * b_up_k_up_j_diff / cum_sig2_diff_j) + g2[j] * exp(-0.5 * b_up_k_lo_j_diff * b_up_k_lo_j_diff / cum_sig2_diff_j) * (b_up_deriv_k - sig2_k * b_up_k_lo_j_diff / cum_sig2_diff_j)); g2_k -= dt_sqrt_2_pi / sqrt_cum_sig2_diff_j * (g1[j] * exp(-0.5 * b_lo_k_up_j_diff * b_lo_k_up_j_diff / cum_sig2_diff_j) * (b_lo_deriv_k - sig2_k * b_lo_k_up_j_diff / cum_sig2_diff_j) + g2[j] * exp(-0.5 * b_lo_k_lo_j_diff * b_lo_k_lo_j_diff / cum_sig2_diff_j) * (b_lo_deriv_k - sig2_k * b_lo_k_lo_j_diff / cum_sig2_diff_j)); } /* avoid negative densities that could appear due to numerical instab. */ g1[k] = std::max(g1_k, 0.0); g2[k] = std::max(g2_k, 0.0); } }
void DrawContext::drawRoundRect(const Rect& rect, u16 r, const Color& col) { TexturePtr tex = disc(r); drawRR(rect, r, tex, col); }
void GraphicTestWindow::onPaint(int width, int height) { glClearColor(1.0f, 1.0f, 1.0f, 1.0f); _image.setTextureCoordinate(1, 3); _image.setSize(_image.originalSize()); _image.draw(); _rect.setColor(QColor(0, 255, 0)); _rect.setRect(50, 100, 500, 75); _rect.draw(); _rect.setColor(QColor(0, 255, 255)); _rect.setRect(50, 175, 500, 25); _rect.draw(); int textCount = 1; int quadCount = 1; QString textContent("Change the text from the settings"); if(_settings) { quadCount = _settings->quadCount(); textCount = _settings->textCount(); textContent = _settings->textContent(); } for(int i = 0; i < textCount; i++) { PhGraphicText text1(&_font1, textContent); text1.setRect(i % 200, i / 200, 500, 100); text1.setColor(QColor(128, 255, 0)); text1.setZ(5); text1.draw(); } _font1.setFontFile(_settings->font1File()); _font1.select(); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glColor3f(0, 0, 1); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_QUADS); //Begining the cube's drawing { for(int i = 0; i < quadCount; i++) { glTexCoord3f(0, 0, 1); glVertex3i(0, 0, 0); glTexCoord3f(1, 0, 1); glVertex3i(width, 0, 0); glTexCoord3f(1, 1, 1); glVertex3i(width, height, 0); glTexCoord3f(0, 1, 1); glVertex3i(0, height, 0); } } glEnd(); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); // _text.setX(_text.getX() + 4); // if(_text.getX() > this.width()) // _text.setX(0); // if((_text.getX()+_text.getWidth()) < 0) // _text.setX(this.width()); PhGraphicSolidRect rect3(0, 800, 400, 300); rect3.setColor(Qt::blue); rect3.draw(); PhGraphicLoop vLoop; vLoop.setPosition(100, 500, 3); vLoop.setSize(220, 200); vLoop.setThickness(30); vLoop.setCrossSize(100); vLoop.setColor(QColor(255, 0, 255)); vLoop.draw(); PhGraphicLoop hLoop; hLoop.setHorizontalLoop(true); hLoop.setPosition(0, 800, 3); hLoop.setSize(300, 50); hLoop.setThickness(20); hLoop.setCrossSize(60); hLoop.setColor(QColor(255, 0, 255)); hLoop.draw(); //_yuvRect.draw(); PhGraphicDisc disc(300, 300, 100); disc.setColor(Qt::yellow); disc.draw(); for (int i = 0; i < 5; ++i) { PhGraphicDashedLine line(i, 0, 50*i, 300, 30); line.setColor(Qt::green); line.setZ(4); line.draw(); } PhGraphicArrow arrow1(PhGraphicArrow::DownLeftToUpRight, 150, 250, 200, 100); arrow1.setColor(Qt::red); arrow1.setZ(5); arrow1.draw(); PhGraphicArrow arrow2(PhGraphicArrow::UpLefToDownRight, 150, 400, 200, 100); arrow2.setColor(Qt::red); arrow2.setZ(5); arrow2.draw(); _yuvRect.draw(); _rgbRect.draw(); _font2.setFontFile(_settings->font2File()); _font2.select(); PhGraphicText text2(&_font2, "eéaàiîoô"); int textWidth = 500; text2.setRect(_x, 300, textWidth, 100); text2.setColor(QColor(255, 0, 0)); text2.setZ(1); text2.draw(); _x += 4; if(_x > width) _x = -textWidth; }
static gboolean expose (GtkWidget *da, GdkEventExpose *event, gpointer user_data) { GdkGLContext *glcontext = gtk_widget_get_gl_context (da); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (da); // g_print (" :: expose\n"); if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) { g_assert_not_reached (); } /* draw in here */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); //glRotatef (ang, 1, 0, 0); glRotatef (ang, 0, 1, 0); // glRotatef (ang, 0, 0, 1); glShadeModel(GL_FLAT); #if 0 glBegin (GL_QUADS); glColor4f(0.0, 0.0, 1.0, ALPHA); glVertex3fv(boxv[0]); glVertex3fv(boxv[1]); glVertex3fv(boxv[2]); glVertex3fv(boxv[3]); glColor4f(1.0, 1.0, 0.0, ALPHA); glVertex3fv(boxv[0]); glVertex3fv(boxv[4]); glVertex3fv(boxv[5]); glVertex3fv(boxv[1]); glColor4f(0.0, 1.0, 1.0, ALPHA); glVertex3fv(boxv[2]); glVertex3fv(boxv[6]); glVertex3fv(boxv[7]); glVertex3fv(boxv[3]); glColor4f(1.0, 0.0, 0.0, ALPHA); glVertex3fv(boxv[4]); glVertex3fv(boxv[5]); glVertex3fv(boxv[6]); glVertex3fv(boxv[7]); glColor4f(1.0, 0.0, 1.0, ALPHA); glVertex3fv(boxv[0]); glVertex3fv(boxv[3]); glVertex3fv(boxv[7]); glVertex3fv(boxv[4]); glColor4f(0.0, 1.0, 0.0, ALPHA); glVertex3fv(boxv[1]); glVertex3fv(boxv[5]); glVertex3fv(boxv[6]); glVertex3fv(boxv[2]); glEnd (); #endif /*glBegin (GL_LINES); glColor3f (1., 0., 0.); glVertex3f (0., 0., 0.); glVertex3f (1., 0., 0.); glEnd (); glBegin (GL_LINES); glColor3f (0., 1., 0.); glVertex3f (0., 0., 0.); glVertex3f (0., 1., 0.); glEnd (); glBegin (GL_LINES); glColor3f (0., 0., 1.); glVertex3f (0., 0., 0.); glVertex3f (0., 0., 1.); glEnd ();*/ //circle(0.3, 0.2, 0.8, 36); glColor4f(0.0, 1.0, 0.0, ALPHA); disc( 0.3 , 0.2 , 0.8 , 36, 0.5); /*glBegin(GL_LINES); glColor3f (1., 1., 1.); glVertex3fv(boxv[0]); glVertex3fv(boxv[1]); glVertex3fv(boxv[1]); glVertex3fv(boxv[2]); glVertex3fv(boxv[2]); glVertex3fv(boxv[3]); glVertex3fv(boxv[3]); glVertex3fv(boxv[0]); glVertex3fv(boxv[4]); glVertex3fv(boxv[5]); glVertex3fv(boxv[5]); glVertex3fv(boxv[6]); glVertex3fv(boxv[6]); glVertex3fv(boxv[7]); glVertex3fv(boxv[7]); glVertex3fv(boxv[4]); glVertex3fv(boxv[0]); glVertex3fv(boxv[4]); glVertex3fv(boxv[1]); glVertex3fv(boxv[5]); glVertex3fv(boxv[2]); glVertex3fv(boxv[6]); glVertex3fv(boxv[3]); glVertex3fv(boxv[7]); glEnd();*/ glPopMatrix (); if (gdk_gl_drawable_is_double_buffered (gldrawable)) gdk_gl_drawable_swap_buffers (gldrawable); else glFlush (); gdk_gl_drawable_gl_end (gldrawable); return TRUE; }
int main() { const int WINDOW_WIDTH = 748;//873 const int WINDOW_HEIGHT = 440;//491 const int YARDSIZE = 12; const int FIELDW = (131*YARDSIZE); const int FIELDH = (41*YARDSIZE); const int ENDZONE = (25*YARDSIZE); const int NUMPLAYERS = 12; int x = FIELDW-WINDOW_WIDTH; int y = 0; int loop = 0; double rotation = 0; double height = -1*PI/6 ; float power = 0; bool direction = true; bool nkey = false; bool zkey = false; bool xkey = false; bool mkey = false; Team teams[2]; cout << "Welcome to the first test of College Ultimate\n"; Window test(WINDOW_WIDTH,WINDOW_HEIGHT, "College Ultimate Test", false); Field stndfield(YARDSIZE, FIELDW, FIELDH, ENDZONE); teams[0].initialize(275, FIELDH, Color(255,255,255), true, "guy1runleft.png","guy1runright.png","guy1standleft.png","guy1standright.png"); teams[1].initialize(1275, FIELDH, Color(0,0,0), false, "guy2runleft.png","guy2runright.png","guy2standleft.png","guy2standright.png"); Frisbee disc(290,FIELDH/2); test.disableAutoPageFlip(); TimerEvent clock = test.startTimer(25); //game loop while(true) { test.waitForTimerEvent(); stndfield.drawField(test, x, y); if(test.isKeyDown(NamedKey::ESCAPE)) return 0; disc.centerWindow(x,y,test); if(teams[0].getIXpos() < (FIELDW/2) ) { teams[0].hasCaught(teams[1], disc, teams[0].getCaught()+teams[1].getCaught(), rotation, teams[0].getInit()+teams[1].getInit(), FIELDW-ENDZONE, FIELDW, YARDSIZE, FIELDH); teams[1].hasCaught(teams[0], disc, teams[0].getCaught()+teams[1].getCaught(), rotation, teams[0].getInit()+teams[1].getInit(), YARDSIZE, ENDZONE+YARDSIZE, YARDSIZE, FIELDH); } else { teams[0].hasCaught(teams[1], disc, teams[0].getCaught()+teams[1].getCaught(), rotation, teams[0].getInit()+teams[1].getInit(), YARDSIZE, ENDZONE+YARDSIZE, YARDSIZE, FIELDH); teams[1].hasCaught(teams[0], disc, teams[0].getCaught()+teams[1].getCaught(), rotation, teams[0].getInit()+teams[1].getInit(), FIELDW-ENDZONE, FIELDW, YARDSIZE, FIELDH); } if(!(teams[0].getCaught()+teams[1].getCaught()) ) { disc.move(rotation,power,height, FIELDW, FIELDH, YARDSIZE); } else { //////throw sceen if(teams[1].getCaught() && (teams[1].getCaught()-1 == teams[1].isSelected()) ) { if(test.isKeyDown(NamedKey::LEFT_ARROW)) { rotation -= (0.075); } if(test.isKeyDown(NamedKey::RIGHT_ARROW)) { rotation += (0.075); } if(test.isKeyDown(NamedKey::UP_ARROW)) { if(height > -1*PI/6 ) height -= (0.075); } if(test.isKeyDown(NamedKey::DOWN_ARROW)) { if(height < -0.075 ) height += (0.075); } } if(teams[0].getCaught() && (teams[0].getCaught()-1 == teams[0].isSelected()) ) { if(test.isKeyDown('1')) { rotation -= (0.075); } if(test.isKeyDown('3')) { rotation += (0.075); } if(test.isKeyDown('5')) { if(height > -1*PI/6 ) height -= (0.075); } if(test.isKeyDown('2')) { if(height < -0.075 ) height += (0.075); } } if(teams[0].getCaught() && (teams[0].getCaught()-1 != teams[0].isSelected()) && teams[0].getInit()) { rotation = teams[0].findRotation(); } if(teams[1].getCaught() && (teams[1].getCaught()-1 != teams[1].isSelected()) && teams[1].getInit()) { rotation = teams[1].findRotation(); } disc.drawArrow(test, teams[0].givePlayer(teams[0].getCaught()-1), x, y, rotation); disc.drawArrow(test, teams[1].givePlayer(teams[1].getCaught()-1), x, y, rotation); if(test.isKeyDown('x') && !xkey && teams[1].getCaught() != false) { xkey = true; power = 0; } if(test.isKeyDown('9') && !mkey && teams[0].getCaught() != false) { mkey = true; power = 0; } if(test.isKeyDown('x') && xkey && teams[1].getCaught() != false) { if(power<8.9) power += (float)(.15); } if(test.isKeyDown('9') && mkey && teams[0].getCaught() != false) { if(power<8.9) power += (float)(.15); } if(!test.isKeyDown('9') && mkey && teams[0].getStatus()!=2 && teams[0].getCaught() != false) { mkey = false; if( teams[0].getInit() == false && teams[0].getCaught() != false) { teams[0].changeInit(true); teams[0].changeStatus(2); } teams[0].clearCaught(); teams[1].clearCaught(); disc.throwFrisbee(); for(loop = 0; loop<7; ++loop) { disc.move(rotation,power, height, FIELDW, FIELDH, YARDSIZE); } } if(!test.isKeyDown('x') && xkey && teams[1].getStatus()!=2 && teams[1].getCaught() != false) { xkey = false; if( teams[1].getInit() == false && teams[1].getCaught() != false) { teams[1].changeInit(true); teams[1].changeStatus(2); } teams[0].clearCaught(); teams[1].clearCaught(); disc.throwFrisbee(); for(loop = 0; loop<7; ++loop) { disc.move(rotation,power, height, FIELDW, FIELDH, YARDSIZE); } } ///////////////////// } if(teams[0].getStatus() == 3 && teams[1].getStatus() != 3 && teams[0].getInit() != false) disc.changeInit(teams[0].getIXpos()+30, FIELDH/2); if(teams[1].getStatus() == 3 && teams[0].getStatus() != 3 && teams[1].getInit() != false) disc.changeInit(teams[1].getIXpos()+30, FIELDH/2); if(teams[0].getStatus() == 3 || teams[1].getStatus() == 3) { teams[0].changeStatus(3); teams[1].changeStatus(3); teams[0].clearCaught(); teams[1].clearCaught(); teams[0].changeInit(false); teams[1].changeInit(false); if(teams[0].lineUp(FIELDW, FIELDH, YARDSIZE) ) teams[0].changeStatus(0); if(teams[1].lineUp(FIELDW, FIELDH, YARDSIZE) ) teams[1].changeStatus(0); disc.restart(); } //teams[0].sortClosest(disc); //teams[1].sortClosest(disc); if(test.isKeyDown('z') && !zkey) { teams[1].nextSelected(); zkey = true; } if(test.isKeyDown('7') && !nkey) { teams[0].nextSelected(); nkey = true; } if(!test.isKeyDown('z') && zkey) zkey = false; if(!test.isKeyDown('7') && nkey) nkey = false; if(teams[0].getInit()+teams[1].getInit() && (teams[1].getCaught()-1!= teams[1].isSelected()) ) { if(test.isKeyDown(NamedKey::LEFT_ARROW)) { teams[1].move(teams[1].isSelected(), -8, 0, FIELDW, FIELDH, YARDSIZE); } if(test.isKeyDown(NamedKey::RIGHT_ARROW)) { teams[1].move(teams[1].isSelected(), 8, 0, FIELDW, FIELDH, YARDSIZE); } if(test.isKeyDown(NamedKey::UP_ARROW)) { teams[1].move(teams[1].isSelected(), 0,-8, FIELDW, FIELDH, YARDSIZE); } if(test.isKeyDown(NamedKey::DOWN_ARROW)) { teams[1].move(teams[1].isSelected(), 0, 8, FIELDW, FIELDH, YARDSIZE); } } if(teams[0].getInit()+teams[1].getInit() && (teams[0].getCaught()-1!=teams[0].isSelected()) ) { if(test.isKeyDown('1')) { teams[0].move(teams[0].isSelected(), -8, 0, FIELDW, FIELDH, YARDSIZE); } if(test.isKeyDown('3')) { teams[0].move(teams[0].isSelected(), 8, 0, FIELDW, FIELDH, YARDSIZE); } if(test.isKeyDown('5')) { teams[0].move(teams[0].isSelected(), 0, -8, FIELDW, FIELDH, YARDSIZE); } if(test.isKeyDown('2')) { teams[0].move(teams[0].isSelected(), 0, 8, FIELDW, FIELDH, YARDSIZE); } } teams[0].decisiveMove(disc, teams[1], teams[0].getInit()+teams[1].getInit(), FIELDW, FIELDH, YARDSIZE); teams[1].decisiveMove(disc, teams[0], teams[0].getInit()+teams[1].getInit(), FIELDW, FIELDH, YARDSIZE); teams[0].drawTeam(test, x, y); teams[1].drawTeam(test, x, y); disc.drawFrisbee(test, x, y); //Scoreboard //test.drawRectangleFilled(Style::BLACK, 0, test.getHeight()*6/7, test.getWidth(), test.getHeight() ); test.drawText( Style(Color::WHITE, 2), Font(Font::ROMAN, 16), 5, test.getHeight()-42, "Fish"); test.drawText( Style(Color::WHITE, 2), Font(Font::ROMAN, 16), 160, test.getHeight()-42, test.numberToString(teams[0].getScore() ) ); test.drawText( Style(Color::WHITE, 2), Font(Font::ROMAN, 16), 5, test.getHeight()-17, "Veggies"); test.drawText( Style(Color::WHITE, 2), Font(Font::ROMAN, 16), 160, test.getHeight()-17, test.numberToString(teams[1].getScore() )); //Powerbar test.drawText( Style(Color::WHITE, 1.5), Font(Font::ROMAN, 10), test.getWidth()/3+40, test.getHeight()-40, "Power:"); test.drawRectangleFilled(Style(Color(255,145,0), 1), test.getWidth()/3-10, test.getHeight()-33, test.getWidth()/3-10+(power*16.666), test.getHeight()-21); test.drawRectangleOutline(Style(Color::WHITE, 1), test.getWidth()/3-10, test.getHeight()-33, test.getWidth()/3 + 140, test.getHeight()-21); //Heightbar test.drawLine( Style(Color::WHITE, 5), test.getWidth()/3 +202.5+(27.5*cos(height)), test.getHeight()-35+(27.5*sin(height)), test.getWidth()/3+202.5+(27.5*cos(height+PI)), test.getHeight()-35+(27.5*sin(height+PI))); //Feild Map test.drawRectangleFilled(Style::GREEN, test.getWidth()*3/4, test.getHeight()-55, test.getWidth()*3/4+(FIELDW/YARDSIZE), test.getHeight()-55+(FIELDH/YARDSIZE)); test.drawRectangleOutline(Style(Color::WHITE, 1), test.getWidth()*3/4, test.getHeight()-55, test.getWidth()*3/4+(FIELDW/YARDSIZE), test.getHeight()-55+(FIELDH/YARDSIZE)); test.drawRectangleOutline(Style(Color::WHITE, 1), test.getWidth()*3/4+(ENDZONE/YARDSIZE), test.getHeight()-55, test.getWidth()*3/4+(FIELDW-ENDZONE)/YARDSIZE, test.getHeight()-55+(FIELDH/YARDSIZE)); teams[0].drawPixels(test, YARDSIZE); teams[1].drawPixels(test, YARDSIZE); disc.drawPixel(test, YARDSIZE); test.flipPage(); } return 0; }
void gxRenderingTriangle::RenderAsDisc() { mlDisc disc(a, b, c); disc.Render(gxColorPurple, true); }
template <class Type> void Bench_PackB_IM<Type>::verif() { INT def = (INT)(NRrandom3() * 1000); verif( rectangle(Pt2di(1,0),Pt2di(2,1))); for (INT k=0; k<10 ; k++) { verif( rectangle(Pt2di(k,0),Pt2di(k+1,10) ),def); verif( rectangle(Pt2di(k,0),Pt2di(k+10,10) ),def); verif( rectangle(Pt2di(k,0),Pt2di(k+100,10)),def); verif( rectangle(Pt2di(k,0),Pt2di(k+200,10)),def); } verif( im1.all_pts()); verif( rectangle(Pt2di(-10,-20),sz+Pt2di(30,40)),def); verif( disc(sz/2.0,euclid(sz)/1.8),def); { for (INT k=0 ; k<10 ; k++) { Pt2dr c = sz/2.0 + Pt2dr(NRrandom3(),NRrandom3())*20; REAL ray = 1+NRrandom3()*100; verif(disc(c,ray),def); } } ELISE_COPY(disc(CentreRand(),RayonRand()),1,im1.out()| pck.out()); verif(im1.all_pts()); ELISE_COPY(disc(CentreRand(),RayonRand()),frandr()*8,im1.out()| pck.out()); verif(im1.all_pts()); INT NbPts = (INT)(3 + NRrandom3()*10); ElList<Pt2di> Lpt; { for (INT k=0; k<NbPts ; k++) Lpt = Lpt+Pt2di(CentreRand()); } ELISE_COPY(polygone(Lpt),NRrandom3()<0.1,im1.out()| pck.out()); verif(im1.all_pts()); ModifCSte(rectangle(Pt2di(5,0),Pt2di(10,10)),2); verif(im1.all_pts()); ModifLut(rectangle(Pt2di(0,5),Pt2di(12,12)),FX&3); verif(im1.all_pts()); //ModifCSte(disc(Pt2di(50,50),20),3); ModifCSte(disc(Pt2dr(50,50),20),3); // __NEW verif(im1.all_pts()); for (INT NbC =0 ; NbC < 20 ; NbC++) { ElList<Pt2di> lPt; for (INT iPt =0 ; iPt < 20; iPt ++) { lPt = lPt + Pt2di(CentreRand()); } ModifCSte(polygone(lPt),INT(NRrandom3() * 3)); verif(im1.all_pts()); } Pt2di P_00 (0,0); Pt2di P_10 (sz.x,0); Pt2di P_01 (0,sz.y); ElList<Pt2di> lP1; lP1 = lP1 + P_00; lP1 = lP1 + P_01; lP1 = lP1 + P_10; ModifCSte(polygone(lP1),7); verif(im1.all_pts()); TiffVerif(); }
/*! * does the anisotropic filtering */ int NLD:: execute() { cout << "Filter options:" << endl; cout << "tau = " << tau << endl; cout << "time_steps = " << time_steps << endl; cout << "precision = " << epsilon << endl; cout << "multigrid levels = " << levels << endl; cout << "fixed_coeffs = " << fixed_coeffs << endl; cout << "anicoeff1 = " << anicoeff1 << endl; cout << "anicoeff2 = " << anicoeff2 << endl; cout << "anicoeff3 = " << anicoeff3 << endl; cout << "dependence_type = " << dependence_type << endl; cout << "lambda = " << lambda << endl; cout << "integration_size_x = " << integration_size_x << endl; cout << "integration_size_y = " << integration_size_y << endl; cout << "integration_size_z = " << integration_size_z << endl; cout << "geometry_type = " << gt << endl; cout << "ip_flag = " << ip_flag << endl; // initialise matrix Array<int> sizes(3); sizes.SetElement(1,dc->GetSize()[1]); sizes.SetElement(2,dc->GetSize()[2]); sizes.SetElement(3,dc->GetSize()[3]); int code; // errorcode; time_t time1, time2, timediff; for ( int i = 1; i <= time_steps; i++ ){ cout << "Time step " << i << " :" << endl; SparseMatrix<NeuraDataType> matA(sizes); //delete marker1; // initialise discretation FV_3d27 disc(&matA,ip_flag); disc.SetLambda(lambda); disc.SetAniCoefficients(anicoeff1, anicoeff2, anicoeff3); disc.SetFixedCoefficients(fixed_coeffs); disc.SetDependenceType(dependence_type); disc.SetIntegrationSizeX(integration_size_x); disc.SetIntegrationSizeY(integration_size_y); disc.SetIntegrationSizeZ(integration_size_z); disc.SetGeometryType(gt); // initialise right hand side MultiVector<NeuraDataType> rhs; dc->CopyIntoMultiVector(rhs); //delete marker2; // initialise solution MultiVector<NeuraDataType> sol(rhs); sol.SetZero(); // initialise multigrid Multigrid<NeuraDataType> multigrid; // important: precision has to be set before initializing multigrid! multigrid.SetPrecision(epsilon); // set multigrid properties // make sure that precision was setted before! multigrid.Initialise(REGULAR, MATRIX_DEPENDENT_INTERPOLATION, MATRIX_DEPENDENT_RESTRICTION, alpha, LEXICOGRAPHIC_GAUSS_SEIDEL, 2, 2, V, BICGSTAB, NODES, levels); multigrid.SaveProlongation(); multigrid.SaveRestriction(); multigrid.SetMaximumSteps(50); dc->CopyIntoMultiVector(rhs); dc->CopyIntoMultiVector(sol); cout << "discretize..." << endl; time1 = time(NULL); code = disc.discretize(*dc); if ( code ) return code; cout << "NLD: Ich komme hier an!" << endl; disc.SetTimeDependent(tau); time2 = time(NULL); cout << "...discretation finished" << endl; timediff = time2-time1; cout << "discretation took " << timediff << " seconds" << endl; cout << "BuildMatrixHierarchy..." << endl; if ( levels > 1 ) { if ( ( !pow_of_two(dc->GetSize()[1]-1) ) || ( !pow_of_two(dc->GetSize()[2]-1) ) || ( !pow_of_two(dc->GetSize()[3]-1) ) ) { return SIZE_NOT_POW_OF_TWO_PLUS_ONE; } } time1 = time(NULL); multigrid.BuildMatrixHierarchy(matA); time2 = time(NULL); cout << "...done" << endl; timediff = time2-time1; cout << "building matrix hierarchy took " << timediff << " seconds" << endl; cout << "solve by multigrid method..." << endl; time1 = time(NULL); multigrid.Solve(rhs,sol); time2 = time(NULL); cout << "......done" << endl; timediff = time2-time1; cout << "soluting took " << timediff << " seconds" << endl; dc->CopyFromMultiVector(sol); } cout <<"quit nld now" << endl; return OK; }