I am guessing you started with code taken from the
applyMatrix() documentation:
Code:size(100, 100, P3D);
noFill();
translate(50, 50, 0);
rotateY(PI/6);
stroke(153);
box(35);
// Set rotation angles
float ct = cos(PI/9.0);
float st = sin(PI/9.0);
// Matrix for rotation around the Y axis
applyMatrix( ct, 0.0, st, 0.0,
0.0, 1.0, 0.0, 0.0,
-st, 0.0, ct, 0.0,
0.0, 0.0, 0.0, 1.0);
stroke(255);
box(50);
This is an advanced topic, and I suggest that if your aim is simply to rotate the object, you should try
rotateY() and similar functions.
I don't know exactly why your code does what it does, but it is clear that you are not using a "usual" transformation matrix for rotation - for starters, the "angle" term in your ct and st calculations should be the same (not +something and -something).
What you should be thinking about doing is modifying the angle slightly for each frame; if you negate it, that is a large change. What you want is to decrement the angle to make the cube turn in the opposite direction.
Code:float angle = 0; // current rotation angle
float angleStep = 0.01; // amount to adjust rotation angle by
// setup() { ... }
void draw()
{
// maybe translate(width, height) here to centre coordinates
angle += angleStep; // increase or decrease the rotation angle
rotateY(angle);
// draw something
}
void mousePressed()
{
angleStep *= -1; // reverse the _change_ in rotation angle
}
If you are intent on using applyMatrix(), I suggest you use the 'proper' matrix without trying to inject extra sign*blah terms; the idea is to adjust the angle, not change the functions.
-spxl