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

C++ setRight函数代码示例

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

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



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

示例1: rampDrive

	void rampDrive(int driveTarget)
	{
		int direction = 1;
		if( driveTarget < 0 )
		{
			direction = -1;
			driveTarget *= -1;
		}
		nMotorEncoder[LeftMWheel] = 0;
		int distance = 0;
		int pwr = 0;
		while(distance < driveTarget )
		{
			//distance = abs ( nMotorEncoder[leftBack] + nMotorEncoder[rightBack] ) / 2;

			distance = abs(nMotorEncoder[LeftMWheel]);

			if( distance <= driveTarget / 2)
				pwr = distance / 5 + 20;
			else
				pwr = ( driveTarget - distance ) / 10 + 20;

			pwr *= direction;
			setLeft(pwr);
			setRight(pwr);
		}
		setLeft(0);
		setRight(0);
	}
开发者ID:joseph-zhong,项目名称:Robotics,代码行数:29,代码来源:917B-AlexLakeWashington1_2.c


示例2: moveStraight

	// time is in milliseconds
	// distance is in tenths of inches
	// direction is 1 or -1 -- positive is forwards
	void moveStraight(int direction, int time, int driveTarget)
	{
		nMotorEncoder[LeftMWheel] = 0;
		int distance = 0;
		float pwr = 0;
			while(distance < driveTarget )
			{

					distance = abs(nMotorEncoder[LeftMWheel]);
					//initial version
					//pwr = 64 * sin(distance * PI / driveTarget);
					//improved version

					//SHITTY PID:
					//pwr = 0.05 * (driveTarget - distance) + 0.0003 * (0.05 * (driveTarget * distance - 0.5 * (distance * distance)));

					if( distance <= driveTarget / 2)
						pwr = distance / 5 + 20; //TODO: figure out how this works
					else
						pwr = ( driveTarget - distance ) / 10 + 20;

						//pwr = -1 * (1.11 * sqrt(driveTarget) - 10) * cos(distance * 2 * PI / driveTarget) + (1.11 * sqrt(distance)) + 10;


					pwr *= direction;
					setLeft(pwr);
					setRight(pwr);
			}
			setLeft(0);
			setRight(0);
		}
开发者ID:joseph-zhong,项目名称:Robotics,代码行数:34,代码来源:917B-AlexLakeWashington1_3.c


示例3: moveStraight

// time is in milliseconds
// distance is in tenths of inches
// direction is 1 or -1 -- positive is forwards
void moveStraight(int direction, int time, int driveTarget)
{
	nMotorEncoder[LeftMWheel] = 0;
	int distance = 0;
	float pwr = 0;
	while(distance < driveTarget )
	{
		distance = abs(nMotorEncoder[LeftMWheel]);
		// works
		if( distance <= driveTarget / 2)
			pwr = distance / 5 + 20; //TODO: figure out how this works
		else
			pwr = ( driveTarget - distance ) / 10 + 20;

		// test old formula
		//pwr = oldPwr(driveTarget, distance);
		// test new formula
		//pwr = newPwr(driveTarget, distance);

		pwr *= direction;
		setLeft(pwr);
		setRight(pwr);
	} // end while loop

	setLeft(0);
	setRight(0);
}
开发者ID:joseph-zhong,项目名称:Robotics,代码行数:30,代码来源:917B-JosephLakeWashington1_2.c


示例4: switch

 void PlayerInputStruct::fromGameEvent(const GameControl &control, bool state)
 {
     switch(control)
     {
         case GameControl::ACTION:
             setAction(state);
             break;
         case GameControl::UP:
             if(state)
                 setUp(100000);
             else
                 setUp(0);
             break;
         case GameControl::DOWN:
             if(state)
                 setDown(100000);
             else
                 setDown(0);
             break;
         case GameControl::LEFT:
             if(state)
                 setLeft(100000);
             else
                 setLeft(0);
             break;
         case GameControl::RIGHT:
             if(state)
                 setRight(100000);
             else
                 setRight(0);
             break;
         case GameControl::BUTTON1:
             setButton1(state);
             break;
         case GameControl::BUTTON2:
             setButton2(state);
             break;
         case GameControl::BUTTON3:
             setButton3(state);
             break;
         case GameControl::BUTTON4:
             setButton4(state);
             break;
         case GameControl::BUTTON5:
             setButton5(state);
             break;
         case GameControl::BUTTON6:
             setButton6(state);
             break;
         default:
             //Nothing to do; control is not handled by the automatic conversion.
             break;
     }
 }
