Пример #1
0
void rotateTo(irr::core::vector3d<irr::f32> rotation)
{
	if(node)
	{
		//do I want this from left to right too???  Assuming yes.
		node->setRotation(rightToLeft(rotation) + rightToLeft(irr::core::vector3d<irr::f32>(defaultXRotation,defaultYRotation,defaultZRotation)));
	}
}
Пример #2
0
void goTo(irr::core::vector3d<irr::f32> position)
{
	if(node)
	{
		node->setPosition(rightToLeft(position));
	}
}
    /**
     * 计算你能获得的最大收益
     *
     * @param prices Prices[i]即第i天的股价
     * @return 整型
     */
    int calculateMax(vector<int> prices) {
       vector<int> leftToRight(prices.size(),0);
    	int minLeft = 0;
    	for(int i=1;i<prices.size();i++){       // From left to right
        	if(prices[i]>prices[i-1]){
           	 	leftToRight[i] = std::max(leftToRight[i-1],prices[i]-prices[minLeft]);
       		}
        	else{
            	leftToRight[i] = leftToRight[i-1];
            	if(prices[i]<prices[minLeft]){
                	minLeft = i;
            	}
       	    }
       }

       vector<int> rightToLeft(prices.size(),0);
       int maxRight = prices.size()-1;
       for(int i=prices.size()-2;i>=0;i--){
          if(prices[i]<prices[i+1]){
             rightToLeft[i] = std::max(prices[maxRight]-prices[i],rightToLeft[i+1]);
          }else{
             rightToLeft[i] = rightToLeft[i+1];
             if(prices[i]>prices[maxRight]){
                maxRight = i;
             }
         }
      }

      int ret=0;
      for(int i=0;i<prices.size();i++){
          ret = max(leftToRight[i]+rightToLeft[i],ret);
      }
      return ret;
    }
Пример #4
0
ILModel(irr::scene::ISceneManager *mngr, irr::c8 *fName, irr::core::vector3d<irr::f32> position, irr::core::vector3d<irr::f32> rotation)
{
	manager = mngr;
	mesh = mngr->getMesh(fName);
	node = 0;
	defaultXRotation = 0.0f;
	defaultYRotation = 0.0f;
	defaultZRotation = -90.0f;
	node = manager->addAnimatedMeshSceneNode(mesh);
	node->setPosition(rightToLeft(position));
	rotateTo(rotation);
}