- If you implemented Hermite or Bezier for last week's assignment, then implement B-Spline (the simplest one: Uniform Non-Rational).
- If you implemented B-Spline, then implement either Hermite or Bezier.

Implement a simple motion machine. Your motion machine should implement at least the following instructions (feel free to implement more as well, such as other shape drawing primitives):

- Initialize: M[0] = identity; n = 1
- PushCopy: M[n] = M[n-1] ; n++
- Pop: n--
- RotateX(theta): M[n-1].rotateX(theta)
- RotateY(theta): M[n-1].rotateY(theta)
- RotateZ(theta): M[n-1].rotateZ(theta)
- Translate(x,y,z): M[n-1].translate(x,y,z)
- Scale(s): M[n-1].scale(s)
- Scale(x,y,z): M[n-1].scale(x,y,z)
- DrawLine(p1,p2): drawLine(viewport(p1.transform(M[n-1]), viewport(p2.transform(M[n-1])))
- ... // any other shape drawing instructions you'd like to implement

*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); } }