void PDESolver<T,lFunc,rFunc,bFunc,tFunc,force>::resize(const ulong size) { if(size != m_size) { m_size = size; generateB(); generateA(); } }
void World::generate(WorldType type) { switch (type) { case WorldType::SYMETRY: { generateA(); } case WorldType::TERRA: { generateB(); } } }
PDESolver<T,lFunc,rFunc,bFunc,tFunc,force>::PDESolver(const ulong size, const T lBound, const T rBound, const T bBound, const T tBound) { m_size = size; if(lBound >= rBound) throw InvalidBound("Left bound needs to be less than right bound"); if(bBound >= tBound) throw InvalidBound("Lower bound needs to be less than upper bound"); m_leftBound = lBound; m_rightBound = rBound; m_upperBound = tBound; m_lowerBound = bBound; generateB(); generateA(); }
Mahalanobis TogersonMetricLearner::learnMetric() { dim = getVectorDim(); sampleCount = getSampleCount(); int iIdx = selectI(); mat B = generateB(iIdx); mat X = generateX(); mat Y = generateY(B); mat Z = generateZ(X, Y); mat A = Z.t() * Z; // normalize it for convenience A = 1 / A(0, 0) * A; return Mahalanobis(A); }
sf::Sprite Ship::act(EventHandler e, Util* u) { int * tar = e.getTarget(alignment); double dx = tar[0]; double dy = tar[1]; dx = dx-(x+radius); dy = dy-(y+radius); double magnitude = 2/std::sqrt(std::abs(dx)*std::abs(dx)+std::abs(dy)*std::abs(dy)); bool hitBarrier = false; if(std::abs(dx) > 1 || std::abs(dy) > 1) { x += dx*magnitude; y += dy*magnitude; for (int i = 0; i < barrierVector.size() && !hitBarrier; i++) // check barrier collisions { if (didICollide(&barrierVector.at(i))) { hitBarrier = true; } } } if(x+radius<0 || x+radius > mx || hitBarrier) x -= dx*magnitude; if(y+radius<0 || y+radius > my || hitBarrier) y -= dy*magnitude; shipSprite.setPosition(x, y); end = e.myClock.getElapsedTime(); special(e, u); if(end - start >= sf::milliseconds(curAtkDelay)) // start bullet creation stuff { int dir = -(alignment*2-1); start = end; if(specialA > 0) { specialA--; u->addBullet(generateA(specialA, dir)); }else if(specialB>0) { specialB--; u->addBullet(generateB(specialB, dir, e)); }else if(e.shootNow(alignment)) { //double dx = e.mouseX-(x+radius); //double dy = e.mouseY-(y+radius); curAtkDelay = attackDelay; double dx = 0; double dy = dir; double magnitude = 4/dy; // equivalent to 4/std::sqrt(std::abs(dx)*std::abs(dx)+std::abs(dy)*std::abs(dy)); sf::Color newColor(curColor.r, curColor.g, curColor.b, sf::Int8(180)); Bullet * mine = new Bullet(x+radius/2, y+radius/2, dx*magnitude, dy*magnitude, mx, my, alignment, newColor); u->addBullet(mine); } } //std::cout << "pointer of first:" << u.first << "\n"; return shipSprite; }