开发者ID:maximaximal,项目名称:piga,代码行数:54,代码来源:PlayerInput.cpp


示例5: pickUpBall

		void pickUpBall(int goals)
	{
		resetValues(0);
		intake(1);
		wait10Msec(30);
		int current = 0;
		while(current < goals * 250)
		{
			setLeft(25); setRight(25);
			current = nMotorEncoder[LeftMWheel];
		}
		intake(0);
		setLeft(0); setRight(0);
	}
开发者ID:joseph-zhong,项目名称:Robotics,代码行数:14,代码来源:917B-AlexLakeWashington1_3.c


示例6: blueUdit

void blueUdit()
{
	deploy();
	intake(1);
	wait10Msec(10);
	moveStraight(1, 0, 475); //picks up
	wait10Msec(50);
	moveStraight(-1, 0, 475);//comes back
	//intake(0)();
	spin(1, 0, 400);
	lift(BUMP);
	holdArm();
	waitForButton();
	intake(-1);
	wait10Msec(100);
	resetValues(0);
	liftDown(); // added

	waitForButton();
	//liftDown();
	// end Devansh
	//waitForButton();
	intake(1);
	moveStraight(1, 0, (HALF_TILE));
	wait10Msec(50);
	pickUpBall(1);
	spin(1, 0, 200);
	//crossBump();
	lift(BUMP);
	nMotorEncoder[LeftMWheel] = 0;
	if(true)
	{
		setRight(127);
		wait10Msec(10);
		setLeft(127);
	}
	while (abs(nMotorEncoder[LeftMWheel]) < 500)
	{
		setRight(127); setLeft(127);
	}
	setRight(0); setLeft(0);
	lift(BARRIER);
	holdArm();
	wait10Msec(30);
	moveStraight(1, 0, 550);
	intake(-1);
	// end udit
	resetValues(1000);
}
开发者ID:joseph-zhong,项目名称:Robotics,代码行数:49,代码来源:917B-AlexLakeWashington1_3.c


示例7: usercontrol

task usercontrol()
{

	// Flags

	// Servo / program initialization:

	zeroEncoders();

	// Main loop:

	waitForStart();

	while (true)
	{

		getJoystickSettings(joystick);

		setLeft(100);
		setRight(100);

	}

	return;

}
开发者ID:CosineGaming,项目名称:VEX-2016,代码行数:26,代码来源:test.c


示例8: type

ExpressionNode::ExpressionNode(const ExpressionNode & other): //copy constructor
type(other.getType()), operation(other.getOperation()), activechildren(other.getOperation()->getArity()),
right(0), firstChild(0), variable(other.getVariable()), value(other.getValue())
{
	setRight(other.getRight());
	setFirstChild(other.getFirstChild()); // automatically also sets other children
}
开发者ID:vk-eipi,项目名称:MathParser,代码行数:7,代码来源:expression.cpp


示例9: glfwGetCursorPos

