Class PjLinear
- java.lang.Object
-
- jv.object.PsObject
-
- jv.project.PjProject
-
- vgp.tutor.linear.PjLinear
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, PsTimeListenerIf, PsUpdateIf, PvPickListenerIf
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.
- See Also:
- Serialized Form
- Author:
- Konrad Polthier
- Version:
- 05.11.02, 1.30 revised (ep) Use perspective camera for cross product.
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)
-
-
Field Summary
Fields Modifier and Type Field and Description static intMODE_ADDSummation mode, result is sum of two argument vectors.static intMODE_CROSSCross product mode, result is cross product of two argument vectors.static intMODE_SUBDifference mode, result is difference of two argument vectors.-
Fields inherited from class jv.object.PsObject
HAS_BOUNDARY_PANEL, HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, IS_SELECTED, IS_USED, NUM_TAGS
-
-
Constructor Summary
Constructors Constructor and Description PjLinear()Constructors creates two argument vectors and a result vector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidcomputeResult(int mode)Perform vector arithmetic on two argument vectors to compute the result vector.intgetMode()Get the current computation mode, possibly values are MODE_... constants.voidinit()Initialize all instance variables of this project.intsetMode(int mode)Set the current computation mode, possibly values are MODE_... constants.voidstart()Method is invoked during loading of a project in JavaView.booleanupdate(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, getParameterInfo, getViewer, hasAnimation, hasDisplay, isEnabledAutoFit, markVertices, pickDisplay, pickInitial, pickVertex, removeDisplay, removeGeometries, removeGeometry, selectDisplay, selectGeometry, setAnimation, setBackColor, setBorderType, setDisplay, setEnabledAutoFit, setGeometry, setParameterInfo, setTime, setViewer, stop, unmarkVertices
-
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, setTag, toString, updatePanels
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jv.anim.PsTimeListenerIf
getName
-
Methods inherited from interface jv.project.PvPickListenerIf
getName
-
-
-
-
Field Detail
-
MODE_ADD
public static final int MODE_ADD
Summation mode, result is sum of two argument vectors.- See Also:
- Constant Field Values
-
MODE_SUB
public static final int MODE_SUB
Difference mode, result is difference of two argument vectors.- See Also:
- Constant Field Values
-
MODE_CROSS
public static final int MODE_CROSS
Cross product mode, result is cross product of two argument vectors.- See Also:
- Constant Field Values
-
-
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 reset. Therefore, allocations of instance variables should be performed in the constructor of the project.
-
start
public void start()
Description copied from class:PjProjectMethod 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:
startin classPjProject- See Also:
PvViewerIf.start(),PjProject.isEnabledAutoFit()
-
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.- Specified by:
updatein interfacePsUpdateIf- Overrides:
updatein classPsObject- Parameters:
event- carries a lot of information- Returns:
- true if event has been handled, otherwise false
- See Also:
PsObject.setParent(PsUpdateIf),PsObject.getFather(),PsObject.addUpdateListener(PsUpdateIf)
-
-
"