Need help trouble shooting

So i’m working on a program in which the user interacts with the face of a bear, The user drags the mouse to 1 of 3 objects. upon doing so the user is able to move the object on when clicked to the face of the bear, if these objects touch the bear’s face, the bear will display an emotion. one object makes the bear get teary eyed, one makes the bear angry, another makes the bear happy.

my issue right now is within the angry emotion. The “isAngry” boolean is set true when 2 different collision parameters are met. while in “isAngry” ive written code that when the pepper object is touching the bears face, its eyebrows go from relaxed to diagonal and its face becomes red. however, using the ofRotate function it draws the eyebrows at a different position, even though the position for where to draw eyebrows is well defined can i get some help trouble shooting this. I’ll post the codes so anyone with expert experience can help me find a solution to the issue.

**ofApp.h values.**

#pragma once

#include "ofMain.h"

class ofApp : public ofBaseApp{

	public:
		void setup();
		void update();
		void draw();

		void keyPressed(int key);
		void keyReleased(int key);
		void mouseMoved(int x, int y );
		void mouseDragged(int x, int y, int button);
		void mousePressed(int x, int y, int button);
		void mouseReleased(int x, int y, int button);
		void mouseEntered(int x, int y);
		void mouseExited(int x, int y);
		void windowResized(int w, int h);
		void dragEvent(ofDragInfo dragInfo);
		void gotMessage(ofMessage msg);
		
		//Bear head use vec2f for position
		ofVec2f bearHead;
		float bearHeadSize;

		//Bear tummy use vec2f for position
		ofVec2f tummy;
		float tummysize;

		ofVec2f innerTummy;
		float innerTummySize;

		//Bear arms use vec2f for position
		ofVec2f leftArm;
		ofVec2f rightArm;
		float  armSizeW;
		float armSizeH;
		

		//Bear eyes use vect2f for position
		ofVec2f bearEye;
		float bearEyeSize;
		ofVec2f bearEye2;

		//bear ear use vec2f for position
		ofVec2f bearEar;
		ofVec2f bearEar2;
		float   EarSize;

		//bear ear use vec2f for position
		ofVec2f innerEar;
		ofVec2f innerEar2;
		float   innerEarSize;

		//Bear eyebrows use vect2f for position

		ofVec2f bearEyebrow;
		ofVec2f bearEyebrow2;
		float bearEyebrowSizeW;
		float bearEyebrowSizeH;

		//mouse position
		ofVec2f handPos;
		float handSize;

		//honeycomb position
		ofVec2f honeyCombPos;
		float honeycombSize;


		//pepper position
		ofVec2f pepperPos;
		float pepperSize;
		bool pepperHeld;


		//orange position
		ofVec2f orangePos;
		float orangeSize;
		bool orangeHeld;



		// set emotion booleans to false

		bool isHappy;
		bool isAngry;
		bool isSad;
};





***ofApp.cpp values and code**
#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){

	//set up mouse position
	handPos.set(0, 0);
	handSize = 20;

	//set up honeycomb position
	honeyCombPos.set(500, 750);
	honeycombSize = 50;

	//set up pepper position
	pepperPos.set(200, 750);
	pepperSize = 50;

	//set up orange position
	orangePos.set(800, 750);
	orangeSize = 50;


	/*set bear's head values 
	1) bear's head position
	2) size of bear's head
	*/
	bearHead.set(450, 300);
	bearHeadSize = 150;

	/*set bear's ears values, bear's left and right ear position
	and size of bears ear*/
	bearEar.set(330, 160);
	bearEar2.set(560, 160);
	EarSize = 70;

	innerEar.set(330, 160);
	innerEar2.set(560, 160);
	innerEarSize = 35;




	/* set bear's eyebrows values
	1) bear's left eyebrow position and size
	2) bear's right eyebrow position and size
	*/

	bearEyebrow.set(340, 230);
	bearEyebrow2.set(500, 230);
	bearEyebrowSizeW = 60;
	bearEyebrowSizeH = 10;

	/* Set bear's eyes values
	1) left eye's values position
	left eyes size
	2) right eyes's position,
	right eyes' size
	*/

	bearEye.set(370, 270);
	bearEye2.set(530, 270);
	bearEyeSize = 30;

	
	

	//set background color
	ofSetBackgroundColor(0, 0, 0);

	// set emotion booleans to false

	 isHappy = false;
	 isAngry = false;
	 isSad = false;

	 orangeHeld = false;
	 pepperHeld = false;
	
}

