• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ speed函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中speed函数的典型用法代码示例。如果您正苦于以下问题:C++ speed函数的具体用法?C++ speed怎么用?C++ speed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了speed函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: assert

void Client::sendPlayerPos()
{
	LocalPlayer *myplayer = m_env.getLocalPlayer();
	if(myplayer == NULL)
		return;

	// Save bandwidth by only updating position when something changed
	if(myplayer->last_position        == myplayer->getPosition() &&
			myplayer->last_speed      == myplayer->getSpeed()    &&
			myplayer->last_pitch      == myplayer->getPitch()    &&
			myplayer->last_yaw        == myplayer->getYaw()      &&
			myplayer->last_keyPressed == myplayer->keyPressed)
		return;

	myplayer->last_position   = myplayer->getPosition();
	myplayer->last_speed      = myplayer->getSpeed();
	myplayer->last_pitch      = myplayer->getPitch();
	myplayer->last_yaw        = myplayer->getYaw();
	myplayer->last_keyPressed = myplayer->keyPressed;

	u16 our_peer_id;
	{
		//JMutexAutoLock lock(m_con_mutex); //bulk comment-out
		our_peer_id = m_con.GetPeerID();
	}

	// Set peer id if not set already
	if(myplayer->peer_id == PEER_ID_INEXISTENT)
		myplayer->peer_id = our_peer_id;

	assert(myplayer->peer_id == our_peer_id);

	v3f pf         = myplayer->getPosition();
	v3f sf         = myplayer->getSpeed();
	s32 pitch      = myplayer->getPitch() * 100;
	s32 yaw        = myplayer->getYaw() * 100;
	u32 keyPressed = myplayer->keyPressed;

	v3s32 position(pf.X*100, pf.Y*100, pf.Z*100);
	v3s32 speed(sf.X*100, sf.Y*100, sf.Z*100);
	/*
		Format:
		[0] v3s32 position*100
		[12] v3s32 speed*100
		[12+12] s32 pitch*100
		[12+12+4] s32 yaw*100
		[12+12+4+4] u32 keyPressed
	*/

	NetworkPacket pkt(TOSERVER_PLAYERPOS, 12 + 12 + 4 + 4 + 4);

	pkt << position << speed << pitch << yaw << keyPressed;

	Send(&pkt);
}
开发者ID:hunter688,项目名称:minetest,代码行数:55,代码来源:client.cpp


示例2: switch

void frog::keyup(unsigned char key) {
    switch (key) {
    case 'o':
        speed().x() += SPEED_X;
        orientation_ -= 45;
        break;
    case 'p':
        speed().x() -= SPEED_X;
        orientation_ += 45;
        break;
    case 'q':
        speed().z() += SPEED_Z;
        break;
    case 'a':
        speed().z() -= SPEED_Z;
        break;
    default:
        break;
    }
}
开发者ID:luisribeirogomes,项目名称:Frogger,代码行数:20,代码来源:frog.cpp


示例3: main

int main(void)
{
	init_MCU();
	LED_R_ON;

	speed(0,0);
	while(1)
	{
		ctrrobot();
	}
}
开发者ID:DinhUIT,项目名称:RobotSoccer,代码行数:11,代码来源:RobotSoccer.c


示例4: TEST

TEST(ValidMoveRightTest, ValidMoveReturnsSameMoveIfItIsValid){
	std::list<Position> allPosns;
	allPosns.push_back(Position(Vector2(0, 0), 50, 50));

	ValidMove validity(Position(Vector2(0, 0), 500, 500), allPosns);
	Vector2 speed(25, 0);
	Position nextMove(Vector2(25, 0), 50, 50);
	Position validMove = validity.getValidMove(Position(Vector2(0, 0), 50, 50), speed);
	
	EXPECT_EQ(validMove, nextMove); 
}
开发者ID:oceanchild,项目名称:goobleprojects,代码行数:11,代码来源:ValidMoveTest.cpp


示例5: fillCubeArray

