当前位置: 首页>>代码示例>>C++>>正文


C++ Helicopter::getVelocity方法代码示例

本文整理汇总了C++中Helicopter::getVelocity方法的典型用法代码示例。如果您正苦于以下问题:C++ Helicopter::getVelocity方法的具体用法?C++ Helicopter::getVelocity怎么用?C++ Helicopter::getVelocity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Helicopter的用法示例。


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

示例1: maxSpead

void RealTimeTest::maxSpead() {
    
	Hud *maxSpeadTestingHud = game.getHudsManager()->createHud(HudAlignment::RIGHT);
	maxSpeadTestingHud->setText("MAX SPEAD TESTING STARTED...");
	
	DelayCommand dc(15);
	dc.execute();
	
	Helicopter *helicopter = game.getHelicopter();
	JoystickMoveForward jmf(helicopter->getJoystick());
	RotorNeutral rn(helicopter->getMainRotor());
	float oldV = 0;
	float newV = 0;
	
	std::cout << "\nmaxSpead test started:" << std::endl;
	
	game.getConfiguration()->activateFriction();
	helicopter->reset();
	helicopter->setPosistion(osg::Vec3f(0, 0, 600));
	jmf.execute();
	rn.execute();
	
	
	do {
		oldV = newV;
		dc.execute();
		newV = helicopter->getVelocity().x();
	} while (oldV < newV);
	
	
	// viscous resistance = v * (6 * WORLD_PI * 0.001 * 4)
	// if joystick(theta = 15, phi = 0) and throttle(9.8), then
	// ax = sin15 * 9.8 = 0.2588 * 9.8 = 2.53624
	// viscous resistance should be equal 2.53624
	// v * (6 * WORLD_PI * 0.001 * 4) = 2.53624 <= now solve for v
	// v = 2.53624 / (6 * WORLD_PI * 0.001 * 4)
	// v = 33.6379
	Assert(33.6379, helicopter->getVelocity().x(), 0.01);
	
	std::cout << "maxSpead test passed" << std::endl;
	std::cout << "maxSpead test results:" << std::endl;
	std::cout << "vx = " << helicopter->getVelocity().x() << std::endl;
    maxSpeadTestingHud->setText("HOVER TESTING PASSED...");
}
开发者ID:hamadmarri,项目名称:Helicopter-Game-on-OSG,代码行数:44,代码来源:RealTimeTest.cpp

示例2: hover

void RealTimeTest::hover() {
	
	Hud *hoverTestingHud = game.getHudsManager()->createHud(HudAlignment::RIGHT);
	hoverTestingHud->setText("HOVER TESTING STARTED...");
	
	DelayCommand dc(2);
	DelayCommand wait10s(10);
	dc.execute();
	
	std::cout << "\nhover test started:" << std::endl;
	
	game.getConfiguration()->deactivateFriction();
	Helicopter *helicopter = game.getHelicopter();
	
	helicopter->reset();
	helicopter->setPosistion(osg::Vec3f(0, 0, 0));
	helicopter->getMainRotor()->increaseMagnitude();
	helicopter->getMainRotor()->increaseMagnitude();
	helicopter->getMainRotor()->increaseMagnitude();
	
	wait10s.execute();
	
	
	// after 10s should be at position 15m
	// a = 0.3
	// x = 0 + 0*10 + 0.5 * 0.3 * (10)^2 = 15
	// v = 0 + a * t
	// v = 0.3 * 10 = 3
    
	Assert(15.0, helicopter->getPosistion().z(), 1.0e-1);
	Assert(3.0, helicopter->getVelocity().z(), 1.0e-1);
	Assert(0.3, helicopter->getAcceleration().z(), 1.0e-1);
	
	std::cout << "hover test passed" << std::endl;
	std::cout << "hover test results:" << std::endl;
	std::cout << "pz = " << helicopter->getPosistion().z() << std::endl;
	std::cout << "vz = " << helicopter->getVelocity().z() << std::endl;
	std::cout << "az = " << helicopter->getAcceleration().z() << std::endl;
    
	hoverTestingHud->setText("HOVER TESTING PASSED...");
}
开发者ID:hamadmarri,项目名称:Helicopter-Game-on-OSG,代码行数:41,代码来源:RealTimeTest.cpp


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