Simple interactive linear algebra applet performs vector calculations
on two vectors and shows the result vector.

The result vector has 3D coordinates because of the possible cross product mode.
Nevertheless, the dimension of the two argument vectors has been chosen 2D
since then the vectors always lie in the xy-plane in the display, even
if the camera is in perspective mode. This makes the dragging of the argument
vectors in cross product mode more intuitive. Note, the method computeResult()
may be simplified a little if one chooses 3D coordinates for all vectors.

MODE_CROSS

Constructor Detail

PjLinear

public PjLinear()

Constructors creates two argument vectors and a result vector. Initializations
of instance variables should be performed within the init() method
to allow resetting the project later by simply calling the init() method.

Method Detail

init

public void init()

Initialize all instance variables of this project. This method
is invoked during the construction of this project and whenever
this project is resetted. Therefore, allocations of instance variables
should be performed in the constructor of the project.

start

If a project has an animation object, then the animation panel is shown
when the project's this start() method is invoked during loading
of the project. Use setAnimation(PsAnimation)
to register an animation.

getMode

Get the current computation mode, possibly values are MODE_... constants.

setMode

public int setMode(int mode)

Set the current computation mode, possibly values are MODE_... constants.
Method also recomputes the result vector and initiates a redraw.

computeResult

public void computeResult(int mode)

Perform vector arithmetic on two argument vectors to compute the result vector.
This method could be made simpler if one uses 3D coordinates for
argument vectors too.

update

public boolean update(java.lang.Object event)

Perform recomputations whenever a child has changed. Here the two argument
vectors have registered this class as parent, therefore, we are able to catch
their update events and recompute the result vectors if they have changed.
Method is usually invoked from the children.