You have stumbled upon something which has plagued us since we began the alice project: order of operations matters in linear algebra (and it bites you hard when you do moves and turns together).

Here's some example code:

DoTogether
	DoInOrder
		box roll left 1/4
		box roll right 1/4
	DoInOrder
		box move forward 5
		box move backward 5

Looks great. Each second line inverts its first line. Why doesn't it produce the desired inverse when the animation engine gets a hold of it? Well, it gets broken up into a whole bunch of RollALittles and MoveALittles.

frame                      # start first lines
	RollALittle Left
	MoveALittle Forward
frame
	RollALittle Left
	MoveALittle Forward
frame
	RollALittle Left
	MoveALittle Forward
.
.
.
frame                      # - start second lines
	RollALittle Right
	MoveALittle Backward
frame
	RollALittle Right
	MoveALittle Backward
frame
	RollALittle Right
	MoveALittle Backward
.
.
.

Since order of operation matters, to produce an inverse each step must be mirrored. The MoveALittles need to come first in the inverse frames.

   +---------------------------------------+
   |                                       |
   |           +---------------+           |
   |           |               |           |
   V           V               V           V
                       |
RollLeft  MoveForward  |  MoveBackward  RollRight

Rewriting the code to look like:

DoInOrder
	DoTogether
		box roll left 1/4
		box move forward 5
	DoTogether
		box move backward 5
		box roll right 1/4

Produces:

frame                      # start first lines
	RollALittle Left
	MoveALittle Forward
frame
	RollALittle Left
	MoveALittle Forward
frame
	RollALittle Left
	MoveALittle Forward
.
.
.
frame                      # start second lines
	MoveALittle Backward
	RollALittle Right
frame
	MoveALittle Backward
	RollALittle Right
frame
	MoveALittle Backward
	RollALittle Right
.
.
.

Which works like a charm. (I'm sorry this isn't coming out as clear as I would like, but I hope it is shedding some light.)

Back


Alice is made freely available as a public service.
Alice v2.0 © 2002-2003, Carnegie Mellon University. All rights reserved.
We gratefully acknowledge the University of Virginia, where the Alice project originated.
We gratefully acknowledge the financial support of DARPA, Intel, Microsoft, NSF, and ONR.