void Loadbar::createAnimation()
{
    fillCubeArray(0x00);
    for (quint8 i = 0; i < CUBE_SIZE; i++)
    {
        setPlane(m_axis, i);
        if(m_abort)
            return;
        waitMs(speed());
    }
    waitMs(speed() * 2);
    for (quint8 i = 0; i < CUBE_SIZE; i++)
    {
        clearPlane(m_axis, i);
        if(m_abort)
            return;
        waitMs(speed());
    }
    Q_EMIT done();
}
开发者ID:cslux,项目名称:ledcc,代码行数:20,代码来源:Loadbar.cpp


示例6: speed

uint8 CPU::op_read(uint32 addr) {
  debugger.op_read(addr);

  status.clock_count = speed(addr);
  dma_edge();
  add_clocks(status.clock_count - 4);
  regs.mdr = bus.read(addr);
  add_clocks(4);
  alu_edge();
  return regs.mdr;
}
开发者ID:Brunnis,项目名称:bsnes-mercury,代码行数:11,代码来源:memory.cpp


示例7: variable

/* ARGSUSED */
void
variable(int cc)
{
	char	buf[256];

	if (prompt("[set] ", buf, sizeof (buf)))
		return;
	vlex(buf);
	if (vtable[BEAUTIFY].v_access&CHANGED) {
		vtable[BEAUTIFY].v_access &= ~CHANGED;
		(void) kill(pid, SIGSYS);
	}
	if (vtable[SCRIPT].v_access&CHANGED) {
		vtable[SCRIPT].v_access &= ~CHANGED;
		setscript();
		/*
		 * So that "set record=blah script" doesn't
		 *  cause two transactions to occur.
		 */
		if (vtable[RECORD].v_access&CHANGED)
			vtable[RECORD].v_access &= ~CHANGED;
	}
	if (vtable[RECORD].v_access&CHANGED) {
		vtable[RECORD].v_access &= ~CHANGED;
		if (boolean(value(SCRIPT)))
			setscript();
	}
	if (vtable[TAND].v_access&CHANGED) {
		vtable[TAND].v_access &= ~CHANGED;
		if (boolean(value(TAND)))
			tandem("on");
		else
			tandem("off");
	}
	if (vtable[LECHO].v_access&CHANGED) {
		vtable[LECHO].v_access &= ~CHANGED;
		boolean(value(HALFDUPLEX)) = boolean(value(LECHO));
	}
	if (vtable[PARITY].v_access&CHANGED) {
		vtable[PARITY].v_access &= ~CHANGED;
		setparity(NULL);
	}
	if (vtable[BAUDRATE].v_access&CHANGED) {
		vtable[BAUDRATE].v_access &= ~CHANGED;
		ttysetup(speed(number(value(BAUDRATE))));
	}
	if (vtable[HARDWAREFLOW].v_access & CHANGED) {
		vtable[HARDWAREFLOW].v_access &= ~CHANGED;
		if (boolean(value(HARDWAREFLOW)))
			hardwareflow("on");
		else
			hardwareflow("off");
	}
}
开发者ID:AlfredArouna,项目名称:illumos-gate,代码行数:55,代码来源:cmds.c


示例8: main

int main(){


    long n(0), k(0); scanf("%ld %ld\n", &n, &k);
    std::vector<long> speed(n,0);
    for(int p = 0; p < n; p++){scanf("%ld", &speed[p]);}
    std::sort(speed.begin(), speed.end());
    printf("%ld\n", speed[n - k]);

    return 0;
}
开发者ID:AhmedAMohamed,项目名称:CodeForces,代码行数:11,代码来源:412B-NetworkConfiguration.cpp


示例9: Q_D

void KJob::emitSpeed(unsigned long value)
{
    Q_D(KJob);
    if (!d->speedTimer) {
        d->speedTimer = new QTimer(this);
        connect(d->speedTimer, SIGNAL(timeout()), SLOT(_k_speedTimeout()));
    }

    emit speed(this, value);
    d->speedTimer->start(5000);   // 5 seconds interval should be enough
}
开发者ID:crayonink,项目名称:calligra-2,代码行数:11,代码来源:kjob.cpp


示例10: rodConfig

