Note: Depending on how you've implemented your Matrix3D class, it might work better for you to either preMultiply or postMultiply to implement the rotate and translate methods for this assignment. You might want to try both, and use whichever multiplication order produces the most sensible results.
I'd like you to use your motion machine instructions to implement a simple walking stick-figure, like I showed at the end of class (but yours should also have arms). For now, you can implement each instruction as a method in a class MotionMachine, and you can implement the stick-figure as a sequence of method calls to a MotionMachine object.
One way to do this is to implement a method that calls a sequence of motion machine instructions. For example, here is a simple bouncing ball, implemented as a method consisting of calls to a motion machine:
BouncingBall(MotionMachine mm, double time) { mm.Initialize(); mm.Translate(0, 1 - cos(time), 0); mm.DrawSphere(0,0,0,1); // x,y,z,radius }
If you follow this approach, you need to implement a method StickFigure that takes a MotionMachine mm and a double time argument. This method should consist of nothing but a sequence of method calls on mm, as in the bouncing ball example I gave above. Call this method repeatedly (rerendering each time) to make an animation of the figure walking.
Hint: try putting sin and cos calls into the arguments to your Rotate instructions to make the limbs rotate, like I did above to make the ball bounce.
Alternately, if you prefer, you can implement a class StickFigure that extends MotionMachine, and contains a method void render(double time). You may find this cleaner. If you do things this way, you'll probably want to add a default render method to MotionMachine that just calls the Initialize method.
Doing the ball this way would have resulted in:
class BouncingBall extends MotionMachine { void render(double time) { super.render(time); Translate(0, 1 - cos(time), 0); DrawSphere(0,0,0,1); } }