/** * Simulates the timestep for the capsule. * @param timestep The step length in ms. * @param capsule The capsule, that is the projectile in the world. */ void ProjectileSplitting::step( int timestep, BodyProjectile &capsule ) { Vector velocity( capsule.getVelocity() ); float splitAngle = M_PI * this->parameters.getParameterValue( this->indexSplittingAngle ) / 180.0; float stepAngle = splitAngle / this->splitCount; velocity.scale( this->splittingVelocity / velocity.getLength() ); velocity.rotate( ( stepAngle - splitAngle ) / 2 ); if ( this->timeLived >= this->parameters.getParameterValue( this->indexSplittingTime ) ) { for ( int i = 0; i < this->splitCount; i++ ) { Projectile *model = this->splittingProjectile.getCopy(); model->setShooter( this->getShooter() ); BodyProjectile *newProjectile = new BodyProjectile( capsule.getWorld(), capsule.getLocation().getX(), capsule.getLocation().getY(), *model ); newProjectile->setVelocity( capsule.getVelocity().getX() + velocity.getX(), capsule.getVelocity().getY() + velocity.getY() ); velocity.rotate( stepAngle ); newProjectile->setActionFlag( capsule.getActionFlag() ); capsule.getWorld().addBody( *newProjectile ); } capsule.destroy(); } Projectile::step( timestep, capsule ); }
void findLine(void) { nodeMissEnable = 0; int tempLeftCount = ShaftCountLeft; int tempRightCount = ShaftCountRight; velocity(180, 150); sensorRight = ADC_Conversion(1); left(); while(sensorRight < 20) { centre = ADC_Conversion(2); if(centre > 30) { forward(); nodeMissEnable = 1; return; } sensorRight = ADC_Conversion(1); } stop(); _delay_ms(100); sensorLeft = ADC_Conversion(3); right(); while(sensorLeft < 20) { centre = ADC_Conversion(2); if(centre > 30) { forward(); nodeMissEnable = 1; return; } sensorLeft = ADC_Conversion(3); } ShaftCountLeft = tempLeftCount; ShaftCountRight = tempRightCount; nodeMissEnable = 1; }
//------------------------------------------------------------------------------ // protected: //------------------------------------------------------------------------------ void Cloud::doInit() { if ( m_black ) { m_sprite = Engine::rm()->GetSprite( BLACK[m_size] ); } else { m_sprite = Engine::rm()->GetSprite( WHITE[m_size] ); } m_zoom = 0; m_life = 4.0f; b2BodyDef bodyDef; bodyDef.userData = static_cast<void*> (this); m_body = Engine::b2d()->CreateDynamicBody(&bodyDef); b2CircleDef shapeDef; shapeDef.radius = 0.5f * 0.95f * m_sprite->GetWidth() * m_scale; shapeDef.density = 10.0f; shapeDef.friction = 0.0f; shapeDef.restitution = 1.0f; if ( m_size == 0 ) { shapeDef.density = 0.001f; } m_body->CreateShape(&shapeDef); m_body->SetMassFromShapes(); m_body->m_linearDamping = 0.0f; if ( m_size == 0 ) { m_body->m_linearDamping = 0.99f; m_body->m_angularDamping = 0.8f; } m_body->m_angularDamping = 0.0f; float spin( 5.0f / static_cast<float>(m_size + 1.0f) ); m_body->SetAngularVelocity( Engine::hge()->Random_Float( -spin, spin ) ); float speed( SPEED[m_size] ); b2Vec2 velocity( Engine::hge()->Random_Float( -speed, speed ), Engine::hge()->Random_Float( -speed, speed ) ); m_body->SetLinearVelocity( velocity ); }
//************************************************************************************************************* void Update(float delta) { D3DXVECTOR2 velocity(mousedx, mousedy); cameraangle.prev = cameraangle.curr; if( mousedown == 1 ) cameraangle.curr += velocity * 0.004f; // clamp to [-pi, pi] if( cameraangle.curr.y >= 1.5f ) cameraangle.curr.y = 1.5f; if( cameraangle.curr.y <= -1.5f ) cameraangle.curr.y = -1.5f; system1.Update(); }
void ParticleEmitterCircle::Update(GLfloat delta) { m_currentDelay+=delta; while(m_currentDelay>=m_spawnDelay) { m_currentDelay-=m_spawnDelay; Particle *pParticle=new Particle; pParticle->m_position=m_position; pParticle->m_angularVelocity=Core::Random::Double(m_minAngularVelocity,m_maxAngularVelocity); pParticle->m_maxLife=Core::Random::Double(m_minParticleLife,m_maxParticleLife); pParticle->m_life=pParticle->m_maxLife; pParticle->m_texture=m_texture; Vector2f velocity(1.0f,0.0f); velocity.Rotate(Core::Random::Double(0.0f,360.0f)); pParticle->m_velocity=velocity*Core::Random::Double(m_minVelocity,m_maxVelocity); pParticle->m_modifiers=&m_modifiers; } }
void AddParticleStartingAt(Vec4<float> WorldPoint) { ParticleSystem* ps = ModelerApplication::Instance()->GetParticleSystem(); for (int i = 0; i < VAL(PARTICLE_COUNT) * 5 ; i++) { float mag = rand() % 10 / 10.0 + 0.2; float theta = rand() % 360 / 57.3; float yVelocity = rand() % 10 / 10.0 + 2; float xVelocity = cos(theta) * mag; float zVelocity = sin(theta) * mag * 3; //printf("add: %f, %f, %f\n", WorldPoint[0], WorldPoint[1], WorldPoint[2]); Vec3f position(WorldPoint[0], WorldPoint[1], WorldPoint[2]); Vec3f velocity(xVelocity, 5, zVelocity); Particle* p = new PointObj(1.0f, position, velocity); //printf("added: %f, %f, %f\n", p->getPosition()[0], p->getPosition()[1], p->getPosition()[2]); ps->addParticle(p); } }
DOUBLE2 MassProjList::HandleCircularCollision(DOUBLE2 otherCirclePos,DOUBLE2 otherCircleVelocity, double radius, double mass) { DOUBLE2 velocity(0,0), newVelocity(0,0); velocity=otherCircleVelocity; for (int count=0; count < MAX_MASSPROJECTILES; ++count) { if (m_MassProjectilePtrArr[count] != nullptr) { newVelocity=m_MassProjectilePtrArr[count]->HandleCircularCollision(otherCirclePos,velocity ,radius, mass ); if (newVelocity!=DOUBLE2(0,0)) velocity= newVelocity; } } return velocity; }
Vec3D<> CVX_Voxel::force() { //forces from internal bonds Vec3D<> totalForce(0,0,0); for (int i=0; i<6; i++){ if (links[i]) totalForce += links[i]->force(isNegative((linkDirection)i)); //total force in LCS } totalForce = orient.RotateVec3D(totalForce); //other forces totalForce += extForce; //external forces totalForce -= velocity()*mat->globalDampingTranslateC(); //global damping if (isGravityEnabled()) totalForce.z -= mat->_mass*9.80665; //gravity, according to f=mg if (isFloorEnabled()) addFloorForces(&totalForce); //adds forces from interacting with the floor //Collisions: todo return totalForce; }
//figures out what needs to happen at an intersection based on the direction we want to turn void Robot::handleIntersection(Direction direction){ switch (direction) { case StraightAhead: break; case Left: Tape::resetErrors(); resetVelocity(); turnAtIntersection(false, millis()); break; case Right: Tape::resetErrors(); resetVelocity(); turnAtIntersection(true, millis()); break; case TurnAround: Tape::resetErrors(); resetVelocity(); turnOntoTape(direction); break; case SlightRight: Actuators::drive(velocity(), SLIGHT_RIGHT_AT_SPECIAL_INTERSECTION_TURN); delay(SLIGHT_RIGHT_AT_SPECIAL_INTERSECTION_DURATION); Tape::resetErrors(); resetVelocity(); findTape(); break; case SlightLeft: Actuators::drive(VELOCITY_SLOW, -SLIGHT_LEFT_AT_SPECIAL_INTERSECTION_TURN); delay(SLIGHT_LEFT_AT_SPECIAL_INTERSECTION_DURATION); Tape::resetErrors(); resetVelocity(); findTape(); break; } }
void Emitter::prepareParticles(){ // Shotgun stuff if(hasFired && isShotgun){ return; } hasFired = true; for(int i(0); i < density; ++i){ // Shitty random generation for now float rand1 = ((rand()%100)/100.0f)-0.5f; float rand2 = ((rand()%100)/100.0f)-0.5f; float rand3 = ((rand()%100)/100.0f)-0.5f; glm::vec3 position(-1.3f+rand1, 0.0f, rand2); // Emitter parented to camera // position+=camera->getPosition(); glm::vec3 velocity(0.0f, 0.01f+(0.01f*rand3), 0.0f); glm::vec3 acceleration(0.0f, 0.0f, 0.0f); // Random wind interaction for snow particles. // if (rand() % 1000){ // velocity += glm::vec3(0.001 * (rand() % 5), - abs(0.0005 * (rand() % 5)), 0.001 * (rand() % 5)); // } float rotation = 0.0f; // Particle recycling! // Weird that the pointer must be explicitly set to 0, but crashes without this Particle* ptr = 0; if(particles.size() < maxParticles){ ptr = new Particle(*billboard, shader); ptr->setEmissive(particle_texture); } if(particles.size() > 0 && particles[0]->isDead()){ ptr = particles[0]; particles.pop_front(); } if(ptr){ ptr->setInitialValues(position, velocity, acceleration, rotation, lifespan, Particle::ScalingOption::SCALE_DOWN_WITH_AGE, Particle::FadingOption::FADE_NONE); particles.push_back(ptr); } } }
int collision_time(double *pos, double *vel, double h, double r, double *tcoll, double *cup){ int result, napproaches, i; double tpos[3], tvel[3], poly[DEGSIZE], tcloseapproaches[2]; int event = RESULT_NOTHING; double tevent = NAN; // find where the trajectory intersects the z=h plane build_plane_poly(pos, vel, r, poly); find_all_roots(poly, 2, tcloseapproaches, &napproaches); for (i=0; i<napproaches; i++){ if (tcloseapproaches[i] < 0) continue; position(pos, vel, tcloseapproaches[i], tpos); velocity(vel, tcloseapproaches[i], tvel); result = collision_near(tpos, tvel, h, r, tcoll, cup); *tcoll = *tcoll + tcloseapproaches[i]; if (result == RESULT_COLLISION || result == RESULT_INCUP){ if ((isnan(tevent) || tevent > *tcoll) && *tcoll > 0){ event = result; tevent = *tcoll; } } } result = collision_near(pos, vel, h, r, tcoll, cup); if (result == RESULT_COLLISION || result == RESULT_INCUP){ if ((isnan(tevent) || tevent > *tcoll) && *tcoll > 0){ event = result; tevent = *tcoll; } } if (event == RESULT_NOTHING){ build_zero_poly(pos, vel, poly); find_all_roots(poly, 2, tcloseapproaches, &napproaches); tevent = tcloseapproaches[0] > 0 ? tcloseapproaches[0] : tcloseapproaches[1]; } *tcoll = tevent; return event; }
void ViewportScrollCallback::handleEvent(ScrollState* state) { DCHECK(state); if (!m_rootFrameViewport) return; bool browserControlsDidScroll = scrollBrowserControls(*state); ScrollResult result = performNativeScroll(*state); // We consider browser controls movement to be scrolling. result.didScrollY |= browserControlsDidScroll; // Handle Overscroll. if (m_overscrollController) { FloatPoint position(state->positionX(), state->positionY()); FloatSize velocity(state->velocityX(), state->velocityY()); m_overscrollController->handleOverscroll(result, position, velocity); } }
void spin(int which, int direction) { int lVel, rVel; switch (direction) { case CLOCKWISE : lVel = (int)(48 * gSpinVelocityScaling + 0.5); //rVel = (int)(-48 * gSpinVelocityScaling + 0.5); rVel = -lVel; break; case ANTICLOCKWISE : rVel = (int)(48 * gSpinVelocityScaling + 0.5); //lVel = (int)(-48 * gSpinVelocityScaling + 0.5); lVel = -rVel; break; } velocity(which, lVel, rVel); return; } //---- spin()
/** * returns current status of particle set in a general form * * \return filled particle vector */ const ParticleSet& getParticleSet( base::Vector3d transformation = base::Vector3d::Zero()) { assert(particles.size() > 0); ps.particles.clear(); ps.timestamp = timestamp; for(ParticleIterator it = particles.begin(); it != particles.end(); it++) { Particle p; p.position = position(*it) + transformation; p.velocity = velocity(*it); p.yaw = base::getYaw(orientation(*it).orientation); p.main_confidence = confidence(*it); ps.particles.push_back(p); } return ps; }
Manager::Manager() : env( SDL_putenv(const_cast<char*>("SDL_VIDEO_CENTERED=center")) ), gdata( Gamedata::getInstance() ), drawTheStupidHud(false), io( IOManager::getInstance() ), clock( ), screen( io->getScreen() ), clouds( SpriteFrameFactory::getInstance()->getFrame("back", "back"), 2 ), hills( SpriteFrameFactory::getInstance()->getFrame("hill", "hill"), 1 ), ghostbcknd(SpriteFrameFactory::getInstance()->getFrame("ghostbcknd", "ghostbcknd"), 1 ), view(Viewport::getInstance()), pter( NULL ), pterleft(NULL), var1(0), var2(0), gui(), remainingTime(60), orbs() { if (SDL_Init(SDL_INIT_VIDEO) != 0) { throw string("Unable to initialize SDL: "); } Vector2f position(gdata->getXmlInt("pterX"), gdata->getXmlInt("pterY")); Vector2f velocity(gdata->getXmlInt("pterXspeed"), gdata->getXmlInt("pterYspeed")); pter = new MultiSprite(position, velocity, MultiSpriteFrameFactory::getInstance()->getFrame("pter","pter"), "pter"); pterleft= new MultiSprite(position, velocity, MultiSpriteFrameFactory::getInstance()->getFrame("pterleft","pterleft"), "pterleft"); orbs.pter = pter; orbs.pterLeft = pterleft; view->setObjectToTrack(pter); atexit(SDL_Quit); SDL_WM_SetCaption( "*** CpSc 870: Nikhil Bendre - Ghost Busters ***", NULL ); }
void PbfSolver::ImposeBoundaryConstraint_() { const vec_t world_sz_dim{world_size_x_, world_size_y_, world_size_z_}; for (size_t ptc_i = 0; ptc_i < ps_->NumParticles(); ++ptc_i) { auto ptc = ps_->Get(ptc_i); auto pos = ptc.position(); auto vel = ptc.velocity(); for (int c = 0; c < 3; ++c) { if (pos[c] <= 0.0f || (pos[c] >= world_sz_dim[c] - kFloatEpsilon)) { vel[c] = 0.0f; pos[c] = std::max(0.0f, std::min(world_sz_dim[c] - kFloatEpsilon, pos[c])); } } ptc.set_position(pos); ptc.set_velocity(vel); } }
coment::Entity EntityFactory::createParticle(coment::World& world, float x, float y) { coment::Entity entity = world.createEntity(); //return entity; // First working solution with SFML //sf::Vector2f velocity(0.f, (float)(std::rand() % 800 - 400)); //sf::Transform rotationTransform; //rotationTransform.rotate((rand() % 36000) / 100.f); //velocity = rotationTransform.transformPoint(velocity); // Second working solution // http://stackoverflow.com/a/5838055/1702695 float t = 2.f * 3.141592654f * MathUtils::randomFloat(); float u = MathUtils::randomFloat() + MathUtils::randomFloat(); float r = (u>1) ? 2.f-u : u; Vector2f velocity(r * std::cos(t), r * std::sin(t)); velocity = velocity * (MathUtils::randomFloat() * 800.f - 400.f); // I benchmark it and it's faster than the first solution // Bench (in Release mode): // solution 1: 192ms for 1'000'000 iterations // solution 2: 50ms for 1'000'000 iterations world.addComponent(entity, Position(x, y)); world.addComponent(entity, Velocity(velocity.x, velocity.y)); world.addComponent(entity, Expires(7.f)); Sprite sprite; sprite.name = "particle"; sprite.color = Color({1.0f, 0.84f, 0.0f, 0.5f}); sprite.layer = Sprite::Layer::PARTICLES; world.addComponent(entity, sprite); ColorAnimation colorAnimation; colorAnimation.animate[ColorAnimation::A] = true; colorAnimation.speed[ColorAnimation::A] = -0.2f; colorAnimation.min[ColorAnimation::A] = 0.f; colorAnimation.max[ColorAnimation::A] = 1.f; colorAnimation.repeat = false; world.addComponent(entity, colorAnimation); }
bool SGMFastScanParameters::operator ==(const SGMFastScanParameters &other){ if( element() == other.element() && runSeconds() == other.runSeconds() && energyStart() == other.energyStart() && energyMidpoint() == other.energyMidpoint() && energyEnd() == other.energyEnd() && velocity() == other.velocity() && velocityBase() == other.velocityBase() && acceleration() == other.acceleration() && scalerTime() == other.scalerTime() && baseLine() == other.baseLine() && undulatorStartStep() == other.undulatorStartStep() && undulatorVelocity() == other.undulatorVelocity() && undulatorRelativeStep() == other.undulatorRelativeStep() && exitSlitDistance() == other.exitSlitDistance() && sgmGrating() == other.sgmGrating()){ return true; } return false; }
void MetalineEnemy::checkToFire() { if (fireCounter >= FIRE_COUNTER_THRESHOLD) { GameState *gs = GameState::GetInstance(); Vector3f playerPos = gs->GetPlayerPosition(); Vector3f pCenter(this->center.x, this->center.y, this->center.z); Vector3f projectileDirection = (playerPos - pCenter).normalized(); Vector3f velocity(projectileDirection(0) * PROJECTILE_SPEED, projectileDirection(1) * PROJECTILE_SPEED, projectileDirection(2) * PROJECTILE_SPEED); Projectile *p = new Ball(pCenter, velocity, PROJECTILE_RADIUS); gs->GetParticleSystems()->AddBullet(p); fireCounter = 0; } else if (fireCounter < FIRE_COUNTER_THRESHOLD) { fireCounter++; } }
void ExplosionEmitter::resetParticle(ParticleAttribute *particle) { particle->_position = _origin; D3DXVECTOR3 velocity(0.0f, 0.0f, 1.0f); ParticleEmitter::jitterVector( velocity, (-D3DX_PI / 2) + util::EPSILON, (D3DX_PI / 2) - util::EPSILON, 0.0f, (2 * D3DX_PI) - util::EPSILON); velocity *= std::pow(util::randFloat(00.0f, 1.0f),3)*1000; particle->_velocity = velocity; particle->_acceleration = D3DXVECTOR3(0.0f, -100.0f, 0.0f); particle->_alive = true; particle->_age = 0.0f; particle->_lifeTime = 1.0f; particle->_color = D3DCOLOR_RGBA(255, 255, 255, 0); }
void GameScene_Box2D::addParticle(){ //発生起点 b2Vec2 origin(300.0f/PTM_RATIO,300.0f/PTM_RATIO); //パーティクル加速度 b2Vec2 velocity(0,100.0f); b2ParticleDef particleDef; particleDef.flags = b2_waterParticle; particleDef.flags |= b2_destructionListenerParticle; particleDef.color = b2ParticleColor(100,150,255,200); //パーティクルの寿命 // particleDef.lifetime = 2.0f; //グループへのポインタを渡しておく事でそのグループ内で管理する事ができる。 particleDef.group = _particleGroup; //設定した数値の間で発射方向をランダムに設定 float ratep = (float)rand() / (float)RAND_MAX; particleDef.position.x = origin.x + (100 * ratep)/PTM_RATIO - 100/PTM_RATIO; particleDef.position.y = origin.y + (100 * ratep)/PTM_RATIO - 100/PTM_RATIO; //設定した数値の間でランダムな位置にパーティクルを生成 float ratev = (float)rand() / (float)RAND_MAX; particleDef.velocity.x = velocity.x + (5 * ratev) - (5 / 2); //画像設定 Sprite * image = Sprite::create("ball.png"); image->setPositionX(particleDef.position.x * PTM_RATIO); image->setPositionY(particleDef.position.y * PTM_RATIO); //描画担当レイヤに渡す addChild(image); particleDef.userData = image; _particleSystem->CreateParticle(particleDef); }
unsigned int SpawnTemplate::Instantiate(unsigned int aId, const Transform2 &aPosition, const Transform2 &aVelocity) const { // apply position offset Transform2 transform(mOffset * aPosition); // apply position scatter if (mScatter.a) transform.a += Random::Value(0.0f, mScatter.a); if (mScatter.p.x) transform.p.x += Random::Value(0.0f, mScatter.p.x); if (mScatter.p.y) transform.p.y += Random::Value(0.0f, mScatter.p.y); // get local velocity Transform2 velocity(aVelocity.a, transform.Unrotate(aVelocity.p)); // apply velocity inherit velocity.a *= mInherit.a; velocity.p.x *= mInherit.p.x; velocity.p.y *= mInherit.p.y; // apply velocity add // (TO DO: make this more straightforward) velocity.a += mVelocity.a; velocity.p.x += mVelocity.p.x; velocity.p.y += mVelocity.p.y; // apply velocity variance if (mVariance.a) velocity.a += Random::Value(0.0f, mVariance.a); if (mVariance.p.x) velocity.p.x += Random::Value(0.0f, mVariance.p.x); if (mVariance.p.y) velocity.p.y += Random::Value(0.0f, mVariance.p.y); // get world velocity velocity.p = transform.Rotate(velocity.p); // instantiate the item return Database::Instantiate(mSpawn, Database::owner.Get(aId), aId, transform.a, transform.p, velocity.p, velocity.a); }
void GillespieProcess::fire() { Real velocity( getk() * N_A ); velocity *= getSuperSystem()->getSize(); for( VariableReferenceVector::const_iterator s( theVariableReferenceVector.begin() ); s != theZeroVariableReferenceIterator; ++s ) { VariableReference aVariableReference( *s ); Integer aCoefficient( aVariableReference.getCoefficient() ); do { ++aCoefficient; velocity *= aVariableReference.getVariable()->getMolarConc(); } while( aCoefficient != 0 ); } setActivity( velocity ); }
void forwardJaa() { unsigned int vi=0; do { forward(); //_delay_ms(200); set_color(); if(Center_white_line>40 && (Left_white_line>40 || Right_white_line>40)) //2 bbw wbb { node(); } velocity(240,240); //velocity(v+vi,v+vi); //i+=20; }while(Center_white_line>0x28 && Left_white_line<40 && Right_white_line<40); //wbw noNatak(); forwardJaa(); return; }
void VTKWriter::initializeOutput(int numParticles) { vtkFile = new VTKFile_t("UnstructuredGrid"); // per point, we add mass, velocity, force, type and stress // and in DEBUG mode the id of the molecules PointData pointData; DataArray_t mass(type::Float32, "mass", 1); DataArray_t velocity(type::Float32, "velocity", 3); DataArray_t forces(type::Float32, "force", 3); DataArray_t type(type::Int32, "type", 1); DataArray_t stress(type::Float32, "stress", 1); DataArray_t flag(type::Int32, "flag", 1); pointData.DataArray().push_back(mass); pointData.DataArray().push_back(velocity); pointData.DataArray().push_back(forces); pointData.DataArray().push_back(type); pointData.DataArray().push_back(stress); pointData.DataArray().push_back(flag); #ifdef DEBUG DataArray_t id(type::Int32, "id", 1); pointData.DataArray().push_back(id); #endif CellData cellData; // we don't have cell data => leave it empty // 3 coordinates Points points; DataArray_t pointCoordinates(type::Float32, "points", 3); points.DataArray().push_back(pointCoordinates); Cells cells; // we don't have cells, => leave it empty // for some reasons, we have to add a dummy entry for paraview DataArray_t cells_data(type::Float32, "types", 0); cells.DataArray().push_back(cells_data); PieceUnstructuredGrid_t piece(pointData, cellData, points, cells, numParticles, 0); UnstructuredGrid_t unstructuredGrid(piece); vtkFile->UnstructuredGrid(unstructuredGrid); }
void Physics::attachTo(iPhysics* newParent, float speed, float angularSpeed) { // detach from current parent, if any if (parent_){ bodyForce_=mass_*9.8f*Vector(0,-1,0); velocity_=velocity() //initial velocity of detached frame is made of its current velocity + tanVelocity() //velocity from parent's spin + speed * normal(bv_->relativePosition() * parent_->rotation()); //launch velocity acceleration_=tanAcceleration(); //tangential acceleration from the parent's rotation //angVel_ = angularSpeed*Vector(0,1,0); //angAccel_= Vector(0,-1,0); } parent_=0; parent_=newParent; if(newParent){ bv_->attachTo(newParent->bv()); } else{ bv_->attachTo(0); physicsType_=PHYS_Falling; } }
virtual void fire() { Real velocity( k * N_A ); velocity *= getSuperSystem()->getSize(); for( VariableReferenceVector::const_iterator s( theVariableReferenceVector.begin() ); s != theZeroVariableReferenceIterator; ++s ) { VariableReference aVariableReference( *s ); Integer aCoefficient( aVariableReference.getCoefficient() ); do { ++aCoefficient; velocity *= aVariableReference.getMolarConc(); } while( aCoefficient != 0 ); } setFlux(velocity); }
Note<Time>::Note(uint8_t chan, Time t, Time l, uint8_t n, uint8_t v) // FIXME: types? : _on_event (0xDE, t, 3, NULL, true) , _off_event (0xAD, t + l, 3, NULL, true) { assert(chan < 16); _on_event.buffer()[0] = MIDI_CMD_NOTE_ON + chan; _on_event.buffer()[1] = n; _on_event.buffer()[2] = v; _off_event.buffer()[0] = MIDI_CMD_NOTE_OFF + chan; _off_event.buffer()[1] = n; _off_event.buffer()[2] = 0x40; assert(time() == t); assert(length() == l); assert(note() == n); assert(velocity() == v); assert(_on_event.channel() == _off_event.channel()); assert(channel() == chan); }
void velocityspline2(double x[3], double dx[3], double ds, double binv, double deltav, double *vfac){ int i,steps=10; double v,d,val,vel[3]; *vfac=0.; for(i=0;i<steps;i++){ d=i*ds/steps; velocity(x[0]+(dx[0]*d),x[1]+(dx[1]*d),x[2]+(dx[2]*d),vel); v=deltav+veloproject(dx,vel); val=fabs(v)*binv; if(val <= 2500.){ #ifdef FASTEXP *vfac+= FastExp(val*val); #else *vfac+= exp(-(val*val)); #endif } } *vfac=*vfac/steps; return; }
void run(){ if(Att_Avg>=1 && Att_Avg<=10){ //Mind Wandering level PORTJ=0X01; stop(); } else if(Att_Avg>10 && Att_Avg<=30){ //Poor level of attention PORTJ=0x03; velocity(190,190); forward(); } else if(Att_Avg>30 && Att_Avg<=40){ //Attention level building up PORTJ=0X07; velocity(200,200); forward(); } else if(Att_Avg>40 && Att_Avg<=50){ //Neutral PORTJ=0X0F; velocity(220,220); forward(); } else if(Att_Avg>50 && Att_Avg<=60){ //Neutral PORTJ=0X1F; velocity(220,220); forward(); } else if(Att_Avg>60 && Att_Avg<=70){ //Slightly elevated PORTJ=0X3F; velocity(230,230); forward(); } else if(Att_Avg>70 && Att_Avg<=80){ //Slightly elevated PORTJ=0X7F; velocity(240,240); forward(); } else if(Att_Avg>80 && Att_Avg<=100){ //Elevated PORTJ=0xFF; velocity(240,240); forward(); } }