This question may be useful to some people, but it is not posed correctly for my particular situation, please see:
Simulating simultaneous rotation of an object about a fixed origin given limited resources.
So, I am using the Processing programming language to create an animation where a box rolls around the screen. The tricky part is that the box can be moving in the X and the Y directions at the same time.
I am drawing the box by simply calling a function called box(), so I am not calculating the vertices based on rotation and then drawing the shape, rather, I am performing a rotation of the coordinate system itself and then drawing a box.
The problem here is that processing only lets you rotate about the world axis, so as much as I would like to do, say:
rotateX(radians(30)) to rotate the box 60 degrees to the right and then 30 degrees up, calling
rotateY() also shifts the X axis itself, so you don't get what you want.
I am looking to derive a trigonometric relationship (likely by taking advantage of the third axis, Z, which you normally wouldn't need to rotate) that I can use in order to simulate the rotation of an object about a fixed set of axis.
Let me try to use some examples to show you what I mean:
So this is what the box looks like if it is not rotated at all. There is also a Z axis, which I have drawn in blue, but you can't see it because of the angle. When the box is rotated it will become visible.
If, before I draw the box, I call:
Again, this is because when I rotated about the Y axis the relative angle of the X axis was shifted , so after the call to
rotateY(radians(60)) the axes were effectively like this:
I want to derive a relationship that I can use to simulate a way of rotation such that after performing
rotateY(radians(60)) the axis would effectively look like(drawing this one with paint:
To clarify, I don't care what the axes actually look like, I only want the end result to be equivalent to what it would be if the axes existed as they do in the picture above.
Again, I think this is possible if I utilize the third axis somehow as a way of correcting the rotation, but I am not sure how to go about it. I have been trying at it for a while now and I can't seem to get something that works across all situations.
You don't need to know programming to solve this. I am looking for some mathematical theories/formulas that I can use to my advantage.
Thanks in advance, hopefully the pictures make it clear. Please don't hesitate to ask me to clarify.