void T12SuperBallPayload::setup(tgWorld& world)
{

    const tgRod::Config rodConfig(c.radius, c.density, c.friction, 
				c.rollFriction, c.restitution);
    /// @todo acceleration constraint was removed on 12/10/14 Replace with tgKinematicActuator as appropreate
    tgBasicActuator::Config muscleConfig(c.stiffness, c.damping, c.pretension,
					    c.history, c.maxTens, c.targetVelocity);
            
    // Start creating the structure
    tgStructure s;
    addNodes(s);
    addRods(s);
    addMuscles(s);

//    // Add a rotation. This is needed if the ground slopes too much,
//    // otherwise  glitches put a rod below the ground.
//    btVector3 rotationPoint = btVector3(0, 0, 0); // origin
//    btVector3 rotationAxis = btVector3(0, 1, 0);  // y-axis
//    double rotationAngle = M_PI/2;
//    s.addRotation(rotationPoint, rotationAxis, rotationAngle);

    //s.move(btVector3(0,30,0));

    // Create the build spec that uses tags to turn the structure into a real model
    tgBuildSpec spec;
    spec.addBuilder("rod", new tgRodInfo(rodConfig));
    spec.addBuilder("muscle", new tgBasicActuatorInfo(muscleConfig));
    
    // Create your structureInfo
    tgStructureInfo structureInfo(s, spec);

    // Use the structureInfo to build ourselves
    structureInfo.buildInto(*this, world);

    // We could now use tgCast::filter or similar to pull out the
    // models (e.g. muscles) that we want to control. 
    allMuscles = tgCast::filter<tgModel, tgBasicActuator> (getDescendants());

    // call the onSetup methods of all observed things e.g. controllers
    notifySetup();

    // Actually setup the children
    tgModel::setup(world);

    //map the rods and add the markers to them
    addMarkers(s);

    btVector3 location(0,10.0,0);
    btVector3 rotation(0.0,0.6,0.8);
  	btVector3 speed(0,20,100);
    this->moveModel(location,rotation,speed);
}
开发者ID:CarlosManriquez,项目名称:NTRTsim,代码行数:53,代码来源:T12SuperBallPayload.cpp


示例11: speed

void KPrPageEffect::saveOdfSmilAttributes( KoGenStyle & style ) const
{
    QString speed("slow");
    if (m_duration < 2500) {
        speed = "fast";
    }
    else if (m_duration < 7500) {
        speed = "medium";
    }
    style.addProperty("presentation:transition-speed", speed);
    return m_strategy->saveOdfSmilAttributes(style);
}
开发者ID:KDE,项目名称:calligra-history,代码行数:12,代码来源:KPrPageEffect.cpp


示例12: speed

void Ship::fire(std::vector<Shoot>&salvo, Fleet *enemy)
{
    double ourspeed = speed();
    for (auto weapon : weapons)
    {
        std::shared_ptr<Weapon> gun = weapon.lock();
        if (gun)
        {
            gun->fire(salvo, enemy, ourspeed);
        }
    }
}
开发者ID:AlexeyTyurenkov,项目名称:GeneCode,代码行数:12,代码来源:Ship.cpp


示例13: main

int main(){
    double V0x,V0y,h,t,h0;
    printf("h:\n");
    scanf("%lf",&h0);
    printf("V0y:\n");
    scanf("%lf",&V0y);
    t=0;
    h=0;
    while(h>=0){
    h=h0-dist(V0y,t);
    printf("t=%lf Speed=%lf  h=%lf",t,speed(V0y,t),h);
    usleep(100);
    t=t+0.0001;
    fflush(stdout);
    printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
    }
    printf("t=%lf Speed=%lf  h=%lf\n",t,speed(V0y,t),h);



}
开发者ID:Macvol,项目名称:OldBundle,代码行数:21,代码来源:phis.c


示例14: speed