void Camera::updateCameraRotation() {

	double xPos, yPos;
	glfwGetCursorPos(m_window, &xPos, &yPos); // get current mouse position
	
	// if mouse still in window center, no need to recalculate view matrix
	if (xPos == m_windowWidth / 2 && yPos == m_windowHeight / 2) {
		return;
	}
	centerMouse();

	m_horizontalAngle += float(m_windowWidth / 2 - xPos) * m_mouseSpeed;
	m_verticalAngle += float(m_windowHeight / 2 - yPos) * m_mouseSpeed;

	glm::vec3 oldLookIn = getLookAt() - getCenter();
	glm::vec3 lookInHorizontal = glm::vec3(sin(m_horizontalAngle), oldLookIn.y, cos(m_horizontalAngle));
	glm::vec3 lookInVertical = glm::vec3(oldLookIn.x * cos(m_verticalAngle), sin(m_verticalAngle), oldLookIn.z * cos(m_verticalAngle));
	glm::vec3 newLookIn = glm::normalize(lookInHorizontal + lookInVertical);
	
	setLookAt(getCenter() + newLookIn);

	float rightHorizontalAngle = m_horizontalAngle - PI / 2.0f;
	setRight(glm::vec3(sin(rightHorizontalAngle), getRight().y, cos(rightHorizontalAngle)));

	setUp(glm::normalize(glm::cross(getRight(), newLookIn)));
}
开发者ID:gotcha84,项目名称:asdfgame,代码行数:26,代码来源:Camera.cpp


示例10: qDebug

Snake::Snake():AnimUT()
{
#ifdef debug
    qDebug("Snake launched");
#endif

    controls->addAnimationControl(animate, 200);

    cellSize = 15;
    nbCells = 20;

    // controls
    snakeItem = new SnakeItem(cellSize, nbCells);

    controls->addLabel("Movements");
    QPushButton *upBtn = controls->addButton("Up");
    connect(upBtn, SIGNAL(released()), snakeItem, SLOT(setUp()));
    QPushButton *downBtn = controls->addButton("Down");
    connect(downBtn, SIGNAL(released()), snakeItem, SLOT(setDown()));
    QPushButton *leftBtn = controls->addButton("Left");
    connect(leftBtn, SIGNAL(released()), snakeItem, SLOT(setLeft()));
    QPushButton *rightBtn = controls->addButton("Right");
    connect(rightBtn, SIGNAL(released()), snakeItem, SLOT(setRight()));

    controls->addDivider();

    score = controls->addLabel("Score : 0");
    connect(snakeItem, SIGNAL(updateScore(int)), this, SLOT(updateScore(int)));

    // viewer
    drawBorders();
    viewer->addItem(snakeItem);
}
开发者ID:christophe-r,项目名称:UTBM-QtFramework-AnimUT,代码行数:33,代码来源:Snake.cpp


示例11: AnchorsBase

bool AnchorsBase::setAnchor(const Qt::AnchorPoint &p, QWidget *target, const Qt::AnchorPoint &point)
{
    if (!target) {
        return false;
    }

    AnchorsBase *base = AnchorsBasePrivate::getWidgetAnchorsBase(target);

    if (!base) {
        base = new AnchorsBase(target);
    }

    const AnchorInfo *info = base->d_func()->getInfoByPoint(point);

    switch (p) {
    case Qt::AnchorTop:
        return setTop(info);
    case Qt::AnchorBottom:
        return setBottom(info);
    case Qt::AnchorLeft:
        return setLeft(info);
    case Qt::AnchorRight:
        return setRight(info);
    case Qt::AnchorHorizontalCenter:
        return setHorizontalCenter(info);
    case Qt::AnchorVerticalCenter:
        return setVerticalCenter(info);
    default:
        return false;
    }
}
开发者ID:zccrs,项目名称:Anchors,代码行数:31,代码来源:anchors.cpp


示例12: PixelRegion

    PixelRegion PixelRegion::globalCut(Side side, int p) {
        if (!lineIntersect(side, p)) {
            return PixelRegion({ 0, 0 }, { 0, 0 });
        }

        PixelRegion cutOff(*this);
        int cutSize = 0;
        switch (side) {
        case LEFT:
            setLeft(p);
            cutOff.setRight(p - cutSize);
            break;
        case TOP:
            setTop(p);
            cutOff.setBottom(p - cutSize);
            break;
        case RIGHT:
            setRight(p);
            cutOff.setLeft(p + cutSize);
            break;
        case BOTTOM:
            setBottom(p);
            cutOff.setTop(p + cutSize);
            break;
        }
        return cutOff;
    }
