void CDX9Renderer::FillGradient(const rect& r, cr_float angle, point hotspot, const color& c1, const color& c2, gradient_direction dir) { quad q((r - hotspot).rotate_to_quad(angle, r.topleft())); SetTexture(NULL); color vs[4]; switch (dir) { case dir_up: SetVertices(vs, c2, c2, c1, c1); Quad(r, vs); break; case dir_down: SetVertices(vs, c1, c1, c2, c2); Quad(r, vs); break; case dir_left: SetVertices(vs, c2, c1, c2, c1); Quad(r, vs); break; case dir_right: SetVertices(vs, c1, c2, c1, c2); Quad(r, vs); break; } }
void CDX9Renderer::FillGradient(const rect& r, const color& c1, const color& c2, gradient_direction dir) { SetTexture(NULL); color vs[4]; switch (dir) { case dir_up: SetVertices(vs, c2, c2, c1, c1); Quad(r, vs); break; case dir_down: SetVertices(vs, c1, c1, c2, c2); Quad(r, vs); break; case dir_left: SetVertices(vs, c2, c1, c2, c1); Quad(r, vs); break; case dir_right: SetVertices(vs, c1, c2, c1, c2); Quad(r, vs); break; } }
MapGridNode::MapGridNode(const vn::vector2i &index) { vn::color_t color(0xFF, 0xFF, 0xFF, 0x20); Quad *p = vnnew Quad(); *p << vn::aabox2f(0, 0, 38, 2) << color << vn::Render2DInterface::kAlphaAdditive; addRenderable(p, false); p = vnnew Quad(); *p << vn::aabox2f(0, 2, 2, 40) << color << vn::Render2DInterface::kAlphaAdditive; addRenderable(p, false); p = vnnew Quad(); *p << vn::aabox2f(38, 0, 40, 38) << color << vn::Render2DInterface::kAlphaAdditive; addRenderable(p, false); p = vnnew Quad(); *p << vn::aabox2f(2, 38, 40, 40) << color << vn::Render2DInterface::kAlphaAdditive; addRenderable(p, false); Text *t = vnnew Text(); vn::c8 buf[32]; sprintf(buf, "%u,%u", index.x + 1, index.y + 1); *t << vn::color_t(0xFF, 0xFF, 0xFF, 0x80) << vn::Render2DInterface::kAlphaAdditive << vn::RenderText::kCenter; *t << vn::FontManager::instance().defaultFont() << buf; SceneNode *node = vnnew SceneNode(); node->setPosition(vn::vector2f(20, 20)); node->setScale(vn::vector2f(0.6f, 0.6f)); node->addRenderable(t, false); addChild(node, false); setPosition(index * 40); setLocalBoundingBox(vn::aabox2f(0, 0, 40, 40)); }
smReal Distance(QPointF p1, QPointF p2) { return sqrt( Quad( p1.x() - p2.x() ) + Quad( p1.y() - p2.y() ) ); }
void CDX9Renderer::Quad(const rect& r, cr_float angle, point hotspot, const color& filter, const rect* _uv) { // Avoid math for unrotated rects if (angle == 0.0) Quad(r - hotspot, filter, _uv); else Quad((r - hotspot).rotate_to_quad(angle, r.topleft()), filter, _uv); }
void begin() { rot = 0.0; square = Quad(1,1,ColorRGBA(0,0,0,1)); square2 = Quad(1,1,ColorRGBA(0,0,0,1)); square3 = Quad(1,1,ColorRGBA(0,0,0,1)); square.setColor(ColorRGBA(0,1,0,1)); square2.setColor(ColorRGBA(0,0,1,1)); square3.setColor(ColorRGBA(1,0,0,1)); } // Execute when game state starts.
local void walktree(nodeptr *aptr, nodeptr *nptr, cellptr cptr, cellptr bptr, nodeptr p, real psize, vector pmid) { nodeptr *np, *ap, q; int actsafe; matrix trQM; if (Update(p)) { // new forces needed in node? np = nptr; // start new active list actsafe = actmax - NSUB; // leave room for NSUB more for (ap = aptr; ap < nptr; ap++) { // loop over active nodes if (Type(*ap) == CELL) { // is this node a cell? if (accept(*ap, psize, pmid)) { // does it pass the test? if (Mass(*ap) > 0.0) { // and contribute to field? Mass(cptr) = Mass(*ap); // copy to interaction list SETV(Pos(cptr), Pos(*ap)); #if defined(SOFTCORR) TRACEM(Trace(cptr), Quad(*ap)); // save trace in copy SETMI(trQM); MULMS(trQM, trQM, Trace(cptr)/3); SUBM(Quad(cptr), Quad(*ap), trQM); // store traceless moment #else SETM(Quad(cptr), Quad(*ap)); // copy traceless moment #endif cptr++; // and bump cell array ptr } } else { // this cell fails the test if (np - active >= actsafe) // make sure list has room fatal("%s.walktree: active list overflow\n", getprog()); for (q = More(*ap); q != Next(*ap); q = Next(q)) // loop over all subcells *np++= q; // put them on active list } } else // else this node is a body if (*ap != p && Mass(*ap) > 0.0) { // not self-interaction? --bptr; // bump body array ptr Mass(bptr) = Mass(*ap); // and copy data to array SETV(Pos(bptr), Pos(*ap)); } } acttot = MAX(acttot, np - active); // keep track of max active if (np != nptr) { // if new actives were added walksub(nptr, np, cptr, bptr, p, psize, pmid); // then visit next level } else { // else no actives left if (Type(p) != BODY) // make sure we got a body fatal("%s.walktree: recursion terminated with cell\n" " p = 0x%x psize = %.8f Mass(p) = %g\n" " pmid = (%.8f,%.8f,%.8f)\n Pos(p) = (%.8f,%.8f,%.8f)\n", getprog(), (int) p, psize, Mass(p), pmid[0], pmid[1], pmid[2], Pos(p)[0], Pos(p)[1], Pos(p)[2]); gravsum((bodyptr) p, cptr, bptr); // sum force on this body } } }
void cubicToQuads (const Cubic &cu, std::vector< Quad > &out) { /* //Generic recursive subdivision Cubic c1,c2; subdivCubic( cu, c1,c2 ); Cubic cubics[4]; subdivCubic( c1, cubics[0], cubics[1] ); subdivCubic( c2, cubics[2], cubics[3] ); for (int j=0; j<4; ++j) { Cubic cj = cubics[j]; Quad quad; quad.p0 = cj.p0; quad.p2 = cj.p3; if (! intersectLines( cj.p0, cj.p1, cj.p2, cj.p3, quad.p1 )) quad.p1 = (cj.p1 + cj.p2) * 0.5f; out.push_back( quad ); } */ //Fixed subdivision into 4 quads Vec2 p01 = (cu.p0 + cu.p1) * 0.5f; Vec2 p12 = (cu.p1 + cu.p2) * 0.5f; Vec2 p23 = (cu.p2 + cu.p3) * 0.5f; Vec2 p001 = (cu.p0 + p01) * 0.5f; Vec2 a = (p001 + p01) * 0.5f; Vec2 p233 = (p23 + cu.p3) * 0.5f; Vec2 d = (p23 + p233) * 0.5f; Vec2 p0112 = (p01 + p12) * 0.5f; Vec2 p1223 = (p12 + p23) * 0.5f; Vec2 B = (p0112 + p1223) * 0.5f; Vec2 p0112B = (p0112 + B) * 0.5f; Vec2 b = (p0112 + p0112B) * 0.5f; Vec2 pB1223 = (B + p1223) * 0.5f; Vec2 c = (pB1223 + p1223) * 0.5f; Vec2 A = (a + b) * 0.5f; Vec2 C = (c + d) * 0.5f; out.push_back( Quad( cu.p0, a, A ) ); out.push_back( Quad( A, b, B ) ); out.push_back( Quad( B, c, C ) ); out.push_back( Quad( C, d, cu.p3 ) ); }
GridTopology::Quad GridTopology::getQuad(int x, int y, int z) { if (n.getValue()[2] == 1) return Quad(point(x, y, 1), point(x+1, y, 1), point(x+1, y+1, 1), point(x, y+1, 1)); else if (n.getValue()[1] == 1) return Quad(point(x, 1, z), point(x+1, 1, z), point(x+1, 1, z+1), point(x, 1, z+1)); else return Quad(point(1, y, z),point(1, y+1, z), point(1, y+1, z+1),point(1, y, z+1)); }
local void gravsub(nodeptr q) { real drab, phii, mor3; vector ai, quaddr; real dr5inv, phiquad, drquaddr; if (q != (long) qmem) { /* cant use memorized data? */ SUBV(dr, Pos(q), pos0); /* then compute sep. */ DOTVP(drsq, dr, dr); /* and sep. squared */ } drsq += eps*eps; /* use standard softening */ drab = rsqrt(drsq); phii = Mass(q) / drab; mor3 = phii / drsq; MULVS(ai, dr, mor3); phi0 -= phii; /* add to total grav. pot. */ ADDV(acc0, acc0, ai); /* ... and to total accel. */ if (usequad && Type(q) == CELL) { /* if cell, add quad term */ cellptr SAFE c= TC(q); dr5inv = 1.0/(drsq * drsq * drab); /* form dr^-5 */ MULMV(quaddr, Quad(c), dr); /* form Q * dr */ DOTVP(drquaddr, dr, quaddr); /* form dr * Q * dr */ phiquad = -0.5 * dr5inv * drquaddr; /* get quad. part of phi */ phi0 = phi0 + phiquad; /* increment potential */ phiquad = 5.0 * phiquad / drsq; /* save for acceleration */ MULVS(ai, dr, phiquad); /* components of acc. */ SUBV(acc0, acc0, ai); /* increment */ MULVS(quaddr, quaddr, dr5inv); SUBV(acc0, acc0, quaddr); /* acceleration */ } }
local void sumcell(cellptr start, cellptr finish, vector pos0, real *phi0, vector acc0) { real eps2, eps2thrd, dr2, dr2i, dr1i, mdr1i, mdr3i, qdr2, dr5i, phi_q; vector dr, qdr; eps2 = eps * eps; // premultiply softening eps2thrd = eps2 / 3.0; // predivide for soft corr for (cellptr p = start; p < finish; p++) { // loop over node list DOTPSUBV(dr2, dr, Pos(p), pos0); // do mono part of force dr2i = ((real) 1.0) / (dr2 + eps2); // perform only division dr1i = rsqrt(dr2i); // set inverse soft distance mdr1i = Mass(p) * dr1i; // form mono potential mdr3i = mdr1i * dr2i; // get scale factor for dr DOTPMULMV(qdr2, qdr, Quad(p), dr); // do quad part of force #if defined(SOFTCORR) qdr2 -= eps2thrd * Trace(p); // apply Keigo's correction #endif dr5i = ((real) 3.0) * dr2i * dr2i * dr1i; // factor 3 saves a multiply phi_q = ((real) 0.5) * dr5i * qdr2; // form quad potential mdr3i += ((real) 5.0) * phi_q * dr2i; // adjust radial term *phi0 -= mdr1i + phi_q; // sum mono and quad pot ADDMULVS2(acc0, dr, mdr3i, qdr, - dr5i); // sum mono and quad acc } }
void CDX9Renderer::Fill(const rect& r, cr_float angle, point hotspot, const color& c) { quad q((r - hotspot).rotate_to_quad(angle, r.topleft())); SetTexture(NULL); Quad(q, c, NULL); }
Snake::Snake(const glm::vec3& position) : _allowMove(true), _isAlive(true) { int direction = rand() % 4; _snakeBody.push_back(Quad(Settings::ModelSnake)); _snakeBody[0].setPosition(position); switch (direction) { case 0: _snakeBody[0].setMoveDirection(Settings::UP); _snakeBody[0].rotateLeft(); break; case 1: _snakeBody[0].setMoveDirection(Settings::RIGHT); break; case 2: _snakeBody[0].setMoveDirection(Settings::DOWN); _snakeBody[0].rotateRight(); break; case 3: _snakeBody[0].setMoveDirection(Settings::LEFT); _snakeBody[0].rotateLeft(); _snakeBody[0].rotateLeft(); break; } _snakeBody[0].setColor(Settings::SnakeColor); }
void Jogo::executar() { while(!gTeclado.soltou[TECLA_ESC] && !gEventos.sair) { uniIniciarFrame(); // Se pressionou R, restaura o painel de debug if (gTeclado.pressionou[TECLA_R]) gDebug.restaurar(); // Depurar variaveis gDebug.depurar("FPS", (int)gTempo.getFPS()); gDebug.depurar("deltaTempo", gTempo.getDeltaTempo()); gDebug.depurar("mouse", Vetor2D(gMouse.x, gMouse.y)); gDebug.depurar("retanguloTela", Quad(0, 0, gJanela.getLargura(), gJanela.getAltura())); // Cria um erro gDebug.erro("Erro Teste", this); // Opcionalmente, passa-se uma cor para a depuração gDebug.depurar("Verde", "Este é um texto Verde", Cor(0, 255, 0)); // Desenhar fundo, para poder ver melhor a transparência do painel sprFundo.desenhar(gJanela.getLargura() / 2, gJanela.getAltura() / 2); desenharInstrucoes(); uniTerminarFrame(); } }
void Snake::eat() { _snakeBody.push_back(Quad(Settings::ModelSnake)); _snakeBody.back().setPosition(_tailPosition); _snakeBody.back().setMoveDirection(_tailMoveDirection); _snakeBody.back().setRotation(_tailRotation); _snakeBody.back().setColor(Settings::SnakeColor); }
//------------------------------------------------------------------ void Proof::set_trace_pair(const Vertex & v1, const Vertex & v2, const Tag & t1, const Tag & t2) { assert( vertices.find(v1) != vertices.end() ); assert( vertices.find(v2) != vertices.end() ); assert( tag_map[v1].find(t1) != tag_map[v1].end() ); assert( tag_map[v2].find(t2) != tag_map[v2].end() ); trace_pairs.insert( Quad(v1, v2, t1, t2) ); }
smReal normalCurve(smReal x, smReal mu, smReal sigma) { smReal factor1,factor2; if (mu == 0.0 && sigma == 1.0) { factor1 = 0.3989422804014327; factor2 = 2; } else { factor1 = 1.0/(sigma*sqrt(2*PI)); factor2 = 2*Quad(sigma); } smReal exponential = -(Quad(x-mu)/factor2); return factor1 * exp(exponential); }
void EtageQuad::split() { if (nbEtages > 1 && etage == 0 && ((w[N] && w[S]) || (w[E] && w[W])) && c.minLengthEW() > 800 && proba(seed, 0, 0.8)) { Quad q = c << ((w[N] && w[S]) ? 0 : 1); Quad qh = ch << ((w[N] && w[S]) ? 0 : 1); Vertex n = (q[NW] + q[NE]) / 2.f; Vertex s = (q[SE] + q[SW]) / 2.f; Vertex nh = (qh[NW] + qh[NE]) / 2.f; Vertex sh = (qh[SE] + qh[SW]) / 2.f; Quad e = Quad(q[NE], q[SE], s, n).inset(W, 200); Quad w = Quad(n, s, q[SW], q[NW]).inset(E, 200); Quad eh = Quad(qh[NE], qh[SE], sh, nh).inset(W, 200); Quad wh = Quad(nh, sh, qh[SW], qh[NW]).inset(E, 200); Quad ei = e.insetNESW(28, 28, 28, 0); Quad wi = w.insetNESW(28, 0, 28, 28); Quad eih = eh.insetNESW(28, 28, 28, 0); Quad wih = wh.insetNESW(28, 0, 28, 28); // TODO : ArcheQuad(Quad, Quad); addChild(new ArcheQuad(Quad(e[NW], e[SW], w[SE], w[NE]), Segment(qh[NE], q[NE]).length())); // Mur sur e[N], e[E], e[S], w[S], w[W], w[N]; for (int i = 0; i < 3; i++) { addChild(new MurQuad(Quad(e[NE+i], ei[NE+i], ei[NW+i], e[NW+i]), Quad(eh[NE+i], eih[NE+i], eih[NW+i], eh[NW+i]))); addChild(new MurQuad(Quad(w[SE+i], w[SW+i], wi[SW+i], wi[SE+i]), Quad(wh[SE+i], wh[SW+i], wih[SW+i], wih[SE+i]))); } } else { Quad me = c.insetOpp(E,28); Quad ms = c.inset(E,28).inset(W,28).insetOpp(S,28); Quad mw = c.insetOpp(W,28); Quad mn = c.inset(E,28).inset(W,28).insetOpp(N,28); Quad meh = ch.insetOpp(E,28); Quad msh = ch.inset(E,28).inset(W,28).insetOpp(S,28); Quad mwh = ch.insetOpp(W,28); Quad mnh = ch.inset(E,28).inset(W,28).insetOpp(N,28); QuadBool d = QuadBool(false,false,false,false); if(etage == 0) { if(w[E]) d[E] = true; else if(w[W]) d[W] = true; else if(w[N]) d[N] = true; else if(w[S]) d[S] = true; } addChild(new MurQuad(me << 1,meh << 1,w[E]^d[E],false,false,d[E])); addChild(new MurQuad(mw >> 1,mwh >> 1,w[W]^d[W],false,false,d[W])); addChild(new MurQuad(mn,mnh,w[N]^d[N],false,false,d[N])); addChild(new MurQuad(ms >> 2,msh >> 2,w[S]^d[S],false,false,d[S])); } addChild(new PlancherPlafond(c, PlancherPlafond::PLANCHER)); addChild(new PlancherPlafond(ch.offsetNormal(-10), PlancherPlafond::PLAFOND)); }
// This function draws a texture at a single given point - a texture has to be set otherwise it can't get the width and height to draw void CDX9Renderer::Quad(const point& p, cr_float angle, point hotspot, const color& filter, const rect* _uv) { // Check a texture is set if (current_texture == NULL) throw error(_T("Can't draw a quad using this overload with no texture set"), E_FAIL); const rect r(p.x, p.y, p.x + current_texture->image_widthf, p.y + current_texture->image_heightf); Quad(r, angle, origin, filter, _uv); }
void GUIallyResourceBar::PrivateDraw() { int numAllies=0; for(int a=0;a<gs->activeTeams;++a){ if(gs->allies[gs->team2allyteam[a]][gu->myAllyTeam] && a!=gu->myTeam) numAllies++; } h=numAllies*32; w=200; glPushAttrib(GL_CURRENT_BIT); glColor4f(0.0, 0.0, 0.0, 0.5); glBindTexture(GL_TEXTURE_2D, 0); Quad(0, 0, w, h); int yoff=0; for(int a=0;a<gs->activeTeams;++a){ if(gs->allies[gs->team2allyteam[a]][gu->myAllyTeam] && a!=gu->myTeam){ glColor3f(1, 1, 1); guifont->Print(2, yoff+10, gs->players[gs->teams[a]->leader]->playerName.c_str()); guifont->Print(65, yoff+2, "%.0f",gs->teams[a]->metal); guifont->Print(65, yoff+18, "%.0f",gs->teams[a]->energy); glBindTexture(GL_TEXTURE_2D, 0); glColor4f(0.1f, 0.1f, 0.3f, 0.8f); Quad(120,yoff+5,75,6); glColor4f(0.8f, 0.8f, 1.0f, 0.8f); Quad(120,yoff+5,75*gs->teams[a]->metal/gs->teams[a]->metalStorage,6); glColor4f(0.2f, 0.2f, 0.1f, 0.8f); Quad(120,yoff+21,75,6); glColor4f(1.0f, 1.0f, 0.5f, 0.8f); Quad(120,yoff+21,75*gs->teams[a]->energy/gs->teams[a]->energyStorage,6); yoff+=32; } } glPopAttrib(); }
void ObjectFlatten::quadTo (const Vec2 &p1, const Vec2 &p2, int space) { if (!penDown) return; Vec2 t0 = transform( getPen() ); Vec2 t1 = transform( p1 ); Vec2 t2 = transform( p2 ); getObject()->quads.push_back( Quad( t0.x,t0.y, t1.x,t1.y, t2.x,t2.y )); getObject()->contourPoints.push_back( t2 ); getObject()->contours.back().length++; }
void EtageTri::split() { Triangle small = c.insetLTR(28); Triangle smallh = ch.insetLTR(28); TriBool d(false,false,false); if(etage == 0) { if(w[LEFTSIDE]) d[LEFTSIDE] = true; else if(w[RIGHTSIDE]) d[RIGHTSIDE] = true; else if(w[BASE]) d[BASE] = true; } for (int i = 0; i < 3; i++) { Quad q = Quad(c[TOP+i], small[TOP+i], small[LEFT+i], c[LEFT+i]); Quad qh = Quad(ch[TOP+i], smallh[TOP+i], smallh[LEFT+i], ch[LEFT+i]); addChild(new MurQuad(q, qh, w[LEFTSIDE+i]^d[LEFTSIDE+i],false,false,d[LEFTSIDE+i])); } addChild(new PlancherPlafondTri(c, PlancherPlafondTri::PLANCHER)); addChild(new PlancherPlafondTri(ch.offsetNormal(-10), PlancherPlafondTri::PLAFOND)); }
local void walkgrav(nodeptr *aptr, nodeptr *nptr, cellptr cptr, cellptr bptr, nodeptr p, real psize, vector pmid) { nodeptr *np, *ap, q; int actsafe; if (Update(p)) { /* are new forces needed? */ np = nptr; /* start new active list */ actsafe = actlen - NSUB; /* leave room for NSUB more */ for (ap = aptr; ap < nptr; ap++) /* loop over active nodes */ if (Cell(*ap)) { /* is this node a cell? */ if (accept(*ap, psize, pmid)) { /* does it pass the test? */ Mass(cptr) = Mass(*ap); /* copy to interaction list */ SETV(Pos(cptr), Pos(*ap)); SETM(Quad(cptr), Quad(*ap)); cptr++; /* and bump cell array ptr */ } else { /* else it fails the test */ if (np - active >= actsafe) /* check list has room */ error("walkgrav: active list overflow\n"); for (q = More(*ap); q != Next(*ap); q = Next(q)) /* loop over all subcells */ *np++= q; /* put on new active list */ } } else /* else this node is a body */ if (*ap != p) { /* if not self-interaction */ --bptr; /* bump body array ptr */ Mass(bptr) = Mass(*ap); /* and copy data to array */ SETV(Pos(bptr), Pos(*ap)); } actmax = MAX(actmax, np - active); /* keep track of max active */ if (np != nptr) /* if new actives listed */ walksub(nptr, np, cptr, bptr, p, psize, pmid); /* then visit next level */ else { /* else no actives left, so */ if (! Body(p)) /* must have found a body */ error("walkgrav: recursion terminated with cell\n"); gravsum((bodyptr) p, cptr, bptr); /* sum force on the body */ } } }
QList<Quad> MeshTextureGraphicsItem::_split(const Quad& quad) { QList<Quad> quads; QPointF a = quad.getVertex(0); QPointF b = quad.getVertex(1); QPointF c = quad.getVertex(2); QPointF d = quad.getVertex(3); QPointF ab = (a + b) * 0.5f; QPointF bc = (b + c) * 0.5f; QPointF cd = (c + d) * 0.5f; QPointF ad = (a + d) * 0.5f; QPointF abcd = (ab + cd) * 0.5f; quads.append(Quad(a, ab, abcd, ad)); quads.append(Quad(ab, b, bc, abcd)); quads.append(Quad(abcd, bc, c, cd)); quads.append(Quad(ad, abcd, cd, d)); return quads; }
char* showCell(const NBodyCell* c) { char* buf; char* posBuf; if (!c) return NULL; posBuf = showVector(Pos(c)); if (0 > asprintf(&buf, "NBodyCell = {\n" " cellnode = {\n" " pos = %s\n" " next = %p\n" " mass = %f\n" " type = %d\n" " }\n" " rcrit2 = %f\n" " more = %p\n" " stuff = {\n" " .quad = {\n" " .xx = %f, .xy = %f, .xz = %f,\n" " .yy = %f, .yz = %f,\n" " .zz = %f\n" " },\n" "\n" " .subp = {\n" " %p, %p, %p, %p,\n" " %p, %p, %p, %p\n" " }\n" " }\n" "}\n", posBuf, (void*) Next(c), Mass(c), Type(c), Rcrit2(c), (void*) More(c), Quad(c).xx, Quad(c).xy, Quad(c).xz, Quad(c).yy, Quad(c).yz, Quad(c).zz, (void*) Subp(c)[0], (void*) Subp(c)[1], (void*) Subp(c)[2], (void*) Subp(c)[3], (void*) Subp(c)[5], (void*) Subp(c)[5], (void*) Subp(c)[6], (void*) Subp(c)[7] )) { mw_fail("asprintf() failed\n"); } free(posBuf); return buf; }
int main(){ Point target = Point(1,1,0); Quad q = Quad(Point(2,4,1),Point(0,0,2),Point(5,0,3),Point(4,3,4)); //compute local coordinates. std::cout << "Computing Local Coordinates...\n"; LocaleCoordinats lc = newtonIteration(target, q); //interpolate value with computed local coordinates std::cout << "Interpolating Value...\n"; target.value = interpolateValue(lc, q); std::cout << "Target:\n x: " << target.x << "\n y: " << target.y << "\n value: " << target.value <<"\n\n"; system("Pause"); return 0; }
bool SpriteSheet::carregar(string arquivo, int num_animacoes, int num_max_frames, EnumQualidadeEscala qualidade_escala) { if(!uniEstaInicializada()) { gDebug.erro("Sem uniInicializar() antes de tentar carregar: '" + arquivo + "'."); return false; } if(estaCarregado()) { gDebug.erro("Arquivo '" + arquivo + "' nao pode ser carregado, pois SpriteSheet ja carregou o arquivo " + tex.getCaminhoDoArquivo() + "."); return false; } if(!tex.criarDoArquivo(arquivo, qualidade_escala)) { gDebug.erro("Erro ao carregar arquivo: '" + arquivo + "' - " + SDL_GetError() + "."); return false; } if(num_animacoes < 1) num_animacoes = 1; if(num_max_frames < 1) num_max_frames = 1; int largura_frame = tex.getLargura()/num_max_frames; int altura_frame = tex.getAltura()/num_animacoes; frames.resize(num_animacoes); for(int i = 0; i < frames.size(); ++i) { frames[i].resize(num_max_frames); for(int j = 0; j < num_max_frames; ++j) { frames[i][j] = Quad(j*largura_frame, i*altura_frame, largura_frame, altura_frame); } } return true; }
Quad Quad::getBoundingBox(const std::vector<arma::vec2>& points) { // Check for if (points.size() <= 0) { throw std::domain_error("Request made for bounding box for empty list of points!"); } double min_x = points[0][0]; double max_x = points[0][0]; double min_y = points[0][1]; double max_y = points[0][1]; for (uint i = 1; i < points.size(); i++) { auto& p = points[i]; max_x = std::max(max_x, p[0]); min_x = std::min(min_x, p[0]); max_y = std::max(max_y, p[1]); min_y = std::min(min_y, p[1]); } return Quad(arma::vec2({min_x, min_y}), arma::vec2({min_x, max_y}), arma::vec2({max_x, max_y}), arma::vec2({max_x, min_y})); }
local void sumcell(cellptr start, cellptr finish, vector pos0, real *phi0, vector acc0) { cellptr p; real eps2, dr2, drab, phi_p, mr3i, drqdr, dr5i, phi_q; vector dr, qdr; eps2 = eps * eps; for (p = start; p < finish; p++) { /* loop over node list */ DOTPSUBV(dr2, dr, Pos(p), pos0); /* do mono part of force */ dr2 += eps2; drab = rsqrt(dr2); phi_p = Mass(p) / drab; mr3i = phi_p / dr2; DOTPMULMV(drqdr, qdr, Quad(p), dr); /* do quad part of force */ dr5i = ((real) 1.0) / (dr2 * dr2 * drab); phi_q = ((real) 0.5) * dr5i * drqdr; *phi0 -= phi_p + phi_q; /* add mono and quad pot */ mr3i += ((real) 5.0) * phi_q / dr2; ADDMULVS2(acc0, dr, mr3i, qdr, -dr5i); /* add mono and quad acc */ } }
void gravsub(register nodeptr p, long ProcessId) { real drabs, phii, mor3; vector ai; if (p != Local[ProcessId].pmem) { SUBV(Local[ProcessId].dr, Pos(p), Local[ProcessId].pos0); DOTVP(Local[ProcessId].drsq, Local[ProcessId].dr, Local[ProcessId].dr); } Local[ProcessId].drsq += epssq; drabs = sqrt((double) Local[ProcessId].drsq); phii = Mass(p) / drabs; Local[ProcessId].phi0 -= phii; mor3 = phii / Local[ProcessId].drsq; MULVS(ai, Local[ProcessId].dr, mor3); ADDV(Local[ProcessId].acc0, Local[ProcessId].acc0, ai); if(Type(p) != BODY) { /* a body-cell/leaf interaction? */ Local[ProcessId].mynbcterm++; #ifdef QUADPOLE dr5inv = 1.0/(Local[ProcessId].drsq * Local[ProcessId].drsq * drabs); MULMV(quaddr, Quad(p), Local[ProcessId].dr); DOTVP(drquaddr, Local[ProcessId].dr, quaddr); phiquad = -0.5 * dr5inv * drquaddr; Local[ProcessId].phi0 += phiquad; phiquad = 5.0 * phiquad / Local[ProcessId].drsq; MULVS(ai, Local[ProcessId].dr, phiquad); SUBV(Local[ProcessId].acc0, Local[ProcessId].acc0, ai); MULVS(quaddr, quaddr, dr5inv); SUBV(Local[ProcessId].acc0, Local[ProcessId].acc0, quaddr); #endif } else { /* a body-body interaction */ Local[ProcessId].myn2bterm++; } }