void sub_uzo_display::post_display(game& gm) const { if (gm.get_player()->get_target()) { projection_data pd = get_projection_data(gm); ui.show_target(pd.x, pd.y, pd.w, pd.h, get_viewpos(gm)); } sys().prepare_2d_drawing(); int tex_w = compass->get_width(); int tex_h = compass->get_height(); int bearing = int(tex_w*ui.get_relative_bearing().value()/360); if( bearing>dx && bearing<tex_w-dx){ compass->draw_subimage(xi, yi, comp_size, tex_h, bearing-dx, 0, comp_size, tex_h); } else { int dx1=0,dx2=0; if( bearing<dx ){ dx1=dx-bearing; dx2=dx+bearing; } else if( bearing>tex_w-dx ){ dx1=dx+(tex_w-bearing); dx2=comp_size-dx; } compass->draw_subimage(xi, yi, dx1, tex_h, tex_w-(dx1), 0, dx1, tex_h); compass->draw_subimage(xi+dx1, yi, dx2, tex_h, 0, 0, dx2, tex_h ); } uzotex->draw(0, 0, 1024, 768); ui.draw_infopanel(true); sys().unprepare_2d_drawing(); }
SplashState::SplashState(Game* game) : GameState(game), _entities(log()), _spriteRenderer(renderer()), _sprites(assets(), loader(), &_spriteRenderer), _texts(loader(), &_spriteRenderer), _inputs(sys(), &log()), _camera(), _initialized(false), _running(false), _loop(sys()), _fpsTime(0), _fpsCount(0), _skipInput(nullptr), _skipTime(1), _nextState(nullptr) { _entities.registerComponentManager(&_sprites); _entities.registerComponentManager(&_texts); }
void do_step_impl( System system , const StateIn &in , const DerivIn &dxdt , const time_type &t , StateOut &out , const time_type &dt ) { const value_type a2 = static_cast<value_type> ( 0.2 ); const value_type a3 = static_cast<value_type> ( 0.3 ); const value_type a4 = static_cast<value_type> ( 0.6 ); const value_type a5 = static_cast<value_type> ( 1.0 ); const value_type a6 = static_cast<value_type> ( 0.875 ); const value_type b21 = static_cast<value_type> ( 0.2 ); const value_type b31 = static_cast<value_type> ( 3.0 ) / static_cast<value_type>( 40.0 ); const value_type b32 = static_cast<value_type> ( 9.0 ) / static_cast<value_type>( 40.0 ); const value_type b41 = static_cast<value_type> ( 0.3 ); const value_type b42 = static_cast<value_type> ( -0.9 ); const value_type b43 = static_cast<value_type> ( 1.2 ); const value_type b51 = static_cast<value_type> ( -11.0 ) / static_cast<value_type>( 54.0 ); const value_type b52 = static_cast<value_type> ( 2.5 ); const value_type b53 = static_cast<value_type> ( -70.0 ) / static_cast<value_type>( 27.0 ); const value_type b54 = static_cast<value_type> ( 35.0 ) / static_cast<value_type>( 27.0 ); const value_type b61 = static_cast<value_type> ( 1631.0 ) / static_cast<value_type>( 55296.0 ); const value_type b62 = static_cast<value_type> ( 175.0 ) / static_cast<value_type>( 512.0 ); const value_type b63 = static_cast<value_type> ( 575.0 ) / static_cast<value_type>( 13824.0 ); const value_type b64 = static_cast<value_type> ( 44275.0 ) / static_cast<value_type>( 110592.0 ); const value_type b65 = static_cast<value_type> ( 253.0 ) / static_cast<value_type>( 4096.0 ); const value_type c1 = static_cast<value_type> ( 37.0 ) / static_cast<value_type>( 378.0 ); const value_type c3 = static_cast<value_type> ( 250.0 ) / static_cast<value_type>( 621.0 ); const value_type c4 = static_cast<value_type> ( 125.0 ) / static_cast<value_type>( 594.0 ); const value_type c6 = static_cast<value_type> ( 512.0 ) / static_cast<value_type>( 1771.0 ); typename detail::unwrap_reference< System >::type &sys = system; m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) ); //m_x1 = x + dt*b21*dxdt stepper_base_type::m_algebra.for_each3( m_x_tmp.m_v , in , dxdt , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , dt*b21 ) ); sys( m_x_tmp.m_v , m_k2.m_v , t + dt*a2 ); // m_x_tmp = x + dt*b31*dxdt + dt*b32*m_x2 stepper_base_type::m_algebra.for_each4( m_x_tmp.m_v , in , dxdt , m_k2.m_v , typename operations_type::template scale_sum3< value_type , time_type , time_type >( 1.0 , dt*b31 , dt*b32 )); sys( m_x_tmp.m_v , m_k3.m_v , t + dt*a3 ); // m_x_tmp = x + dt * (b41*dxdt + b42*m_x2 + b43*m_x3) stepper_base_type::m_algebra.for_each5( m_x_tmp.m_v , in , dxdt , m_k2.m_v , m_k3.m_v , typename operations_type::template scale_sum4< value_type , time_type , time_type , time_type >( 1.0 , dt*b41 , dt*b42 , dt*b43 )); sys( m_x_tmp.m_v, m_k4.m_v , t + dt*a4 ); stepper_base_type::m_algebra.for_each6( m_x_tmp.m_v , in , dxdt , m_k2.m_v , m_k3.m_v , m_k4.m_v , typename operations_type::template scale_sum5< value_type , time_type , time_type , time_type , time_type >( 1.0 , dt*b51 , dt*b52 , dt*b53 , dt*b54 )); sys( m_x_tmp.m_v , m_k5.m_v , t + dt*a5 ); stepper_base_type::m_algebra.for_each7( m_x_tmp.m_v , in , dxdt , m_k2.m_v , m_k3.m_v , m_k4.m_v , m_k5.m_v , typename operations_type::template scale_sum6< value_type , time_type , time_type , time_type , time_type , time_type >( 1.0 , dt*b61 , dt*b62 , dt*b63 , dt*b64 , dt*b65 )); sys( m_x_tmp.m_v , m_k6.m_v , t + dt*a6 ); stepper_base_type::m_algebra.for_each6( out , in , dxdt , m_k3.m_v , m_k4.m_v , m_k6.m_v , typename operations_type::template scale_sum5< value_type , time_type , time_type , time_type , time_type >( 1.0 , dt*c1 , dt*c3 , dt*c4 , dt*c6 )); }
void sub_bridge_display::post_display(game& gm) const { sys().prepare_2d_drawing(); if (glasses_in_use) { glasses_tex->draw(0, 0, 1024, 768); } ui.draw_infopanel(true); sys().unprepare_2d_drawing(); }
void sub_valves_display::display(class game& gm) const { sys().prepare_2d_drawing(); background->draw(0, 0); ui.draw_infopanel(); sys().unprepare_2d_drawing(); }
freeview_display::projection_data sub_bridge_display::get_projection_data(game& gm) const { projection_data pd = freeview_display::get_projection_data(gm); if (glasses_in_use) { pd.x = 0; pd.y = 0; pd.w = sys().get_res_x(); pd.h = sys().get_res_x(); pd.fov_x = 20.0; } return pd; }
void do_step_impl( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt ) { // ToDo : check if size of in,dxdt,out are equal? static const value_type val1 = static_cast< value_type >( 1 ); m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) ); typename odeint::unwrap_reference< System >::type &sys = system; const time_type dh = dt / static_cast< value_type >( 2 ); const time_type th = t + dh; // dt * dxdt = k1 // m_x_tmp = x + dh*dxdt stepper_base_type::m_algebra.for_each3( m_x_tmp.m_v , in , dxdt , typename operations_type::template scale_sum2< value_type , time_type >( val1 , dh ) ); // dt * m_dxt = k2 sys( m_x_tmp.m_v , m_dxt.m_v , th ); // m_x_tmp = x + dh*m_dxt stepper_base_type::m_algebra.for_each3( m_x_tmp.m_v , in , m_dxt.m_v , typename operations_type::template scale_sum2< value_type , time_type >( val1 , dh ) ); // dt * m_dxm = k3 sys( m_x_tmp.m_v , m_dxm.m_v , th ); //m_x_tmp = x + dt*m_dxm stepper_base_type::m_algebra.for_each3( m_x_tmp.m_v , in , m_dxm.m_v , typename operations_type::template scale_sum2< value_type , time_type >( val1 , dt ) ); // dt * m_dxh = k4 sys( m_x_tmp.m_v , m_dxh.m_v , t + dt ); //x += dt/6 * ( m_dxdt + m_dxt + val2*m_dxm ) time_type dt6 = dt / static_cast< value_type >( 6 ); time_type dt3 = dt / static_cast< value_type >( 3 ); stepper_base_type::m_algebra.for_each6( out , in , dxdt , m_dxt.m_v , m_dxm.m_v , m_dxh.m_v , typename operations_type::template scale_sum5< value_type , time_type , time_type , time_type , time_type >( 1.0 , dt6 , dt3 , dt3 , dt6 ) ); // x += dt/6 * m_dxdt + dt/3 * m_dxt ) // stepper_base_type::m_algebra.for_each4( out , in , dxdt , m_dxt.m_v , // typename operations_type::template scale_sum3< value_type , time_type , time_type >( 1.0 , dt6 , dt3 ) ); // // x += dt/3 * m_dxm + dt/6 * m_dxh ) // stepper_base_type::m_algebra.for_each4( out , out , m_dxm.m_v , m_dxh.m_v , // typename operations_type::template scale_sum3< value_type , time_type , time_type >( 1.0 , dt3 , dt6 ) ); }
freeview_display::projection_data sub_uzo_display::get_projection_data(class game& gm) const { projection_data pd; pd.x = sys().get_res_area_2d_x(); pd.y = sys().get_res_area_2d_y(); pd.w = sys().get_res_area_2d_w(); pd.h = sys().get_res_area_2d_h(); // with normal fov of 70 degrees, this is 1.5 / 6.0 magnification pd.fov_x = zoomed ? 13.31 : 50.05; //fixme: historic values? pd.near_z = 1.0; pd.far_z = gm.get_max_view_distance(); pd.fullscreen = true; return pd; }
void do_step( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt , state_type &x_mp , deriv_table_type &derivs ) { static const value_type val1 = static_cast< value_type >( 1 ); static const value_type val05 = static_cast< value_type >( 1 ) / static_cast< value_type >( 2 ); m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize< StateIn > , detail::ref( *this ) , detail::_1 ) ); const time_type h = dt / static_cast<value_type>( m_steps ); const time_type h2 = static_cast<value_type>( 2 ) * h; typename odeint::unwrap_reference< System >::type &sys = system; time_type th = t + h; // m_x1 = x + h*dxdt m_algebra.for_each3( m_x1.m_v , in , dxdt , typename operations_type::template scale_sum2< value_type , time_type >( val1 , h ) ); if( m_steps == 2 ) // result of first step already gives approximation at the center of the interval boost::numeric::odeint::copy( m_x1.m_v , x_mp ); sys( m_x1.m_v , derivs[0].m_v , th ); boost::numeric::odeint::copy( in , m_x0.m_v ); unsigned short i = 1; while( i != m_steps ) { // general step //tmp = m_x1; m_x1 = m_x0 + h2*m_dxdt; m_x0 = tmp m_algebra.for_each3( m_x1.m_v , m_x0.m_v , derivs[i-1].m_v , typename operations_type::template scale_sum_swap2< value_type , time_type >( val1 , h2 ) ); if( i == m_steps/2-1 ) // save approximation at the center of the interval boost::numeric::odeint::copy( m_x1.m_v , x_mp ); th += h; sys( m_x1.m_v , derivs[i].m_v , th); i++; } // last step // x = 0.5*( m_x0 + m_x1 + h*m_dxdt ) m_algebra.for_each4( out , m_x0.m_v , m_x1.m_v , derivs[m_steps-1].m_v , typename operations_type::template scale_sum3< value_type , value_type , time_type >( val05 , val05 , val05*h ) ); }
int token(char *buf){ if (!strlen(buf)) return 0; char *token = strtok(buf," "); if (!token) return 0; int i=0; char **argList = (char**) malloc(sizeof(char*) * 130); while(token != NULL) { argList[i] = (char*)malloc(sizeof(char) * strlen(token)); strcpy(argList[i],token); token = strtok(NULL," "); i=i+1; } argList[i]=NULL; if (strcmp(argList[0], "cd") == 0){ cd(argList[1]); } else if (strcmp(argList[0], "exit") == 0){ exit(0); } else{ sys(argList); } for(i=i-1;i>=0;i--) free(argList[i]); free(argList); return 0; }
void test_particle_update() { Vector3d object(3.35, -1.11, 0.8); Arm::ArmType arm_type = Arm::ArmType::right; bool view = true; PR2System sys(object, arm_type, view); PR2* brett = sys.get_brett(); Arm* arm = sys.get_arm(); rave::EnvironmentBasePtr env = brett->get_env(); sleep(2); arm->set_posture(Arm::Posture::mantis); // setup scenario VectorJ j_t_real = arm->get_joint_values(), j_tp1_real; VectorJ j_t = j_t_real, j_tp1; // i.e. no belief == actual VectorU u_t = VectorU::Zero(); MatrixP P_t = setup_particles(env), P_tp1; LOG_INFO("Origin particles"); std::vector<ParticleGaussian> particle_gmm_t; sys.fit_gaussians_to_pf(P_t, particle_gmm_t); sys.display(j_t, particle_gmm_t); sys.execute_control_step(j_t_real, j_t, u_t, P_t, j_tp1_real, j_tp1, P_tp1); LOG_INFO("New particles") std::vector<ParticleGaussian> particle_gmm_tp1; sys.fit_gaussians_to_pf(P_tp1, particle_gmm_tp1); sys.display(j_tp1, particle_gmm_tp1); }
// Does tests for time/steps = 1, 2. time/step = 0 is given. void oneBodyTest( void (*integrator_ptr)( nbody::Body**, size_t, float ), float dt, Vector3f pos_vec3f, Vector3f vel_vec3f, Vector3f force_vec3f, float assert1_pos_x, float assert1_pos_y, float assert1_pos_z, float assert1_vel_x, float assert1_vel_y, float assert1_vel_z, float assert1_force_x, float assert1_force_y, float assert1_force_z, float assert2_pos_x, float assert2_pos_y, float assert2_pos_z, float assert2_vel_x, float assert2_vel_y, float assert2_vel_z, float assert2_force_x, float assert2_force_y, float assert2_force_z ) { nbody::Body **body_ptr = new nbody::Body*[1]; body_ptr[0] = new nbody::Body[1]; (*body_ptr)[0].position() = pos_vec3f; (*body_ptr)[0].velocity() = vel_vec3f; (*body_ptr)[0].force() = force_vec3f; nbody::System sys( *body_ptr, 1 ); sys.update( *integrator_ptr, dt ); makeAssertions( body_ptr, 0, assert1_pos_x, assert1_pos_y, assert1_pos_z, assert1_vel_x, assert1_vel_y, assert1_vel_z, assert1_force_x, assert1_force_y, assert1_force_z ); sys.update( *integrator_ptr, dt ); makeAssertions( body_ptr, 0, assert2_pos_x, assert2_pos_y, assert2_pos_z, assert2_vel_x, assert2_vel_y, assert2_vel_z, assert2_force_x, assert2_force_y, assert2_force_z ); }
void basicEntitySystemTest() { // Generate entity system core. std::shared_ptr<es::ESCore> core(new es::ESCore()); // Test that adding BasicSystem also adds component containers for all data // components. core->addSystem(new BasicSystem()); uint64_t id = core->getNewEntityID(); core->addComponent(id, posComponents[id]); core->addComponent(id, homPosComponents[id]); core->addComponent(id, gameplayComponents[id]); id = core->getNewEntityID(); core->addComponent(id, homPosComponents[id]); core->addComponent(id, gameplayComponents[id]); BasicSystem::invalidComponents.insert(std::make_pair(id, true)); id = core->getNewEntityID(); core->addComponent(id, posComponents[id]); core->addComponent(id, homPosComponents[id]); core->addComponent(id, gameplayComponents[id]); id = core->getNewEntityID(); core->addComponent(id, posComponents[id]); core->addComponent(id, homPosComponents[id]); core->addComponent(id, gameplayComponents[id]); std::shared_ptr<BasicSystem> sys(new BasicSystem); core->renormalize(); sys->walkComponents(*core); }
int main() { printf("%s%c%c\n","Content-Type:text/html;charset=iso-8859-1",13,10); char *data = getenv("QUERY_STRING"); if(data == NULL) { printf("<html><head><title>Input Error</title></head><body bgcolor=\"Red\">Error, could not read from login.c</body></html>"); exit(EXIT_FAILURE); } char type[50]; char SYS[10]="SYSTEM"; char USE[10]="USER"; sscanf(data,"type=%[^&]&", type); //printf("%s,%s<br />",data,type); if (!strcmp(type,SYS)) { sys(data); } else if(!strcmp(type,USE)) { user(data); } else { printf("<html><head><title>Input Error</title></head><body bgcolor=\"Red\">UNDEFINED USER TYPE</body></html>"); exit(EXIT_FAILURE); } }
void jsb_register_system( JSContext *_cx, JS::HandleObject object) { // // sys // JS::RootedObject proto(_cx); JS::RootedObject parent(_cx); JS::RootedObject sys(_cx, JS_NewObject(_cx, nullptr, proto, parent)); JS::RootedValue systemVal(_cx); systemVal.set(OBJECT_TO_JSVAL(sys)); JS_SetProperty(_cx, object, "sys", systemVal); // sys.localStorage JSObject *ls = JS_NewObject(_cx, nullptr, proto, parent); JS::RootedValue lsVal(_cx); lsVal.set(OBJECT_TO_JSVAL(ls)); JS_SetProperty(_cx, sys, "localStorage", lsVal); // sys.localStorage functions JS::RootedObject system(_cx, ls); #include "scripting/js-bindings/manual/localstorage/js_bindings_system_functions_registration.h" // Init DB with full path //NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; //NSString *fullpath = [path stringByAppendingPathComponent:@"jsb.sqlite"]; std::string strFilePath = cocos2d::FileUtils::getInstance()->getWritablePath(); strFilePath += "/jsb.sqlite"; localStorageInit(strFilePath); }
void NonlinearSystem::stopSolve() { #ifdef LIBMESH_HAVE_PETSC #if PETSC_VERSION_LESS_THAN(3, 0, 0) #else PetscNonlinearSolver<Real> & solver = static_cast<PetscNonlinearSolver<Real> &>(*sys().nonlinear_solver); SNESSetFunctionDomainError(solver.snes()); #endif #endif // Insert a NaN into the residual vector. As of PETSc-3.6, this // should make PETSc return DIVERGED_NANORINF the next time it does // a reduction. We'll write to the first local dof on every // processor that has any dofs. _transient_sys.rhs->close(); if (_transient_sys.rhs->local_size()) _transient_sys.rhs->set(_transient_sys.rhs->first_local_index(), std::numeric_limits<Real>::quiet_NaN()); _transient_sys.rhs->close(); // Clean up by getting other vectors into a valid state for a // (possible) subsequent solve. There may be more than just // these... if (_Re_time) _Re_time->close(); _Re_non_time->close(); }
void test_pr2_system() { Vector3d object(3.35, -1.11, 0.8); Arm::ArmType arm_type = Arm::ArmType::right; bool view = true; PR2System sys(object, arm_type, view); PR2* brett = sys.get_brett(); Arm* arm = sys.get_arm(); rave::EnvironmentBasePtr env = brett->get_env(); sleep(2); arm->set_posture(Arm::Posture::mantis); // setup particles MatrixP P = setup_particles(env); // test plotting VectorJ j = arm->get_joint_values(); std::vector<ParticleGaussian> particle_gmm; particle_gmm.push_back(ParticleGaussian(Vector3d::Zero(), Matrix3d::Identity(), P.leftCols(M_DIM/2), 1)); particle_gmm.push_back(ParticleGaussian(Vector3d::Zero(), Matrix3d::Identity(), P.rightCols(M_DIM/2), 1)); sys.display(j, particle_gmm); }
controlled_step_result try_step_v1( System system , StateInOut &x , time_type &t , time_type &dt ) { typename boost::unwrap_reference< System >::type &sys = system; m_dxdt_resizer.adjust_size( x , boost::bind( &generic_controlled_stepper::template resize_m_dxdt_impl< StateInOut > , boost::ref( *this ) , _1 ) ); sys( x , m_dxdt.m_v ,t ); return try_step( system , x , m_dxdt.m_v , t , dt ); }
void test_figtree() { Vector3d object(3.35, -1.11, 0.8); Arm::ArmType arm_type = Arm::ArmType::right; bool view = true; PR2System sys(object, arm_type, view); PR2* brett = sys.get_brett(); Arm* arm = sys.get_arm(); rave::EnvironmentBasePtr env = brett->get_env(); arm->set_posture(Arm::Posture::mantis); sleep(1); MatrixP P = setup_particles(env); std::vector<ParticleGaussian> particle_gmm; tc.start("figtree"); sys.fit_gaussians_to_pf(P, particle_gmm); tc.stop("figtree"); std::cout << "particle_gmm size: " << particle_gmm.size() << "\n"; for(int i=0; i < particle_gmm.size(); ++i) { std::cout << "mean: " << particle_gmm[i].mean.transpose() << "\n"; std::cout << "cov diag: " << particle_gmm[i].cov.diagonal().transpose() << "\n"; std::cout << "pct: " << particle_gmm[i].pct << "\n"; } tc.print_all_elapsed(); sys.display(arm->get_joint_values(), particle_gmm); }
void do_step( System system , const StateIn &in , time_type t , StateOut &out , time_type dt ) { typename omplext_odeint::unwrap_reference< System >::type &sys = system; m_resizer.adjust_size( in , detail::bind( &internal_stepper_base_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) ); sys( in , m_dxdt.m_v ,t ); this->stepper().do_step_impl( system , in , m_dxdt.m_v , t , out , dt ); }
int main(int argc, char **argv) { Term terminal; RegisterSystem sys(&terminal); //Execute System sys.exec(); return 0; }
void TestSolver::circle2() { const ExprSymbol& x=ExprSymbol::new_("x"); const ExprSymbol& y=ExprSymbol::new_("y"); SystemFactory f; f.add_var(x); f.add_var(y); f.add_ctr(sqr(x)+sqr(y)=1); f.add_ctr(sqr(x-2)+sqr(y)=1); double _sol1[]={1,0}; Vector sol1(2,_sol1); System sys(f); RoundRobin rr(1e-3); CellStack stack; CtcHC4 hc4(sys); Vector prec(2,1e-3); Solver solver(sys,hc4,rr,stack,prec,prec); solver.start(IntervalVector(2,Interval(-10,10))); CovSolverData::BoxStatus status; bool res=solver.next(status); CPPUNIT_ASSERT(res); CPPUNIT_ASSERT(status==CovSolverData::UNKNOWN); CPPUNIT_ASSERT(solver.get_data().nb_unknown()==1); CPPUNIT_ASSERT(solver.get_data().unknown(0).is_superset(sol1)); res=solver.next(status); CPPUNIT_ASSERT(!res); }
void do_step_v5( System system , StateInOut &x , time_type t , time_type dt , Err &xerr ) { typename odeint::unwrap_reference< System >::type &sys = system; m_resizer.adjust_size( x , detail::bind( &internal_stepper_base_type::template resize_impl<StateInOut> , detail::ref( *this ) , detail::_1 ) ); sys( x , m_dxdt.m_v ,t ); this->stepper().do_step_impl( system , x , m_dxdt.m_v , t , x , dt , xerr ); }
int main(int argc, char **argv) { vctr x0(2); vctr u(1); x0.at(0)=0.1; x0.at(1)=0.0; u.at(0)=0.0; double dt_max=0.1; double state_dim=2; double control_dim=1; double tspan=2.0*M_PI; RK4 sys(&flow,dt_max,state_dim,control_dim); traj sol = sys.sim(tspan,x0,u); sys.print_traj(sol); printf("cost: %f\n",cost(sol)); //Plot result vctr path(sol.time.size()); for(int i=0;i<sol.path.size();i++) { path.at(i)=sol.path[i][0]; } plt::plot(sol.time,path); plt::xlim(0, (int) ceil(sol.time.back())); plt::show(); //plt::save("./basic.png"); return 0; }
void do_step_impl( System system , const StateIn &in , const PredIn &pred , time_type t , StateOut &out , time_type dt , const ABBuf &buf ) { typename odeint::unwrap_reference< System >::type &sys = system; m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) ); sys( pred , m_dxdt.m_v , t ); detail::adams_moulton_call_algebra< steps , algebra_type , operations_type >()( m_algebra , in , out , m_dxdt.m_v , buf , m_coefficients , dt ); }
void backup_best(string path, string name) { string backup_command = "ln " + path + name + ".flm " + path + "best.flm;" + "ln " + path + name + ".count.gz " + path + "best.count.gz;" + "ln " + path + name + ".lm.gz " + path + "best.lm.gz;"; sys(backup_command); }
bool ParticleEffect::_CreateEffect() { // The effect isn't loaded, so we can't create the effect. if(!IsLoaded()) return false; // Initialize systems _systems.clear(); std::vector<ParticleSystemDef>::iterator it = _effect_def._systems.begin(); for(; it != _effect_def._systems.end(); ++it) { if((*it).enabled) { ParticleSystem sys(&(*it)); if(!sys.IsAlive()) { // If a system could not be created then we bail out _systems.clear(); IF_PRINT_WARNING(VIDEO_DEBUG) << "sys->Create() returned false while trying to create effect!" << std::endl; return false; } _systems.push_back(sys); } } _alive = true; _age = 0.0f; return true; }
ThemeLoader::ThemeLoader(QObject* parent) : QObject(parent) { ThemeInfo info; if (!info.load(":/themes/cute/cute.theme")) qWarning() << "Failed to load cute.theme"; d.themes.append(info.name()); d.infos.insert(info.name(), info); QDir inst(COMMUNI_INSTALL_THEMES); if (inst.exists()) load(inst); #if defined(Q_OS_MAC) QDir dir(QApplication::applicationDirPath()); if (dir.dirName() == "MacOS" && dir.cd("../Resources/themes")) load(dir); #elif defined(Q_OS_WIN) QDir dir(QApplication::applicationDirPath()); if (dir.cd("themes") || (dir.cdUp() && dir.cd("themes"))) load(dir); #elif defined(Q_OS_UNIX) QDir sys("/usr/share/themes/communi"); if (sys != inst && sys.exists()) load(sys); QDir home = QDir::home(); if (home.cd(".local/share/themes/communi")) load(home); QDir dev(QApplication::applicationDirPath()); if (dev.cdUp() && dev.cd("themes")) load(dev); #endif }
int main(int argc, char* argv[]) { // load the mesh file Mesh mesh; mesh.load("domain.mesh"); mesh.refine_element(0); // create an H1 space H1Space space(&mesh); space.set_uniform_order(5); // set up the weak formulation WeakForm wf; wf.set_eqn("[u,v] = (2*v)"); PardisoSolver solver; Solution sln; // assemble and solve the linear system LinSystem sys(&wf, &solver); sys.set_spaces(1, &space); sys.assemble(); sys.solve(1, &sln); // show the result ScalarView view("Solution"); view.show(&sln); return 0; }
void test_fk() { Vector3d object(3.35, -1.11, 0.8); Arm::ArmType arm_type = Arm::ArmType::right; bool view = true; PR2System sys(object, arm_type, view); PR2* brett = sys.get_brett(); Arm* arm = sys.get_arm(); Camera* cam = sys.get_camera(); rave::EnvironmentBasePtr env = brett->get_env(); arm->set_posture(Arm::Posture::mantis); sleep(1); VectorJ j = arm->get_joint_values(); Matrix4d actual_arm_pose = rave_utils::transform_from_to(brett->get_robot(), Matrix4d::Identity(), "r_gripper_tool_frame", "world"); Matrix4d fk_arm_pose = arm->get_pose(j); std::cout << "actual_arm_pose:\n" << actual_arm_pose << "\n\n"; std::cout << "fk_arm_pose:\n" << fk_arm_pose << "\n\n"; Matrix4d actual_cam_pose = rave_utils::rave_to_eigen(cam->get_sensor()->GetTransform()); Matrix4d fk_cam_pose = cam->get_pose(j); std::cout << "actual_cam_pose:\n" << actual_cam_pose << "\n\n"; std::cout << "fk_cam_pose:\n" << fk_cam_pose << "\n\n"; }