void Car::update(double delta_t) {
	bool pressed = false;
	_acceleration = 0;
	Vector3 speed(cos((_turnAngle)*(PI / 180)), sin((_turnAngle)*(PI / 180)), 0);

	if (upKeyPressed) {
		pressed = true;
		_acceleration = FORWARD_ACCELERATION;
		if (_currentSpeed + (delta_t * _acceleration) < MAX_FORWARD_SPEED) {
			_currentSpeed = _currentSpeed + (delta_t * _acceleration);
		}
		else {
			_currentSpeed = MAX_FORWARD_SPEED;
		}
	}
	else if (downKeyPressed) {
		pressed = true;
		_acceleration = -BACKWARDS_ACCELERATION;
		if (_currentSpeed + (delta_t * _acceleration) > -MAX_BACKWARDS_SPEED) {
			_currentSpeed = _currentSpeed + (delta_t * _acceleration);
		}
		else {
			_currentSpeed = -MAX_BACKWARDS_SPEED;
		}
	}
	if (leftKeyPressed) {
		_turnAngle += ANGLE_INCREASE;
	}
	if (rightKeyPressed) {
		_turnAngle -= ANGLE_INCREASE;
	}
	if (!pressed) {
		if (_currentSpeed > 0) {
			if (_currentSpeed - (delta_t)* 0.0005 > 0) {
				_currentSpeed -= (delta_t)* 0.0005;
			}
			else {
				_currentSpeed = 0;
			}
		}
		else if (_currentSpeed < 0) {
			if (_currentSpeed + (delta_t)* FRICTION < 0) {
				_currentSpeed += (delta_t)* FRICTION;
			}
			else {
				_currentSpeed = 0;
			}
		}
	}

	_speed = speed * _currentSpeed;
	_position = (_position + _speed);
}
开发者ID:Danisodu,项目名称:Computer-Graphics,代码行数:53,代码来源:Car.cpp


示例15: do_ball

int do_ball(int cn,int x,int y)
{
	int dir;

	if (cn<1 || cn>=MAXCHARS) { error=ERR_ILLEGAL_CHARNO; return 0; }

	if (ch[cn].flags&(CF_DEAD)) { error=ERR_DEAD; return 0; }

	if ((ch[cn].flags&CF_NOMAGIC) && !(ch[cn].flags&CF_NONOMAGIC)) { error=ERR_UNCONCIOUS; return 0; }

	if (warcried(cn)) { error=ERR_UNCONCIOUS; return 0; }

	if (!ch[cn].value[0][V_FLASH]) { error=ERR_UNKNOWN_SPELL; return 0; }

	if (x<1 || x>=MAXMAP-1 || y<1 || y>=MAXMAP-1) { error=ERR_ILLEGAL_COORDS; return 0; }

	if (ch[cn].mana<FLASHCOST) { error=ERR_MANA_LOW; return 0; }

        dir=offset2dx(ch[cn].x,ch[cn].y,x,y);
	if (!dir) {
		if (!may_add_spell(cn,IDR_FLASH)) { error=ERR_ALREADY_WORKING; return 0; }
		ch[cn].action=AC_FLASH;
		ch[cn].duration=speed(ch[cn].value[0][V_SPEED],ch[cn].speed_mode,DUR_MAGIC_ACTION);
		ch[cn].dir=bigdir(ch[cn].dir);
	} else {
		ch[cn].action=AC_BALL1;
		ch[cn].act1=x;
		ch[cn].act2=y;
		ch[cn].duration=speed(ch[cn].value[0][V_SPEED],ch[cn].speed_mode,DUR_MAGIC_ACTION/2);
		ch[cn].dir=dir;
	}

	ch[cn].mana-=FLASHCOST;

	
	if (ch[cn].speed_mode==SM_FAST) ch[cn].endurance-=end_cost(cn);

        return 1;
}
开发者ID:AstoniaDev,项目名称:v3.0-server,代码行数:39,代码来源:do.c


示例16: X

/*
 X(n+1) = Xn - F(Xn)/F'(Xn)
 */
double XPQBezier::invertLength(double t, double l)
{
    double t1 = t, t2;
    
    do
    {
        t2 = t1 - (getBezierLength(t1) - l) / speed(t1);
        if(fabs(t1 - t2) < 0.0001) break;
        t1 = t2;
    } while(true);
    
    return t2;
}
开发者ID:jixuqianxing,项目名称:XPQLabel,代码行数:16,代码来源:XPQPath.cpp


示例17: syncController

