Transform, Rotate, and a splash of Scale

I sat down with Deqing Sun yesterday and tried to wrap my head around a more formal understanding of the relationship between transform, rotate and scale within an orthographically projected/viewed “3D” scene. We fired up processing and took a gander at a simplified problem: how to manipulate a 2D object within 3D space. Quickly we realized that the order with which these operations are performed is the essential element.

``` float eyePoint = 1000; void setup(){ size(600,600,P3D); } ```

```void draw(){ background(200); translate(300,300); translate(0,0,eyePoint); rotateY((mouseY-300)/300.0*(0.5*PI)); scale(300.0/mouseX); translate(0,0,-eyePoint); rect(-20,-20,40,40); } ```

Note that we’re translating three times. Here’s why: first we translate to the middle of the screen, then we translate on the Z axis to the point around which we want to rotate and then we translate back to our original position. Another way to say this is, we nest the rotation commands inside of an operation that translates to the coordinate around which we wish to rotate.

I then reworked these operations in openFrameworks / C++. Robby Tilton helped me realize that for my purposes, I could just drop scale all together. I’m not interested in changing the field of view, or truly “scaling” the scene — just in navigating within it based on arbitrary input. As I understand it, I don’t need to change the relative distance between objects — just the distance between objects and a viewpoint, and then angle from which those objects will be “projected” on the screen.

So I dropped scale — but not before I had a little fun (see picture). When it comes to building the impressionistic side of the re(time) simulator, I think some scale distortions will make transitionary aesthetic elements as I try to provide the experience of traveling (briefly) back in time.