Two ways to think about transforms

I was just answering a question for the Udacity Interactive Graphics MOOC. I had made a rather confusing lecture, much more involved and less informative that I would have liked, so today I wrote a re-do (sadly, it’s not easy to make a new video, since step 1 is “fly from Boston to San Francisco”). I’m still not thrilled with my description – what do you think? Is there a better way to talk about this subject? Anything I could improve? Surprisingly, this course still gets about 35 sign-ups a day (though I’m guessing maybe one of those actually finishes), so it’d be nice to make this lesson better.

Background: up to this point in the course I’d been showing how you typically write down transforms from right to left (OpenGL-style column-major matrices), e.g. “TR” means “rotate the object, then translate it (in world space) to some location.” In this lesson I wanted to point out that you can also read the transform order from left to right.

=================

You’re at 41 Avenue George V in Paris. Someone comes up and asks “How can I see the Arc de Triomphe?” You tell them, “Go up two blocks and then turn to the left – you can’t miss it.” Indeed, at 101 Avenue des Champs-Élysées he can see L’Arc de Triomphe.

So if you wanted to take this person and apply these two transforms, translation T (walk two blocks) and rotation R (turn about 60 degrees to the left), how would you write that out? Think about it for a minute, then scroll down for the answer. (And I like the disembodied arm to the right from Google’s street view).

2016-04-09_153558

The order is (right-to-left “application order”): TR. That is, you want to apply the rotation first, so that it doesn’t affect the translation. So you rotate the person 60 degrees to the left, then you translate him north two blocks north, which is then not affected by the rotation.

If you incorrectly used order RT, you would first translate him north two blocks, so far so good. But, as you saw in the snowman lesson, rotating after translation means the object is rotated around the origin from his present location; in this case, the person’s starting location is the origin. So performing a translation, then a rotation, would move him up two blocks north, then rotate him in a circle with a 2 block radius by 60 degrees, putting him somewhere else in the city (Rue Euler, I guess, which is a great coincidence that it’s named for a famous mathematician).

I hope you accept TR is the right order, then. But, to describe directions we definitely first said “perform T” – walk two blocks north – “then perform R” – rotate to the left 60 degrees. So we talk about directions in a left-to-right fashion. This may seem odd, as we are then describing the last transform that we apply, T, if we actually want to position the man in his environment.

The key thing here, and the point of the lesson, is that by specifying T first, we’re saying to the man, change your frame of reference to be 2 blocks north. From this new frame of reference, then rotate 60 degrees around where you’re standing, your new origin. It’s how we talk about directions. We don’t say “when you get to your final position, rotate 60 degrees left. Then, to get to your final position, walk two blocks north.”

The person walking has his own frame of reference, where he’s always the origin, and rotations are done relative to whichever way he’s facing at the time. To specify transforms when talking in these terms, an object-centric way of describing things, we describe “from left to right.” When we’re looking at the world and want to think how to make some other object take on a particular orientation and position, we tend to work from right to left, getting it oriented and them moving it into position.

However, it all depends. Moving a couch up a flight of stairs, down a hall, and next to a wall in room is a series of transforms, and again we specify them from left to right. We could also shortcut the process if we don’t care about the intermediate steps along the way. Say the couch is facing north, and we know it’ll end up facing east. We could specify the one 90 degree rotation to get it to face east, then the one XYZ translation to move it directly to its desired location – right to left order, so that the rotation doesn’t interfere with the translation.

The final effect of the transforms – a series of moves or the direct rotation and translation – have the same final effect. The point is, each way of thinking has its uses.

Tags:

4 comments

  1. sneftel’s avatar

    When teaching this stuff, I always used the metaphor of a spaceship, with transformations from the point of view of the pilot, versus those of Mission Control back on the ground.

  2. isonno’s avatar

    In his course notes for his graphics classes at NYU, Ken Perlin started embedding simple JavaScript code to animate the concepts. The ability to click ‘n drag on a concept can really help. Examples:

    http://mrl.nyu.edu/~perlin/courses/fall2013/sep25a/
    http://mrl.nyu.edu/~perlin/courses/fall2013/sep18/

    Another good example is this text on Bezier curves, fully illustrated with interactive diagrams:

    https://pomax.github.io/bezierinfo/ and

    https://www.khanacademy.org/partner-content/pixar/animate/parametric-curves/p/constructing-curves-using-repeated-linear-interpolation

    I remember many years ago (1980’s) when somebody showed an animation of repeated-linear interpolation to make a curve. You literally heard a gasp as the abstract concept clicked on for the whole audience at the same time.

  3. Eric’s avatar

    isonno, you’re preaching to the choir; I love demos, I made a lot of them for the MOOC: http://www.realtimerendering.com/udacity/?load=demo/unit7-view-pipeline.js and choose from the list. Most of these demos don’t stand on their own, they’re part of a lesson. Syllabus is here, with demos italicized: https://www.udacity.com/wiki/cs291/syllabus

    My question is how to get across the idea that there are two ways to think about a series of transforms, a left-to-right series of changes of the frame of reference, or right-to-left series of movements. If you have any ideas, let me know.

  4. Eric’s avatar

    Thanks, sneftel, I like this idea, the two points of view. I think this is good for relative coordinates vs. world coordinates.

    This one doesn’t fully work for my goal in that both views would explain the transforms in the same order, “burn fuel now to go in this direction”, “now fire the attitude adjustment boosters to rotate to a new orientation”, etc. So, they’d both read the transforms “left to right”. I’m hoping to come up with an example where it’s worth reading the transforms left to right for one task, while reading them right to left for another mental model for solving some different task. My second task of “how would you apply transforms to position the man?” is too contrived for me.

Comments are now closed.