//--------------------------------------------------------------
void ofApp::update(){

	//mouse hand
	handPos.x = ofGetMouseX();
	handPos.y = ofGetMouseY();



	//honeycomb to bear collision
	float dist = ofDist(honeyCombPos.x, honeyCombPos.y, bearHead.x, bearHead.y);
	if (dist < honeycombSize + bearHeadSize) {
		cout << "they touch!" << endl;
		isHappy = true;
	}
	else {
		isHappy = false;
	}

	
	//pepper to bear collision
	float dist2 = ofDist(pepperPos.x, pepperPos.y, bearHead.x, bearHead.y);
	if (dist2 < pepperSize + bearHeadSize) {
		isAngry = true;
	}
	else {
		isAngry = false;
	}

	

	//orange to bear collision
	float dist3 = ofDist(orangePos.x, orangePos.y, bearHead.x, bearHead.y);
	if (dist3 < orangeSize + bearHeadSize) {
		cout << "bear is sad!" << endl;
		isSad = true;
	}
	else {
		isSad = false;
	}


	//bear head
	bearHead.x = 450;
	bearHead.y = 300;

	//bear's left ear
	bearEar.x = 330;
	bearEar.y = 160;
	innerEar.x = 330;
	innerEar.y = 160;

	//bear's right ear
	bearEar2.x = 560; 
	bearEar2.y = 160;
	innerEar2.x = 560;
	innerEar2.y = 160;

	//bear left eye
	bearEye.x = 370;
	bearEye.y = 270;

	//bear right eye
	bearEye2.x = 530;
	bearEye2.y = 270;

	// bear left eyebrow
	bearEyebrow.x = 340;
	bearEyebrow.y = 230;

	// bear right eyebrow
	bearEyebrow2.x = 500;
	bearEyebrow2.y = 230;
}

//--------------------------------------------------------------
void ofApp::draw(){

	//draw the mouse
	ofSetColor(0, 0, 255);
	ofDrawCircle(handPos.x, handPos.y, handSize);

	//draw the emotion inducing foods
	ofSetColor(255, 206, 7);
	ofDrawCircle(honeyCombPos.x, honeyCombPos.y, honeycombSize);

	ofSetColor(97, 10, 13);
	ofDrawCircle(pepperPos.x, pepperPos.y, pepperSize);

	ofSetColor(235, 158, 26);
	ofDrawCircle(orangePos.x, orangePos.y, orangeSize);


	//draw the bear's head

	//Set color of bear's head
	ofSetColor(71, 47, 6);
	ofDrawCircle(bearHead.x, bearHead.y, bearHeadSize);
	if (isSad == true) {
		ofSetColor(0, 0, 132);
		ofDrawCircle(bearHead.x, bearHead.y, bearHeadSize);
	}

	//Set color of bear's ears
	ofSetColor(71, 48, 6);
	ofDrawCircle(bearEar.x, bearEar.y, EarSize);
	ofDrawCircle(bearEar2.x, bearEar2.y, EarSize);

	//set color of inner bear's ears
	ofSetColor(101, 67, 33);
	ofDrawCircle(innerEar.x, innerEar.y, innerEarSize);
	ofDrawCircle(innerEar2.x, innerEar2.y, innerEarSize);

	//draw bears eyes. set its color
	ofSetColor(0, 0, 0);
	ofDrawCircle(bearEye.x, bearEye.y, bearEyeSize);
	if (isSad == true) {
		float centerX = bearEye.x - 25;
		float centerY = bearEye.y + 20;

		float center1X = bearEye.x;
		float center1Y = bearEye.y;

		float xPupil = center1X;
		float yPupil = center1Y;

		float swarmDist = 25;
		float swarmSpeed = 0.3f;
		float size = .05 + ofNoise(ofGetElapsedTimef(), 3) * 2;
		ofSetColor(0, 0, 0);
		ofDrawCircle(bearEye.x, bearEye.y, bearEyeSize);
		for (int i = 0; i < 4; i++) {
			float noiseX = ofNoise(i, ofGetElapsedTimef()*swarmSpeed, 0);
			float noiseY = ofNoise(i, ofGetElapsedTimef()*swarmSpeed, 100);
			float xPos = centerX - swarmDist / 2 + noiseX * swarmDist;
			float yPos = centerY - swarmDist / 2 + noiseY * swarmDist;

			ofSetColor(255, 255, 255);
			ofDrawCircle(xPos, yPos, 5);

			

			ofPushMatrix();
			//

			ofTranslate(xPupil, yPupil);
			ofScale(size, size);
			ofDrawCircle(0, 0, 10);
			//
			ofPopMatrix();

		}
	}

	ofDrawCircle(bearEye2.x, bearEye2.y, bearEyeSize);
	if (isSad == true) {
		float centerXX = bearEye2.x - 25;
		float centerYY = bearEye2.y + 20;

		float center1XX = bearEye2.x;
		float center1YY = bearEye2.y;

		float xPupil1 = center1XX;
		float yPupil1 = center1YY;

		float swarmDist = 25;
		float swarmSpeed = 0.3f;
		float size = .05 + ofNoise(ofGetElapsedTimef(), 3) * 2;
		ofSetColor(0, 0, 0);
		ofDrawCircle(bearEye2.x, bearEye2.y, bearEyeSize);
		for (int i = 0; i < 4; i++) {
			float noiseX = ofNoise(i, ofGetElapsedTimef()*swarmSpeed, 0);
			float noiseY = ofNoise(i, ofGetElapsedTimef()*swarmSpeed, 100);
			float xPos1 = centerXX - swarmDist / 2 + noiseX * swarmDist;
			float yPos1 = centerYY - swarmDist / 2 + noiseY * swarmDist;

			ofSetColor(255, 255, 255);
			ofDrawCircle(xPos1, yPos1, 5);



			ofPushMatrix();
			//

			ofTranslate(xPupil1, yPupil1);
			ofScale(size, size);
			ofDrawCircle(0, 0, 10);
			//
			ofPopMatrix();

		}
	}

	//draw angry parameters

	if (isAngry == true) {

		// right eye and pupil
		

		ofSetColor(255, 0, 0);
		ofDrawCircle(bearHead.x, bearHead.y, bearHeadSize);


		// draw bear eyes

		
		ofSetColor(0, 0, 0);
		ofDrawCircle(bearEye.x, bearEye.y, bearEyeSize);
		ofDrawCircle(bearEye2.x, bearEye2.y, bearEyeSize);

        

	}




	// bears eyebrows, set color
	ofSetColor(101, 67, 33);
	ofDrawRectangle(bearEyebrow.x, bearEyebrow.y, bearEyebrowSizeW, bearEyebrowSizeH);
	ofDrawRectangle(bearEyebrow2.x, bearEyebrow2.y, bearEyebrowSizeW, bearEyebrowSizeH);

	if (isAngry == true) {



       // draw bear's eyebrows on an angle
		ofSetColor(101, 67, 33);		
		ofRotateZ(45);
		ofDrawRectangle(bearEyebrow.x, bearEyebrow.y, bearEyebrowSizeW, bearEyebrowSizeH);


	}

/*When eyebrows are drawn its it doesn't draw in the location specified in the bearEyebrow ofVec2f... and this occurs for both eyebrows within the **isAngry boolean** */

	if (isAngry == true) {
		ofSetColor(101, 67, 33);		
		ofRotateZ(135);
		ofDrawRectangle(bearEyebrow2.x, bearEyebrow2.y, bearEyebrowSizeW, bearEyebrowSizeH);
	}
}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){

}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){

}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){

	
}