task syncController()
{
    int leftVal;
    int rightVal;
    int delta, max = 0;
    bool done = false;

    nMotorEncoder[leftElevator] = 0;
    nMotorEncoder[rightElevator] = 0;

    while (!done) {
	    leftVal = nMotorEncoder[leftElevator];
	    rightVal = nMotorEncoder[rightElevator];

        nxtDisplayCenteredTextLine(1, "left: %d", leftVal);
        nxtDisplayCenteredTextLine(2, "right: %d", rightVal);

        delta = abs(leftVal - rightVal);
        nxtDisplayCenteredTextLine(3, "delta: %d", delta);

        if (delta > max) {
            max = delta;
            nxtDisplayCenteredTextLine(5, "max: %d", max);
        }

	    if (abs(leftVal - rightVal) > SLOP_FACTOR) {
            if (left < right) {
                nxtDisplayCenteredTextLine(4, "stop right");
                speed(0);
            } else if (right < left) {
                nxtDisplayCenteredTextLine(4, "stop left");
                speed(0);
            }
	    } else {
            nxtDisplayCenteredTextLine(4, "go all");
            speed(20);
        }
    }
}
开发者ID:Kemi25,项目名称:FTC-Team-25,代码行数:39,代码来源:elevatorSyncControl.c


示例18: main

int main()
{
	input = malloc(4096);
	output = malloc(4096);
	setup();
	if (1) {
		verify();
	} else {
		sleep(10);
		speed();
	}
	sleep(120);
}
开发者ID:nishemon,项目名称:bitpack,代码行数:13,代码来源:test.c


示例19: maxSpeed

OpenSteer::Vec3 
OpenSteer::SimpleVehicle::adjustRawSteeringForce (const Vec3& force,
                                                  const float /* deltaTime */)
{
    const float maxAdjustedSpeed = 0.2f * maxSpeed ();

    if ((speed () > maxAdjustedSpeed) || (force == Vec3::zero))
    {
        return force;
    }
    else
    {
        const float range = speed() / maxAdjustedSpeed;
        // const float cosine = interpolate (pow (range, 6), 1.0f, -1.0f);
        // const float cosine = interpolate (pow (range, 10), 1.0f, -1.0f);
        // const float cosine = interpolate (pow (range, 20), 1.0f, -1.0f);
        // const float cosine = interpolate (pow (range, 100), 1.0f, -1.0f);
        // const float cosine = interpolate (pow (range, 50), 1.0f, -1.0f);
        const float cosine = interpolate (pow (range, 20), 1.0f, -1.0f);
        return limitMaxDeviationAngle (force, cosine, forward());
    }
}
开发者ID:AthrunArthur,项目名称:opensteer,代码行数:22,代码来源:SimpleVehicle.cpp


示例20: reduce_duration

void Drawable::handle_action(double elapsed)
{
	cooldown -= elapsed;
	double modElapsed = reduce_duration(elapsed);

	rotation += rot_speed_*elapsed;
	//double dist = speed*modElapsed;

	switch (action)
	{
	case ACT_MOVE_UP:
        move(0, -(speed()*modElapsed));
		break;
	case ACT_MOVE_DOWN:
        move(0, (speed()*modElapsed));
		break;
	case ACT_MOVE_LEFT:
        move(-(speed()*modElapsed), 0);
		break;
	case ACT_MOVE_RIGHT:
        move((speed()*modElapsed), 0);
		break;
    case ACT_REPULSE_UP:
        move(0, -(REPULSE_SPEED*modElapsed));
        break;
    case ACT_REPULSE_DOWN:
        move(0, (REPULSE_SPEED*modElapsed));
        break;
    case ACT_REPULSE_LEFT:
        move(-(REPULSE_SPEED*modElapsed), 0);
        break;
    case ACT_REPULSE_RIGHT:
        move((REPULSE_SPEED*modElapsed), 0);
        break;
	};

	act_duration_ -= elapsed;
}
开发者ID:evg123,项目名称:walkabout,代码行数:38,代码来源:drawable.cpp



注:本文中的speed函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ speex_bits_destroy函数代码示例发布时间:2022-05-30
下一篇:
C++ special_file函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap