i think translate sets the origin of the rotation.
the upper-left corner is the origin of the canvas and without a translation transform the shape will rotate around that point. if you translate first to the centre of the shape that becomes the origin of the rotation instead. well that’s my understanding at least.
One thing I miss in the Processing APIs compared to eg. Java2D is a form of rotate() that also takes the centre point to rotate around. Basically the concatenation of translate, rotate, translate back.
In general, core devs are quite conservative about adding signatures due in part to maintenance headaches, but to me this does seem useful – in particular, conceptually useful for learners. The main downside from a project maintenance perspective might be that in addition to the reference, the major tutorials and examples don’t discuss it, so ideally they would also be updated.
@Chrisir – if you test your sponge with pushMatrix or with translate, which is faster? I’m curious. (Also, I wonder if it is the same for Java2D, P2D, P3D).
Pardon me, I mean test atomic calls. Clearly if you only push and pop once, then use local relative variables, that is faster. But 2000 translates is faster than 1000 pushes and 1000 pops – I think? The point being that the each form is “faster” depending on how you are using it in the larger code construct.
I thought it would clash with an existing P3D rotate() method but it seems not. Always thought it should be more like rotateAt() or rotateAround(). I have a few extra methods like that in PraxisLIVE (such as 7 parameter image()) but haven’t quite got around to this one yet.
Interestingly, there is a 4 parameter version of rotate() in Processing already though -
* Rotate around an arbitrary vector, similar to glRotate(), except that it
* takes radians (instead of degrees).
public void rotate(float angle, float v0, float v1, float v2)