开发者ID:OpenSpace,项目名称:OpenSpace,代码行数:27,代码来源:pixelregion.cpp


示例13: setLeft

void GuiSetBorder::mousePressEvent(QMouseEvent * e)
{
	if (e->y() > e->x()) {
		if (e->y() < height() - e->x()) {
			if (left_.enabled) {
				setLeft(!left_.set);
				// emit signal
				leftSet(left_.set);
			}
		} else {
			if (bottom_.enabled) {
				setBottom(!bottom_.set);
				// emit signal
				bottomSet(bottom_.set);
			}
		}
	} else {
		if (e->y() < height() - e->x()) {
			if (top_.enabled) {
				setTop(!top_.set);
				// emit signal
				topSet(top_.set);
			}
		} else {
			if (right_.enabled) {
				setRight(!right_.set);
				// emit signal
				rightSet(right_.set);
			}
		}
	}
	update();
	// emit signal
	clicked();
}
开发者ID:315234,项目名称:lyx-retina,代码行数:35,代码来源:GuiSetBorder.cpp


示例14: len_

BPlusNode::BPlusNode(IXFileHdr &hdr, PFPageHandle &page, bool load)
	: len_(hdr.len)
	, type_(hdr.type)
	, capacity_(hdr.capacity)
	, page_(page)
{
	// allocPage 用于表示这个页面是否为新分配的
	// 布局如下
	//  一共n个key,占据 n * len_字节的大小
	//  一共n个rid,占据 n * sizeof(RID) 字节的大小
	//  一个字节用于记录一共有多少个key,占据sizeof(numOfKeys_)字节的大小
	//  一个left字段,占据sizeof(Page)字节的大小
	//  一个right字段,占据了sizeof(Page)字节的大小
	Ptr addr = page.rawPtr();
	num_ = page.page();

	keys_ = addr;
	rids_ = reinterpret_cast<RID *>(addr + len_ * capacity_);
	if (load) { // 说明这个页面实际上已经初始化过了
		size_ = size();
		left_ = left();
		right_ = right();
	}
	else { // 这里需要重新初始化
		size_ = 0;
		setSize(0);
		setLeft(-1);
		setRight(-1);
		page.setDirty();
	}
}
开发者ID:lishuhuakai,项目名称:CS,代码行数:31,代码来源:bplus_node.cpp


示例15: buildBinaryTree

void buildBinaryTree(pin_node root, int i)
{
	int v;
	pin_node q, p;
	p = q = root;
	while (q) {
		p = q;
		v = info(p);
		if (v == i) {
			printf("duplicate\n");
			q = NULL;
		} else if (v < i) {
			q = q->left;

		} else {
			q = q->right;
		}
		

	}

	if (p) {
		int v = p->val;
		 if (v < i) {
		 	setLeft(p, i);
		} else {
			setRight(p, i);
		}
	}
	
}
开发者ID:rahulnijhawan,项目名称:c_programs,代码行数:31,代码来源:find-duplicate.c


示例16: setLeft

void Rect::expand( const QPoint& point )
{
	setLeft  ( qMin(point.x(), left()  ) );
	setRight ( qMax(point.x(), right() ) );
	setTop   ( qMax(point.y(), top()   ) );
	setBottom( qMin(point.y(), bottom()) ); 
};
开发者ID:hunt978,项目名称:qfplot,代码行数:7,代码来源:rect.cpp


示例17: GetLinePos

