void Tokenizer::tokenize( vstring &v ) { if(buffer.length() == 0) { return; } resetPosition(); for( ; firstToken() != ""; v.push_back(thisToken)) ; resetPosition(); }
int Tokenizer::countTokens(void) { resetPosition(); int tokenNumber = 0; for(; firstToken() != ""; tokenNumber++ ) ; resetPosition(); return tokenNumber; }
void SpriteRow::rearrange(int index) { resetPosition((CCNode*) villagerImage, ccp(10.0f, (5.0f + villagerImage->boundingBox().size.height) * index)); resetPosition((CCNode*) villagerEnergyBar, ccp(150.0f, (5.0f + villagerImage->boundingBox().size.height) * index + villagerImage->boundingBox().size.height / 2.0f - villagerEnergyBar->boundingBox().size.height / 2.0f + 5.0f)); // resetPosition((CCNode*) villagerEnergyLabel, ccp(235.0f, (5.0f + villagerImage->boundingBox().size.height) * index + villagerImage->boundingBox().size.height / 2.0f - villagerEnergyLabel->boundingBox().size.height / 2.0f + 5.0f)); resetPosition((CCNode*) menu, ccp(580.0f, (5.0f + villagerImage->boundingBox().size.height) * index)); }
void Ekf::controlGpsAiding() { // GPS fusion mode selection logic // To start use GPS we need angular alignment completed, the local NED origin set and fresh GPS data if ((_params.fusion_mode & MASK_USE_GPS) && !_control_status.flags.gps) { if (_control_status.flags.tilt_align && (_time_last_imu - _time_last_gps) < 5e5 && _NED_origin_initialised && (_time_last_imu - _last_gps_fail_us > 5e6)) { // If the heading is not aligned, reset the yaw and magnetic field states if (!_control_status.flags.yaw_align) { _control_status.flags.yaw_align = resetMagHeading(_mag_sample_delayed.mag); } // If the heading is valid start using gps aiding if (_control_status.flags.yaw_align) { _control_status.flags.gps = true; _time_last_gps = _time_last_imu; // if we are not already aiding with optical flow, then we need to reset the position and velocity if (!_control_status.flags.opt_flow) { _control_status.flags.gps = resetPosition(); _control_status.flags.gps = resetVelocity(); } } } } else if (!(_params.fusion_mode & MASK_USE_GPS)) { _control_status.flags.gps = false; } // handle the case when we are relying on GPS fusion and lose it if (_control_status.flags.gps && !_control_status.flags.opt_flow) { // We are relying on GPS aiding to constrain attitude drift so after 10 seconds without aiding we need to do something if ((_time_last_imu - _time_last_pos_fuse > 10e6) && (_time_last_imu - _time_last_vel_fuse > 10e6)) { if (_time_last_imu - _time_last_gps > 5e5) { // if we don't have gps then we need to switch to the non-aiding mode, zero the velocity states // and set the synthetic GPS position to the current estimate _control_status.flags.gps = false; _last_known_posNE(0) = _state.pos(0); _last_known_posNE(1) = _state.pos(1); _state.vel.setZero(); } else { // Reset states to the last GPS measurement resetPosition(); resetVelocity(); // Reset the timeout counters _time_last_pos_fuse = _time_last_imu; _time_last_vel_fuse = _time_last_imu; } } } }
PBall::PBall() { srand( ( unsigned )time( NULL ) ); serveXvelocity = 1; resetPosition(); }
Plane::Plane(KGameRenderer *renderer, BomberBoard *board) : Explodable(QString("plane"), QString("plane_explode"), PLANE_RELATIVE_SIZE, PLANE_RELATIVE_SIZE, renderer, board) { setVelocity(DEFAULT_VELOCITY); resetPosition(); }
void onKey(int key, int scancode, int action, int mods) { if (oria::clearHSW(hmd)) { return; } if (CameraControl::instance().onKey(key, scancode, action, mods)) { return; } if (GLFW_PRESS != action) { int caps = ovrHmd_GetEnabledCaps(hmd); switch (key) { case GLFW_KEY_V: if (caps & ovrHmdCap_NoVSync) { ovrHmd_SetEnabledCaps(hmd, caps & ~ovrHmdCap_NoVSync); } else { ovrHmd_SetEnabledCaps(hmd, caps | ovrHmdCap_NoVSync); } return; case GLFW_KEY_P: if (caps & ovrHmdCap_LowPersistence) { ovrHmd_SetEnabledCaps(hmd, caps & ~ovrHmdCap_LowPersistence); } else { ovrHmd_SetEnabledCaps(hmd, caps | ovrHmdCap_LowPersistence); } return; case GLFW_KEY_R: resetPosition(); return; } } GlfwApp::onKey(key, scancode, action, mods); }
void Camera::initialize() { m_aspectRatio = ((float)graphics.getScreenWidth()) / ((float)graphics.getScreenHeight()); m_target = Vector3((float)graphics.getScreenWidth() / 2, (float)graphics.getScreenHeight() / 2, 0.0f); resetPosition(); }
Item *GfxBlockItem::newImage(QImage img, QUrl src, QPointF pos) { ASSERT(data()->book()); ASSERT(data()->resManager()); double maxW = availableWidth(); double maxH = maxW; double scale = 1; if (scale*img.width()>maxW) scale = maxW/img.width(); if (scale*img.height()>maxH) scale = maxH/img.height(); if (allChildren().isEmpty()) pos = QPointF(0, 0); else pos -= QPointF(img.width(),img.height())*(scale/2); pos = constrainPointToRect(pos, boundingRect()); Resource *res = data()->resManager()->importImage(img, src); QString resName = res->tag(); GfxImageData *gid = new GfxImageData(resName, img, data()); gid->setScale(scale); gid->setPos(pos); GfxImageItem *gii = new GfxImageItem(gid, this); gii->makeWritable(); resetPosition(); sizeToFit(); return gii; }
void yeseulCooperMessages::tensionEffect(ofRectangle rec1, ofRectangle rec2) { if (abs((dimensions.width/2+margin-redMove*1.1 - (0-dimensions.width/2-rec1.getWidth()-margin+redMove*1.6))) < rec1.getWidth()) { redMove+=redTextSpeed/7; } else { redMove+=redTextSpeed; } if (abs((dimensions.width/2+margin-greenMove) - (0-dimensions.width/2-rec1.getWidth()-margin+greenMove)) < rec1.getWidth()) { greenMove+=greenTextSpeed/6; } else { greenMove+=greenTextSpeed; } if (abs((0-dimensions.width/2-margin-rec1.getWidth()+purpleMove*1.7) - (dimensions.width/2+margin-150-purpleMove*1.4)) < rec1.getWidth()) { purpleMove+=purpleTextSpeed/6; } else { purpleMove+=purpleTextSpeed; } resetPosition(); }
image_info::image_info() { real_width = user_width = DEFAULT_WIDTH; real_height = user_height = DEFAULT_HEIGHT; aa_factor = DEFAULT_AAFACTOR; depth = DEFAULT_DEPTH; nr_threads = DEFAULT_NR_THREADS; rgb_data = NULL; raw_data = NULL; resetPosition(); render_in_progress = false; stop_in_progress = false; j_pre = false; palette_ip = false; finfo.type = MANDELBROT; color_out.nr = 1; color_out.ops[0].type = OP_ITER; color_in.nr = 1; color_in.ops[0].type = OP_NUMBER; color_in.ops[0].value = 0.0; io_id = -1; lines_posted = 0; lines_done = 0; }
Alien::Alien(wsp::Image *img) { SetImage(img); DefineCollisionRectangle(28, 14, 42, 55); resetMotion(); resetPosition(); resetShotCountdown(); }
HelloRift() { ovr_Initialize(); hmd = ovrHmd_Create(0); if (nullptr == hmd) { debugDevice = true; hmd = ovrHmd_CreateDebug(ovrHmd_DK2); } ovrHmd_ConfigureTracking(hmd, ovrTrackingCap_Orientation | ovrTrackingCap_Position, 0); resetPosition(); }
void Alien::update() { Move(motionX, motionY); if(GetY() < 0) { SetY(0); resetMotion(); } else if(GetY() > 480-GetHeight()) { SetY(480-GetHeight()); resetMotion(); } int i; for(i=0;i<numEnemyShots;i++) { if(enemyShots[i]->isFired() == false) continue; if(CollidesWith(enemyShots[i])) { enemyShots[i]->remove(); resetPosition(); resetMotion(); resetShotCountdown(); score++; break; } } if(--lockMotionFrames == 0) resetMotion(); if(GetX() < 0) resetPosition(); if(--nextShotCountdown == 0) { resetShotCountdown(); for(i=0;i<numOwnShots;i++) { if(ownShots[i]->isFired() == false) { ownShots[i]->fire(GetX(), GetY() + (GetHeight() / 2) - 10, -6); break; } } } }
void Racer::reset(hkVector4* resetPos, float rotation) { hkVector4 reset; reset.set(0.0f, 0.0f, 0.0f); hkVector4 resetPosition; resetPosition.setXYZ(*resetPos); // Generate random offsets so that the racer doesn't spawn exactly in the middle of the track anymore. srand((unsigned)time(0)+givenDamage); int offsetX = rand()%5; srand((unsigned)time(0)+offsetX); int offsetZ = rand()%5; if(offsetX%2 == 0){ offsetX *= -1; } if(offsetZ%2 == 0){ offsetZ *= -1; } //------------------------ setPosAndRot(resetPosition(0)+offsetX, resetPosition(1), resetPosition(2)+offsetZ, 0, rotation, 0); body->setLinearVelocity(reset); wheelFL->body->setLinearVelocity(reset); wheelFR->body->setLinearVelocity(reset); wheelRL->body->setLinearVelocity(reset); wheelRR->body->setLinearVelocity(reset); body->setAngularVelocity(reset); wheelFL->body->setAngularVelocity(reset); wheelFR->body->setAngularVelocity(reset); wheelRL->body->setAngularVelocity(reset); wheelRR->body->setAngularVelocity(reset); }
void Map::detectCollisionFG() { for (int i = 0; i < gbVector.size(); i++) { for (int j = 0; j < foVector.size(); j++) { if (!foVector[j]->intersected && intersects(foVector[j], gbVector[i]->gbSprite.getGlobalBounds(), 1)) { //collision detected sound.setBuffer(iBuffer); sound.play(); gbVector.erase(gbVector.begin() + i); curNumFO--; foVector[j]->intersected = true; resetPosition(foVector[j]); if (curNumFO == 0) { nextLevel(); } break; } } } }
void Map::nextLevel() { level++; maxNumFO += 5; //x number more falling objects each level curNumFO = maxNumFO; maxVelY += 0.02f; //general speed increase of falling objects //make and add extra falling objects to vector for next level for (int i = foVector.size(); i < maxNumFO; i++) { FallingObject * myFO = new FallingObject(*iceTextureM); resetPosition(myFO); foVector.insert(foVector.begin(), myFO); } for (int i = 0; i < foVector.size(); i++) { float randVelY = (rand() % 2)* 0.03f; //give falling objects random speed within range //update all velY to start next level foVector[i]->velY = maxVelY + randVelY; foVector[i]->intersected = false; } }
void Map::updateFO() { for (int i = 0; i < foVector.size(); i++) { //if falling object off screen if (foVector[i]->foSprite.getPosition().y - foVector[i]->foSprite.getGlobalBounds().height / 2 > window->getSize().y) { resetPosition(foVector[i]); curNumFO--; //check if all falling objects have been destroyed if (curNumFO == 0) { nextLevel(); } } else { foVector[i]->foSprite.setRotation(foVector[i]->foSprite.getRotation() + foVector[i]->randomNum); foVector[i]->foSprite.move(0, 15*foVector[i]->velY); foVector[i]->foCircle.move(0, 15*foVector[i]->velY); } } }
void Map::foCreate() { srand(time(NULL)); for (int i = 0; i < maxNumFO; i++) { //initalize falling objects FallingObject * myFO = new FallingObject(*iceTextureM); resetPosition(myFO); float randVelY = (rand() % 2)* 0.02f; myFO->velY = maxVelY + randVelY; myFO->intersected = false; foVector.insert(foVector.begin(),myFO); } int initx = 20; int x = initx; for (int i = 0; i < curNumGB; i++) { //initalize ground blocks GroundBlock * myGB = new GroundBlock(*woodTextureM); myGB->gbSprite.setPosition(sf::Vector2f(x, window->getSize().y-myGB->gbSprite.getGlobalBounds().height)); x += (((window->getSize().x - 2 * initx) - (curNumGB * myGB->gbSprite.getGlobalBounds().width)) / (curNumGB - 1)) + myGB->gbSprite.getGlobalBounds().width; gbVector.insert(gbVector.begin(), myGB); } }
bool NormalAttack::init() { if (!Attack::init()) return false; isHit = false; sprite = CCSprite::create("dropper.png"); addChild(sprite); angle = CCRANDOM_0_1() * 2 * M_PI; distance = 400; speed = 150 + CCRANDOM_0_1() * 50; resetPosition(); scheduleUpdate(); return true; }
void Map::detectCollisionFB(std::vector<Weapon::Bullet*> bullets) { for (int i = 0; i < bullets.size(); i++) { for (int j = 0; j < foVector.size(); j++) { if (!foVector[j]->intersected && intersects(foVector[j], bullets[i]->bulletSprite.getGlobalBounds(), 0)) { //collision detected sound.setBuffer(iBuffer); sound.play(); bullets.erase(bullets.begin() + i); score += 10; curNumFO--; foVector[j]->intersected = true; resetPosition(foVector[j]); if (curNumFO == 0) { nextLevel(); } break; } } } }
void RawModel::updateScrollPos(int value) { m_iCurAbsScrollPos = firstSample()+value; qDebug() << "RawModel: absolute Fiff Scroll Cursor" << m_iCurAbsScrollPos << "(m_iAbsFiffCursor" << m_iAbsFiffCursor << ", sizeOfPreloadedData" << sizeOfPreloadedData() << ")"; //if a scroll position is selected, which is not within the loaded data range -> reset position of model if(m_iCurAbsScrollPos > (m_iAbsFiffCursor+sizeOfPreloadedData()+m_iWindowSize) || m_iCurAbsScrollPos < m_iAbsFiffCursor) { resetPosition(m_iCurAbsScrollPos); return; } //reload data if end of loaded range is reached //front if(!m_bReloading && (m_iCurAbsScrollPos-m_iAbsFiffCursor < m_reloadPos) && !m_bStartReached) { qDebug() << "RawModel: Reload requested at FRONT of loaded fiff data, m_iAbsFiffCursor:" << m_iAbsFiffCursor << "m_iCurAbsScrollPos:" << m_iCurAbsScrollPos; reloadFiffData(1); } //end else if(!m_bReloading && m_iCurAbsScrollPos > m_iAbsFiffCursor+sizeOfPreloadedData()-m_reloadPos && !m_bEndReached) { qDebug() << "RawModel: Reload requested at END of loaded fiff data, m_iAbsFiffCursor:" << m_iAbsFiffCursor << "m_iCurAbsScrollPos:" << m_iCurAbsScrollPos; reloadFiffData(0); } }
void Map::detectCollisionFC(sf::RectangleShape charShape) { for (int i = 0; i < foVector.size(); i++) { if (!foVector[i]->intersected && intersects(foVector[i], charShape.getGlobalBounds(), 0)) { foVector[i]->intersected = true; lives--; if (lives <= 0) { sound.setBuffer(dBuffer); sound.play(); gameOverB = true; } else { sound.setBuffer(oBuffer); sound.play(); } resetPosition(foVector[i]); curNumFO--; if (curNumFO == 0) { nextLevel(); } } } }
bool MissileAttack::init() { if (!Attack::init()) return false; missile = CCSprite::create("missile.png"); addChild(missile); aim = CCSprite::create("aim.png"); aim->setColor(ccc3(255, 0, 0)); aim->setScale(1.5f); addChild(aim); isHit = false; angle = 0; distance = 1600; resetPosition(); scheduleUpdate(); return true; }
void MissileAttack::rotate(float r) { angle += r; resetPosition(); }
void MissileAttack::update(float dt) { distance -= dt * 800; resetPosition(); }
bool Ekf::initialiseFilter(void) { _state.ang_error.setZero(); _state.vel.setZero(); _state.pos.setZero(); _state.gyro_bias.setZero(); _state.gyro_scale(0) = _state.gyro_scale(1) = _state.gyro_scale(2) = 1.0f; _state.accel_z_bias = 0.0f; _state.mag_I.setZero(); _state.mag_B.setZero(); _state.wind_vel.setZero(); // get initial roll and pitch estimate from accel vector, assuming vehicle is static Vector3f accel_init = _imu_down_sampled.delta_vel / _imu_down_sampled.delta_vel_dt; float pitch = 0.0f; float roll = 0.0f; if (accel_init.norm() > 0.001f) { accel_init.normalize(); pitch = asinf(accel_init(0)); roll = -asinf(accel_init(1) / cosf(pitch)); } matrix::Euler<float> euler_init(roll, pitch, 0.0f); // Get the latest magnetic field measurement. // If we don't have a measurement then we cannot initialise the filter magSample mag_init = _mag_buffer.get_newest(); if (mag_init.time_us == 0) { return false; } // rotate magnetic field into earth frame assuming zero yaw and estimate yaw angle assuming zero declination // TODO use declination if available matrix::Dcm<float> R_to_earth_zeroyaw(euler_init); Vector3f mag_ef_zeroyaw = R_to_earth_zeroyaw * mag_init.mag; float declination = 0.0f; euler_init(2) = declination - atan2f(mag_ef_zeroyaw(1), mag_ef_zeroyaw(0)); // calculate initial quaternion states _state.quat_nominal = Quaternion(euler_init); _output_new.quat_nominal = _state.quat_nominal; // calculate initial earth magnetic field states matrix::Dcm<float> R_to_earth(euler_init); _state.mag_I = R_to_earth * mag_init.mag; resetVelocity(); resetPosition(); // initialize vertical position with newest baro measurement baroSample baro_init = _baro_buffer.get_newest(); if (baro_init.time_us == 0) { return false; } _state.pos(2) = -baro_init.hgt; _output_new.pos(2) = -baro_init.hgt; initialiseCovariance(); return true; }
RemoteVertex(const RemoteVertex &v) : Vertex(v), owner(v.owner), remoteIndex(v.remoteIndex), secondaryOwner(0), secondaryIndex(0), secondaryPos(0.0f,0.0f,0.0f), offset(0.0f) { resetPosition(); }
void Communication_Thread::run() { Msg_Ordre_Com msg_ordre_com; resetPosition(robot1); resetPosition(robot2); for(;;) { // si on a reçu un message //printf("tache : %d\n",bal_ordre_com); if (mq_receive(bal_ordre_com, (char*)&msg_ordre_com, sizeof(Msg_Ordre_Com), NULL)!= -1) { liste = msg_ordre_com; ordreCourantRobot1 = 0; ordreCourantRobot2 = 0; pasPreviousTopRobot1.pas_droite = 0; pasPreviousTopRobot1.pas_gauche = 0; pasPreviousTopRobot2.pas_droite = 0; pasPreviousTopRobot2.pas_gauche = 0; Pas_Robot reinit = {0,0}; if (msg_ordre_com.ordres[0].robot1.pas_droite == 0 && msg_ordre_com.ordres[0].robot1.pas_gauche == 0) { ordreCourantRobot1 = 4; }else { setSpeed(robot1,reinit); resetPosition(robot1); setObjectif(robot1, liste.ordres[ordreCourantRobot1].robot1); } if (msg_ordre_com.ordres[0].robot2.pas_droite == 0 && msg_ordre_com.ordres[0].robot2.pas_gauche == 0) { ordreCourantRobot2 = 4; } else { setSpeed(robot2,reinit); resetPosition(robot2); setObjectif(robot2, liste.ordres[ordreCourantRobot2].robot2); } sleep(1); }else { Pas_Robot vitesse = getSpeed(robot1); if (vitesse.pas_droite == 0 && vitesse.pas_gauche == 0 && ordreCourantRobot1 < 3) { resetPosition(robot1); pasPreviousTopRobot1.pas_droite = 0; pasPreviousTopRobot1.pas_gauche = 0; setObjectif(robot1, liste.ordres[++ordreCourantRobot1].robot1); } vitesse = getSpeed(robot2); if (vitesse.pas_droite == 0 && vitesse.pas_gauche == 0 && ordreCourantRobot2 < 3) { resetPosition(robot2); pasPreviousTopRobot2.pas_droite = 0; pasPreviousTopRobot2.pas_gauche = 0; setObjectif(robot2, liste.ordres[++ordreCourantRobot2].robot2); } }//sinon usleep(50000); } }
//インデックスとタグと位置を変更する void BallSprite::setPositionIndexAndChangePosition(PositionIndex positionIndex) { setPositionIndex(positionIndex); //インデックスとタグを変更する resetPosition(); //位置を変更する }