//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
	cout << "mouse move " << orangeHeld << endl;
	if (orangeHeld == true) {
		cout << "moving" << endl;
		orangePos = handPos;
	}

	if (pepperHeld == true) {
		pepperPos = handPos;
	}
}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
	cout << "mouse position" << handPos.x << " " << handPos.y << endl;
	float dist4 = ofDist(orangePos.x, orangePos.y, handPos.x, handPos.y);
	if (dist4 < orangeSize + handSize) {
		orangeHeld = true;
		cout << "held now" << endl;
	}
	else {
		orangeHeld = false;
	}


	float dist5 = ofDist(pepperPos.x, pepperPos.y, handPos.x, handPos.y);
	if (dist5 < pepperSize + handSize) {
		pepperHeld = true;
		cout << "held now" << endl;
	}
	else {
		
		pepperHeld = false;
	}
}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
	orangeHeld = false;
	pepperHeld = false;
}

//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){

}

//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){

}

//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){ 

}

The x and y in ofDrawRectangle(x, y, w, h) are not necessarily absolute coordinates in the screen, but coordinates in the current coordinate system. When you call ofRotateZ(angle) you rotate the coordinate system, so X no longer points right. To see an example, run the program found below the video at https://www.funprogramming.org/30-Multiple-rotating-objects-and-reset-matrix.html directly in your browser.

That’s why in your previous thread I suggested to use first ofTranslate(x, y) to put the origin (the 0,0 position) wherever you want, then you rotate the coordinates with ofRotateZ() and finally you draw the rectangle at 0, 0.

If you want the rectangle to be centered wherever you specify use ofSetRectMode(OF_RECTMODE_CENTER); before drawing the rectangle.

Thank you, you’re suggestions and solutions have been a really big help.