Пример #1
0
void goalPos(goal_t *goal) {
	int x, y;
	float dx, dy, da, dd, goal_a;

	x = goal->data.pos_data.x;
	y = goal->data.pos_data.y;
	dx = x - current_pos.x;
	dy = y - current_pos.y;
	goal_a = atan2(dy, dx);
	da = (goal_a - current_pos.angle);
	da = moduloTwoPI(da);
	dd = sqrt(pow(dx, 2.0)+pow(dy, 2.0));

	if (goal->data.pos_data.d == ANY) {
		if (abs(da) > CONE_ALIGNEMENT) {
			da = moduloPI(da);
			dd = - dd;
		}
	} else if (goal->data.pos_data.d == BACKWARD) {
		dd = - dd;
		da = moduloTwoPI(da+M_PI);
	}

	if (controlPos(dd, da) & POS_REACHED) {
		goal->is_reached = 1;
	}
	applyPID();
}
Пример #2
0
void goalAngle(goal_t *goal) {
	float angle, da;
	angle = goal->data.ang_data.angle;
	da = angle - current_pos.angle;

	if (goal->data.ang_data.modulo) {
		da = moduloTwoPI(da);
	}
	
	if (controlPos(0, da) & ANG_REACHED) {
		goal->is_reached = 1;
	}
	applyPID();
}
Пример #3
0
 //--------------------------------------------------------------
 void LayoutManager::positionControl(Control &control, ofVec2f &parentScale, int panelDepth) {
     // calculate scale
     ofVec2f curScale = parentScale * control.scale;
     
     int indent = panelDepth * control.getConfig()->layout.indent;
     
     // update dimensions
     control.width = control.layout.width * curScale.x;// ? control.layout.width : control.getConfig()->layout.columnWidth - indent) * curScale.x;
     control.height = control.layout.height * curScale.y;// ? control.layout.height : control.getConfig()->layout.buttonHeight) * curScale.y;
     
     
     // TODO: think about scales
     switch(control.layout.positionMode) {
         case LayoutSettings::kRelative: // normal (controls are placed in a free flowing manner, like html, layout.position is offset off calculated)
         {
             ofVec2f newHead(_curHead);
             ofVec2f controlOffset((control.layout.position + control.layout.paddingPre) * curScale);
             ofVec2f controlPos(newHead + controlOffset);
             float postHeight = (control.height + control.layout.paddingPost.y + control.getConfig()->layout.padding.y) * curScale.y;
             //                        if(control.layout.newColumn || (doWrap && controlPos.y + postHeight > maxPos.y)) {
             //                            newHead.x = control.getParent()->getRight() + control.layout.paddingPost.x + control.getConfig()->layout.padding.x;
             //                            newHead.y = boundRect.y;
             //                            controlPos = newHead + controlOffset;
             //                        }
             control.setPosition(controlPos);
             control.x += indent * curScale.x;
             
             if(control.layout.doAffectFlow) {
                 _curHead = newHead;
                 
                 if(control.height != 0) _curHead.y += postHeight;   // dont do padding if height is 0
             }
             
         }
             break;
             
         case LayoutSettings::kAbsolute: // layout.position is relative to container
             control.setPosition(control.getParent() ? (control.getParent()->position + control.layout.position) : control.layout.position);
             break;
             
         case LayoutSettings::kFixed: // layout.position is relative to screen
             control.setPosition(control.layout.position);
             break;
     }
 }