polyLine rotate with makeRotationMatrix

Hi nice Of people,
i tried to rotate a ofPolyline with a makeRotationMatrix
i would like to make it rotate just on X axis or just on Y axis
but unfortunately that turn as that want

Here my rotate fonction, fromVec is the center of the cube

ofPolyline testApp::polyLineRotate(ofPolyline& polyIn, ofVec3f fromVec,float AngleX,float AngleY,float AngleZ){
ofPolyline tempPoly;

for(int i=0; i<polyIn.size(); i++) {
ofPoint myPoint =polyIn[i];
ofMatrix4x4 mR1;
mR1.makeRotationMatrix(AngleX,fromVec,AngleY,fromVec,AngleZ,fromVec);
}
return tempPoly;
}

i tried many way but still wired
thanks

Hey tarrabass,

There’s a typo mistake with ‘ofPoint myPoint =polyIn’, should be ‘ofPoint myPoint =polyIn[j]’. If that’s not the problem, you could also try rotating the ofPoint directly with myPoint.rotate(angle, pivot, axis) instead of using matrix transform?

Good luck.

Edit- when i hit save on this post, it can’t seem to add the brackets[] with ‘i’ after ‘ofPoint myPoint =polyIn’, so I changed it to ‘j’. Your probably having the same problem, so you don’t have the typo mistake.

you right,
they area posting bug with i
so the proper code could be

ofPolyline testApp::polyLineRotate(ofPolyline& polyIn, ofVec3f fromVec,float AngleX,float AngleY,float AngleZ){
ofPolyline tempPoly;
for(int j=0; j<polyIn.size(); j++) {
ofPoint myPoint =polyIn[j];
ofMatrix4x4 mR1;
mR1.makeRotationMatrix(AngleX,fromVec,AngleY,fromVec,AngleZ,fromVec);
}
return tempPoly;
}

I used makeRotationMatrix because it’s look like i can choose the angle rotation on X, y, Z separately.
this is the point i did get in.
i just want to turn on X around the center, and as you can see on picture it turn on x,y and z
thanks

You can still rotate around a single axis with ofPoint rotate-

ofPoint axisXYZ(1,0,0); // rotates around X axis only
myPoint.rotate(angle, pivot, axisXYZ);

Wondering if u really need to rotate all the points individually? An easier option would just be to wrap the polyline draw in a translation/rotation matrix-

ofPushMatrix();
ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
ofRotateX(angle);
polyline.draw();
ofPopMatrix();