vgp.tutor.linear
Class PjLinear
java.lang.Object
|
+--jv.object.PsObject
|
+--jv.project.PjProject
|
+--vgp.tutor.linear.PjLinear
- All Implemented Interfaces:
- java.lang.Cloneable, PsTimeListenerIf, PsUpdateIf, PvPickListenerIf, java.io.Serializable
- public class PjLinear
- extends PjProject
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.
- Version:
- 04.03.01, 1.20 revised (kp) Converted into a tutorial, and moved to vgp.tutor.
26.11.00, 1.10 revised (kp) Use global instead of local polygon colors.
22.10.00, 1.00 created (kp)
- Author:
- Konrad Polthier
- See Also:
- Serialized Form
|
Field Summary |
static int |
MODE_ADD
Summation mode, result is sum of two argument vectors. |
static int |
MODE_CROSS
Cross product mode, result is cross product of two argument vectors. |
static int |
MODE_SUB
Difference mode, result is difference of two argument vectors. |
| Fields inherited from class jv.object.PsObject |
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, NUM_TAGS |
|
Constructor Summary |
PjLinear()
Constructors creates two argument vectors and a result vector. |
|
Method Summary |
void |
computeResult(int mode)
Perform vector arithmetic on two argument vectors to compute the result vector.
|
int |
getMode()
Get the current computation mode, possibly values are MODE_... constants. |
void |
init()
Initialize all instance variables of this project. |
int |
setMode(int mode)
Set the current computation mode, possibly values are MODE_... constants.
|
void |
start()
Method is invoked during loading of a project in JavaView.
|
boolean |
update(java.lang.Object event)
Perform recomputations whenever a child has changed. |
| Methods inherited from class jv.project.PjProject |
addDisplay, addGeometry, addGeometry, dispose, dragDisplay, dragInitial, dragVertex, fitDisplays, getAnimation, getDisplay, getDisplays, getGeometry, getGeometry, getNumGeometries, getParameter, getViewer, hasAnimation, hasDisplay, isEnabledAutoFit, markVertices, pickDisplay, pickInitial, pickVertex, removeDisplay, removeGeometries, removeGeometry, selectDisplay, selectGeometry, setAnimation, setDisplay, setEnabledAutoFit, setParameter, setTime, setViewer, stop, unmarkVertices |
| Methods inherited from class jv.object.PsObject |
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, removeInspector, removeUpdateListener, setName, setParent, setTag, toString, updatePanels |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
MODE_ADD
public static final int MODE_ADD
- Summation mode, result is sum of two argument vectors.
MODE_SUB
public static final int MODE_SUB
- Difference mode, result is difference of two argument vectors.
MODE_CROSS
public static final int MODE_CROSS
- Cross product mode, result is cross product of two argument vectors.
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.
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.
- Overrides:
init in class PjProject
start
public void start()
- Description copied from class:
PjProject
- Method is invoked during loading of a project in JavaView.
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.
If auto fit is enabled then scenery is scaled to fit in each display.
- Overrides:
start in class PjProject
- Following copied from class:
jv.project.PjProject
- See Also:
PvViewerIf.start(),
#isEnabledAutoFit(boolean)
getMode
public int 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.
- Overrides:
update in class PsObject
- Following copied from interface:
jv.object.PsUpdateIf
- Parameters:
event - carries a lot of information- Returns:
- true if event has been handled, otherwise false
- See Also:
PsObject,
PsUpdateIf.getFather(),
PsUpdateIf.setParent(PsUpdateIf)
The software JavaView® is copyright protected. All Rights Reserved.