I'm having some troubles to display correctly a rotated box in 3d. I'm sparing you the details, but basically I'm recovering Euler angles from arduino+sensor, and using processing for display.
When the cube is rotated along one single axis, it works perfectly fine, but with 2 or 3 axis combined, the cube's rotation is erratic. I've noticed in that case the only working rotation is the first one applied. I'm not using rotatex() rotatey() rotatez() since it changes the reference frame for future rotation each time called, instead I'm using a custom function found on an other post in this forum :
That function creates and applies a rotation matrix for all 3 euler angles, it should work fine. However the cube is still showing the same erratic behavior.
The draw loop :
void draw ()
{
float roll,pitch,yaw;
roll = radians(finalAngles[0][currentVal]);
pitch = radians(finalAngles[1][currentVal]);
yaw = radians(finalAngles[2][currentVal]);
stroke(127,34,255);
fill(27,34,55);
//pushMatrix();
rotateXYZ(roll,yaw,pitch);
box(100);
//popMatrix();
}
Feel free to share your experience if you've encountered problems of that kind with rotations, it might help. Or even the solution if you have it :)