bool
DCirfile::NextItemStr(const char *pos)
{
	CurrLeft = pos;

  for (;;) {
		CurrLeft = GetLinePos(CurrLeft);
		if (!CurrLeft)
			return false;
    //skipLine();
    if (isalnum(*CurrLeft)
     || (ispunct(*CurrLeft)
		  && ((*CurrLeft != ';')
		   || (*(CurrLeft + 1) == '=')) // deleted setting
		  && (*CurrLeft != '['))
		 || (*CurrLeft < 0)) {    // allow high-bit chars
			if (*CurrLeft == '\\')
				CurrLeft++;
      break;
		}
    if ((*CurrLeft == '\0')
     || (*CurrLeft == '[')) {
      CurrLeft = CurrRight = NULL;
      LeftLen = RightLen = 0;
      return false;
    }
  }

  setRight();
  return true;
}
开发者ID:omsys-dev,项目名称:original-source,代码行数:31,代码来源:dcfili.cpp


示例18: setLeft

void GfxCropDialog::bindEvents()
{
	// Left text box
	text_left_->Bind(wxEVT_TEXT_ENTER, &GfxCropDialog::onTextEnter, this);
	text_left_->Bind(wxEVT_KILL_FOCUS, [&](wxFocusEvent& e) {
		setLeft();
		e.Skip();
	});

	// Top text box
	text_top_->Bind(wxEVT_TEXT_ENTER, &GfxCropDialog::onTextEnter, this);
	text_top_->Bind(wxEVT_KILL_FOCUS, [&](wxFocusEvent& e) {
		setTop();
		e.Skip();
	});

	// Right text box
	text_right_->Bind(wxEVT_TEXT_ENTER, &GfxCropDialog::onTextEnter, this);
	text_right_->Bind(wxEVT_KILL_FOCUS, [&](wxFocusEvent& e) {
		setRight();
		e.Skip();
	});

	// Bottom text box
	text_bottom_->Bind(wxEVT_TEXT_ENTER, &GfxCropDialog::onTextEnter, this);
	text_bottom_->Bind(wxEVT_KILL_FOCUS, [&](wxFocusEvent& e) {
		setBottom();
		e.Skip();
	});

	// Absolute/Relative radio buttons
	rb_absolute_->Bind(wxEVT_RADIOBUTTON, [&](wxCommandEvent&) { updateValues(); });
	rb_relative_->Bind(wxEVT_RADIOBUTTON, [&](wxCommandEvent&) { updateValues(); });
}
开发者ID:SteelTitanium,项目名称:SLADE,代码行数:34,代码来源:GfxCropDialog.cpp


示例19: printf

// -1 is max left
// 0 is max forward
// 1 is max right
void MotorController::arc(double direction, double speedScale) {
    if (abs(direction) > 1)direction /= abs(direction); //makes direction between 1 & -1
    printf("Direction: %f\n", direction);

    if (direction < 0) { //left
        setLeft((int) (LEFT_MAX * (1 - abs((int) direction)) *
                       speedScale));    //sets the left motor to something less than the max speed
        setRight((int) (RIGHT_MAX * (speedScale - 0.05)));                        //sets the right motor to max speed
    } else if (direction > 0) { //right
        setLeft((int) (LEFT_MAX * speedScale));                        //sets the left motor the max speed
        setRight((int) (RIGHT_MAX * (1 - direction) *
                        speedScale));     //sets the right motor to something less than the max speed
    } else if (direction == 0) {
        moveForward();
    }

}
开发者ID:dylan-chong,项目名称:a-team-engr101-avc,代码行数:20,代码来源:MotorController.cpp


示例20: setBottom

/*!
 
  Constructs a rectangle with \e topLeft the top-left corner location
  and \e bottomRight the bottom-right corner.

*/
vpRect::vpRect(const vpImagePoint &topLeft, const vpImagePoint &bottomRight)
{
  this->left = topLeft.get_u();
  this->top = topLeft.get_v();
  
  setBottom( bottomRight.get_v() );
  setRight( bottomRight.get_u() );
};
开发者ID:ILoveFree2,项目名称:visp-deb,代码行数:14,代码来源:vpRect.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ setRoleNames函数代码示例发布时间:2022-05-30
下一篇:
C++ setResult函数代码示例发布时间: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