// @brief The process equation is used to update the systems state using the process euquations of the system. // @param sigma_point The sigma point representing a system state. // @param deltaT The amount of time that has passed since the previous update, in seconds. // @param measurement The reading from the rate gyroscope in rad/s used to update the orientation. // @return The new estimated system state. arma::vec::fixed<IMUModel::size> IMUModel::timeUpdate(const arma::vec::fixed<size>& state, double deltaT) { arma::vec::fixed<IMUModel::size> newState; newState = state; //make a rotation quaternion const double omega = arma::norm(state.rows(VX, VZ)) + 0.00000000001; //Negate to compensate for some later mistake. //deltaT has been negative for a while and has masked an incorrect hack below const double theta = -omega*deltaT*0.5; const double sinTheta = sin(theta); const double cosTheta = cos(theta); arma::vec vq({cosTheta,state(VX)*sinTheta/omega,state(VY)*sinTheta/omega,state(VZ)*sinTheta/omega}); //calculate quaternion multiplication //TODO replace with quaternion class arma::vec qcross = arma::cross( vq.rows(1,3), state.rows(QX,QZ) ); newState(QW) = vq(0)*state(QW) - arma::dot(vq.rows(1,3), state.rows(QX,QZ)); newState(QX) = vq(0)*state(QX) + state(QW)*vq(1) + qcross(0); newState(QY) = vq(0)*state(QY) + state(QW)*vq(2) + qcross(1); newState(QZ) = vq(0)*state(QZ) + state(QW)*vq(3) + qcross(2); return newState; }
int main() { QList<State> states; states += State("NOTOKEN"); // identifiers for (int cc = 'a'; cc <= 'z'; ++cc) newState(states, "CHARACTER", cc); for (int cc = 'A'; cc <= 'Z'; ++cc) newState(states, "CHARACTER", cc); newState(states, "CHARACTER", '_'); // add digits for(int cc = '0'; cc <= '9'; ++cc) newState(states, "DIGIT", cc); // keywords for(int ii = 0; keywords[ii].lexem; ++ii) newState(states, keywords[ii].token, keywords[ii].lexem); ::printf("static const struct\n{\n" " Token token;\n" " char next[128];\n" "} keywords[] = {\n"); for(int ii = 0; ii < states.size(); ++ii) { printf("%s { %s, { ", ii?",\n":"", states[ii].token.data()); for(int jj = 0; jj < 128; jj++) printf("%s%d", jj?",":"", states[ii].next[jj]); printf(" } }"); } printf("\n};\n"); }
TicTacToe::TicTacToe( bool meFirst, int boardSize, QWidget *parent, const char *name ) : QWidget( parent, name ) { Q3VBoxLayout * l = new Q3VBoxLayout( this, 6 ); // Create a message label message = new QLabel( this ); message->setFrameStyle( Q3Frame::WinPanel | Q3Frame::Sunken ); message->setAlignment( Qt::AlignCenter ); l->addWidget( message ); // Create the game board and connect the signal finished() to this // gameOver() slot board = new TicTacGameBoard( meFirst, boardSize, this ); connect( board, SIGNAL(finished()), SLOT(gameOver()) ); l->addWidget( board ); // Create a horizontal frame line Q3Frame *line = new Q3Frame( this ); line->setFrameStyle( Q3Frame::HLine | Q3Frame::Sunken ); l->addWidget( line ); // Create the combo box for deciding who should start, and // connect its clicked() signals to the buttonClicked() slot whoStarts = new QComboBox( this ); whoStarts->insertItem( "Opponent starts" ); whoStarts->insertItem( "You start" ); l->addWidget( whoStarts ); whoStarts->setEnabled(false); whoStarts->setCurrentIndex(meFirst); // Create the push buttons and connect their clicked() signals // to this right slots. connect( board, SIGNAL(myMove(int)), this, SIGNAL(myMove(int))); connect( board, SIGNAL(stateChanged()), this, SLOT(newState())); newGame = new QPushButton( "Play!", this ); connect( newGame, SIGNAL(clicked()), SLOT(newGameClicked()) ); newGame->setEnabled(false); quit = new QPushButton( "Quit", this ); connect( quit, SIGNAL(clicked()), this, SIGNAL(closing()) ); Q3HBoxLayout * b = new Q3HBoxLayout; l->addLayout( b ); b->addWidget( newGame ); b->addWidget( quit ); newState(); //board->newGame(); newGameClicked(); }
InputAutomata::InputAutomata(const String& name) : InputSource(name) { _initial = newState(); _terminal = newState(); _current = NULL; _commandHandler = createEventHandler(this, &InputAutomata::onInputCommand); reset(); }
void SessionTab::on_closeSessionButton_clicked() { m_NetworkSession->close(); if (!m_NetworkSession->isOpen()) { newState(m_NetworkSession->state()); } }
void GameClient::connectToServer(QString host, int port) { QString ipAddress; QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); // use the first non-localhost IPv4 address for(int i = 0; i < ipAddressesList.size(); ++i) { if(ipAddressesList.at(i) != QHostAddress::LocalHost && ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); break; } } m_connection = new Connection(Connection::Client); // bind the connection to a certain port int i = 0; bool ok; do { i ++; ok = m_connection->bind(QHostAddress(ipAddress), StartBindPort+1000*i); } while(!ok); m_connBindPort = StartBindPort + 1000 * i; m_connection->connectToHost(host, port); // each connection use the same port as first time connect(m_connection, SIGNAL(newGreeting(QByteArray)), this, SLOT(handleNewGreeting(QByteArray))); connect(m_connection, SIGNAL(newState(QByteArray)), this, SLOT(handleNewState(QByteArray))); connect(m_connection, SIGNAL(newBackupServer(QByteArray)), this, SLOT(handleNewBackupServer(QByteArray))); connect(this, SIGNAL(haveMessageToSend(Connection::DataType,QByteArray)), m_connection, SLOT(sendMessage(Connection::DataType,QByteArray))); emit newPrimaryServerInfo(host+','+QString::number(port)); }
void CDynamicProgrammingStrategy::calculatePaths() { while (!stateQueue.empty()) { PlayerState currentState = stateQueue.front(); for (int xDeviation = -1; xDeviation <= 1; ++xDeviation) { for (int yDeviation = -1; yDeviation <= 1; ++yDeviation) { PlayerState newState( currentState.GetX() + currentState.GetXVelocity() + xDeviation, currentState.GetY() + currentState.GetYVelocity() + yDeviation, currentState.GetXVelocity() + xDeviation, currentState.GetYVelocity() + yDeviation ); if (newState.GetX() < 0 || newState.GetX() >= map.sizeOnXaxis() || newState.GetY() < 0 || newState.GetY() >= map.sizeOnYaxis() || !map.canPlayerStayOnCell(newState.GetX(), newState.GetY()) || map.hasBarrierOnPath(currentState.GetX(), currentState.GetY(), newState.GetX(), newState.GetY())) { continue; } if (minPath.GetStepCount(newState) == -1 || minPath.GetStepCount(newState) > minPath.GetStepCount(currentState) + 1) { minPath.SetStepCount(newState, minPath.GetStepCount(currentState) + 1); minPath.SetPreviousState(newState, currentState); stateQueue.push(newState); } } } stateQueue.pop(); } }
//====================================================================== //====================================================================== void NvUIButton::Draw(const NvUIDrawState &drawState) { if (!m_isVisible) return; const uint32_t state = GetDrawState(); // eventually this will do some state-based handling for active/inactive, pushed NvUIElement *drawme = m_visrep[state]; if (drawme!=NULL) // pass to our visrep. drawme->Draw(drawState); if (m_title) { NvUIDrawState newState(drawState); // !!!!TBD TODO // ... instead of using alpha, we could draw some a translucent box using our uirect. if (m_visrep[0]==NULL && m_visrep[1]==NULL && m_visrep[2]==NULL) { // then modulate alpha based on draw state. if (state==NvUIButtonState::INACTIVE) { newState.alpha *= 0.25f; // very 'dim' } else if (state==NvUIButtonState::SELECTED) { newState.alpha *= 0.75f; // slightly 'dimmed' } // else leave alone. } m_title->Draw(newState); } }
void DialogState::on_buttonBox_accepted() { if(ui->le_nameState->text()!=""){ //qDebug()<<ui->le_nameState->text(); emit newState(ui->le_nameState->text(),ui->cb_final->isChecked()); } }
Camera *newCamera(float x, float y, float z) { Camera *cam = alloc( Camera, 1 ); exit_guard(cam); cam->state = newState(); cam->state->position[0] = x; cam->state->position[1] = y; cam->state->position[2] = z; cam->state->up[0] = 0.0f; cam->state->up[1] = 1.0f; cam->state->up[2] = 0.0f; cam->state->right[0] = 1.0f; cam->state->right[1] = 0.0f; cam->state->right[2] = 0.0f; cam->state->forward[0] = 0.0f; cam->state->forward[1] = 0.0f; cam->state->forward[2] = -1.0f; cam->mouseGrab = 0; cam->wireframe = 0; return cam; }
void TRotationEffect::DialogValueChanged(bool update) { ASSERT(m_keyFramesDialog); bool change = false; // update the state for the target key frame(s) TRotationState newState(m_keyFramesDialog->Rotation()); if (KeyFrameState(m_keyFrameTarget, &newState)) change = true; // Include the end frame if we are editing defaults if (m_editingDefaults) { TKeyFrameIterator kf = EndOfKeyFrames(); kf--; if (KeyFrameState(kf, &newState)) change = true; } if (change && update) { // tell the cue effect to update itself BMessage msg(CUEFX_UPDATE_MSG); msg.AddPointer("effect", &this); m_dialogTarget->PostMessage(&msg, m_dialogTarget); } }
MainForm::MainForm(QWidget * parent, Qt::WindowFlags f) : QWidget ( parent,f ) { ui.setupUi(this); connect(this, SIGNAL(done(QString)), ui.result, SLOT(setText(QString))); connect(ui.PushButton, SIGNAL(clicked()), this, SLOT(computeRes())); connect(this, SIGNAL(done(QString)), ui.widget, SLOT(newState(QString))); }
void ParticleManagerTinkerToy::performStep() { Eigen::Matrix< double, Eigen::Dynamic, 1 > currentState( m_particles.size() * 6 ); Eigen::Matrix< double, Eigen::Dynamic, 1 > newState( m_particles.size() * 6 ); accumulateState( currentState ); m_pSolver->evaluateNextState( currentState, newState, *this ); disperseState( newState ); }
LispRef content(LispRef stream, LispRef eos_error_p, LispRef eos_value) { WITH_DEBUG(fprintf(stderr, "content\n")); char tag; read_byte(tag); WITH_DEBUG(fprintf(stderr, " tag: %x\n", tag)); switch (tag) { case TC_NULL: return nullReference(stream, eos_error_p, eos_value); case TC_REFERENCE: return prevObject(stream, eos_error_p, eos_value); case TC_CLASS: return newClass(stream, eos_error_p, eos_value); case TC_OBJECT: return newObject(stream, eos_error_p, eos_value); case TC_STRING: return newString(stream, eos_error_p, eos_value); case TC_STATE: return newState(stream, eos_error_p, eos_value); case TC_VECTOR: return newVector(stream, eos_error_p, eos_value); case TC_STREAM: return newStream(stream, eos_error_p, eos_value); case TC_RESET: return reset(stream, eos_error_p, eos_value); case TC_SELF: return stream; case TC_FUNCTION: return newFunction(stream, eos_error_p, eos_value); case TC_BYTEVECTOR: return newBytevector(stream, eos_error_p, eos_value); case TC_INT: return newInt(stream, eos_error_p, eos_value); case TC_DOUBLE: return newDouble(stream, eos_error_p, eos_value); case TC_SYMBOL: return newSymbol(stream, eos_error_p, eos_value); case TC_KEYWORD: return newKeyword(stream, eos_error_p, eos_value); case TC_CHAR: return newChar(stream, eos_error_p, eos_value); case TC_CONS: return newCons(stream, eos_error_p, eos_value); default: { LispRef str, args; eul_allocate_string(str, "unknown tag in ~a"); eul_allocate_cons(args, stream, eul_nil); eul_serial_error(stream, str, args); return eul_nil; } } }
void Grammar::computeSuccessors(LR1State &state) { //dump(state); pause(); BitSet itemsDone(state.m_items.size()); // this is correct! for(UINT i = 0; i < state.m_items.size(); i++) { if(itemsDone.contains(i)) { continue; } const LR1Item &origItem = state.m_items[i]; if(isAcceptItem(origItem)) { continue; // No successor, but accept } const Production &origProduction = getProduction(origItem); if(origItem.m_dot < origProduction.getLength()) { // origItem is A -> alfa . X beta [la] CompactIntArray successorItems; successorItems.add(i); int symbolNr = origProduction.m_rightSide[origItem.m_dot]; LR1State newState(getStateCount()); const LR1Item newItem(true, origItem.m_prod, origItem.m_dot+1, origItem.m_la); // newItem is A -> alfa X . beta [la] (kernelItem) newState.addItem(newItem); itemsDone += i; for(UINT k = i+1; k < state.m_items.size(); k++) { if(itemsDone.contains(k)) { continue; } const LR1Item &sameSymbolItem = state.m_items[k]; const Production &sameSymbolProd = getProduction(sameSymbolItem); if(sameSymbolItem.m_dot < sameSymbolProd.getLength() && sameSymbolProd.m_rightSide[sameSymbolItem.m_dot] == symbolNr) { // sameSymbolItem is C -> gamma . X zeta [la1] const LR1Item newItem1(true, sameSymbolItem.m_prod, sameSymbolItem.m_dot+1, sameSymbolItem.m_la); // newItem1 is C -> gamma X . zeta [la1] (kernelItem) newState.addItem(newItem1); itemsDone += k; successorItems.add(k); } } newState.sortItems(); int succStateIndex = findState(newState); if(succStateIndex < 0) { computeClosure(newState, true); succStateIndex = addState(newState); } else { if(mergeLookahead(m_states[succStateIndex], newState)) { m_unfinishedSet.add(succStateIndex); // printf(_T(")%d ", succStateIndex); } } assert(succStateIndex >= 0); for(size_t j = 0; j < successorItems.size(); j++) { state.m_items[successorItems[j]].m_succ = succStateIndex; } } } }
// constructor DlgSplineTest::DlgSplineTest() { m_path.add(Point3(-1, 10, 0)); m_path.add(Point3(-0.5f, 10, 1)); m_path.add(Point3(1, 10, 1)); m_path.add(Point3(1, 10, -1)); m_path.add(Point3(-1, 10, -1)); m_state = Delegate(); newState(); }
void mouseClick(int button, int state, int x, int y) { if (state == GLUT_DOWN) { if (button == GLUT_LEFT_BUTTON) { pushb(pts, newState(x, height - y, 0.00000001, 100)); col = col == 2 ? 0 : col + 1; } if (button == GLUT_RIGHT_BUTTON) { removeNode(pts, pts -> head -> next); } } }
void drawEditLvl(){ int i, j, c; //int iSect[5][5]; int randomNum; Entity *testEn; char enText[] = "models/red_piece.png"; char shipText[] = "models/yell_piece.png"; char powText[] = "models/green_piece.png"; char blText[] = "models/black_piece.png"; char enObj[] = "models/cube.obj"; //memcpy(iSect, *lvlSect, sizeof(lvlSect)); //testEn = newScorer(vec3d(100, cameraPosition.y + 60, 100), sc); for (i = 0; i < 5; i++){ //Y-Axis for (j = 0; j < 5; j++){ //X-Axis c = lvlSect[i][j]; newLvl[i][j] = c; switch (c){ case 0: //nothing testEn = newState(vec3d(worldWidth / 2 * (j - 2), cameraPosition.y + 5, worldHeight / 2 * (i - 2)), "state", LoadSprite(blText, 1024, 1024), 0); break; case 1: //ships testEn = newState(vec3d(worldWidth / 2 * (j - 2), cameraPosition.y + 5, worldHeight / 2 * (i - 2)), "state", LoadSprite(shipText, 1024, 1024), 1); break; case 2: //powerups testEn = newState(vec3d(worldWidth / 2 * (j - 2), cameraPosition.y + 5, worldHeight / 2 * (i - 2)), "state", LoadSprite(powText, 1024, 1024), 2); break; case 3: //walls testEn = newState(vec3d(worldWidth / 2 * (j - 2), cameraPosition.y + 5, worldHeight / 2 * (i - 2)), "state", LoadSprite(enText, 1024, 1024), 3); break; } } } slog("yo"); }
void E42mcStateGeneratorWidget::loadConfig(const OdeConfig* cfg){ const E42mcConfig* ecfg = dynamic_cast<const E42mcConfig*>(cfg); assert(ecfg); delete this->config; this->config = new E42mcConfig(*ecfg); delete this->state; this->state = NULL; newState(); }
int main(int argc, const char* argv[]){ {std::string srcFile, printFile; parseOpt(argc-1, &argv[1], srcFile, printFile); void *state = newState(); parseFile(state,srcFile.c_str(),printFile.c_str()); freeState(state); } #ifdef WIN32 _CrtDumpMemoryLeaks(); #endif return 0; }
int descendantsTest(){ stackPushState(newState(0,0)); Node* currentNode; int i=0; while(!isStackEmpty()){ currentNode = stackPeek(); if(currentNode->isBranched) { stackDeleteTop(); } else { currentNode->isBranched = 1; if(i<3){ stackPushState(newState(i*3+1,1)); stackPushState(newState(i*3+2,i)); stackPushState(newState(i*3+3,i)); i++; } } stackPrintOut(); } return 0; }
void MandatoryUpdateMachine::setCurrentState(State * newStatePointer) { { boost::scoped_ptr<State> newState(newStatePointer); if(mState != 0) mState->exit(); mState.swap(newState); // Old state will be deleted on exit from this block before the new state // is entered. } if(mState != 0) mState->enter(); }
void handleNewState(State* state) { unique_ptr<State> newState(state->clone()); vector<unique_ptr<Action>> actions(newState->availableActions()); stateActions[newState.get()] = vector<unique_ptr<ActionValue>>(); auto& actionValues(stateActions[newState.get()]); for (auto& action : actions) { actionValues.push_back(unique_ptr<ActionValue>(new ActionValue(move(action)))); } ownedStates.push_back(move(newState)); }
void Player::res() { for (int i=0;i<6;i++) { b[i] = true; } bulletCount = 6; shotTime = 0; velocity = VECTOR2(0,0); dead = false; splat = false; dodgeTime = 0; newState(new WalkState()); }
int simpleTest(){ printf("--- Pushing elements to stack \n"); for(int i=0; i<10; i++){ stackPushState(newState(i,i)); stackPrintOut(); } printf("--- Popping elements from stack \n"); for(int i=0; i<10; i++){ stackDeleteTop(); stackPrintOut(); } return 0; }
// update void DlgSplineTest::update(float delta) { Super::update(delta); m_delta = delta; m_time += delta; if (m_oldState != m_state) { newState(); } m_oldState = m_state; }
void Connection::processData() { m_buffer = read(m_numBytesForCurrentDataType); if(m_buffer.size() != m_numBytesForCurrentDataType) { abort(); return; } switch(m_currentDataType) { case Greeting: if(m_identity == PrimaryServer || m_identity == BackupServer) { emit newClient(this); } else if(m_identity == Client) { emit newGreeting(m_buffer); } break; case Direction: if(m_identity == PrimaryServer || m_identity == BackupServer) { emit newMove(m_buffer); } break; case GameState: if(m_identity == BackupServer || m_identity == Client) { emit newState(m_buffer); } break; case SelectServer: if(m_identity == Client) { emit newBackupServer(m_buffer); } break; case Acknowledge: if(m_identity == PrimaryServer) { emit newAck(); } break; case PlayerAddr: if(m_identity == BackupServer) { emit newPlayerAddr(m_buffer); } break; default: break; } m_currentDataType = Undefined; m_numBytesForCurrentDataType = 0; m_buffer.clear(); }
//p := newsink, q:=childstate, r:=newchildstate //suffixstate = [tail(wa)]wa, childstate = [tail(wa)]w void Insert(int a) { State *p = newState(sink->dep + 1), *cur = sink, *sufstate; while (cur && !cur->go[a]) cur->go[a] = p, cur = cur->suf; if (!cur) sufstate = root; else { State *q = cur->go[a]; if (q->dep == cur->dep + 1) sufstate = q; else { State *r = newState(cur->dep + 1); for (int i = 0; i < 26; i++) r->go[i] = q->go[i]; r->suf = q->suf; q->suf = r; sufstate = r; while (cur && cur->go[a] == q) cur->go[a] = r, cur = cur->suf; } } p->suf = sufstate; sink = p; }
bool StandbyState::checkForZoom(Editor* editor, MouseMessage* msg) { tools::Ink* clickedInk = editor->getCurrentEditorInk(); // Start scroll loop if (clickedInk->isZoom()) { EditorStatePtr newState(new ZoomingState()); editor->setState(newState); newState->onMouseDown(editor, msg); return true; } else return false; }
bool StandbyState::checkForScroll(Editor* editor, MouseMessage* msg) { tools::Ink* clickedInk = editor->getCurrentEditorInk(); // Start scroll loop if (msg->middle() || clickedInk->isScrollMovement()) { // TODO msg->middle() should be customizable EditorStatePtr newState(new ScrollingState()); editor->setState(newState); newState->onMouseDown(editor, msg); return true; } else return false; }