Class CoorSys

java.lang.Object
  |
  +--CoorSys
Direct Known Subclasses:
ViewPlane

public class CoorSys
extends Object
implements TreeNode, Cloneable

The representation of a coordinate system.

Author:
Sasmito Adibowo - 1299000029

Field Summary
private  Vector children
          The children of this coordinate system.
private  Jama.Matrix forwardMatrix
          The transformation matrix from a point in the real world to a point in the current coordinate system.
protected  String name
          the name of the coordinate system.
private  CoorSys parent
          the parent of this coordinate system.
static CoorSys REAL_WORLD
          The RealWorld coordinate system.
private  Jama.Matrix reverseMatrix
          The transformation matrix from a point in the current coordinate system to a point in the real world.
 
Constructor Summary
CoorSys(String name)
          Create RealWord root coordinate.
CoorSys(String name, CoorSys parent, Jama.Matrix m)
          Creates a child coordinate system based on the transformation matrix.
CoorSys(String name, Jama.Matrix m)
          Creates a root coordinate system based on the transformation matrix.
 
Method Summary
protected  void attachChild(CoorSys child)
          Attaches a child to this node.
 Enumeration children()
          Returns an enumeration to the children.
 Object clone()
          Clones this object and its parents.
 void fromRealWorld(Point3D[] src, Point3D[] dest)
          Converts points from RealWorld to a point in this coordinate system.
 void fromRealWorld(Point3D src, Point3D dest)
          Converts a point from RealWorld to a point in this coordinate system.
 boolean getAllowsChildren()
          Always returns true.
 TreeNode getChildAt(int childIndex)
          Returns the child at the specified index.
 int getChildCount()
          Returns the number of child of this node.
 Jama.Matrix getForwardMatrix()
          Returns the transformation matrix.
 int getIndex(TreeNode node)
          Returns the index of the specified child.
 String getName()
          Returns the name of the coordinate system.
 TreeNode getParent()
          Returns the parent of this coorsys.
 Jama.Matrix getReverseMatrix()
          Returns the inverse transformation matrix.
 boolean isLeaf()
          Returns true if the this cooorsys has no children.
 void setForwardMatrix(Jama.Matrix m)
          Sets the transformation matrix from a point in the real world to a point in the current coordinate system.
 void setReverseMatrix(Jama.Matrix m)
          Sets the transformation matrix from a point in the current coordinate system to a point in the real world.
 void toRealWorld(Point3D[] src, Point3D[] dest)
          Converts points in RealWorld to points in this coordinate system.
 void toRealWorld(Point3D src, Point3D dest)
          Converts a point in RealWorld to a point in this coordinate system.
 String toString()
          Returns the name of this coordinate system.
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

name

protected String name
the name of the coordinate system.

parent

private CoorSys parent
the parent of this coordinate system.

children

private Vector children
The children of this coordinate system.

forwardMatrix

private Jama.Matrix forwardMatrix
The transformation matrix from a point in the real world to a point in the current coordinate system.
See Also:
reverseMatrix

reverseMatrix

private Jama.Matrix reverseMatrix
The transformation matrix from a point in the current coordinate system to a point in the real world.
See Also:
forwardMatrix

REAL_WORLD

public static final CoorSys REAL_WORLD
The RealWorld coordinate system.
Constructor Detail

CoorSys

public CoorSys(String name)
Create RealWord root coordinate.
Parameters:
name - the name of the coordinate system.

CoorSys

public CoorSys(String name,
               Jama.Matrix m)
Creates a root coordinate system based on the transformation matrix. Use Transformation.createXxxx to create transformation matrices for the coordinate system.
Parameters:
m - the 4x4 homogeneous forward transformation matrix.
name - the name of the coordinate system.
See Also:
Transformation

CoorSys

public CoorSys(String name,
               CoorSys parent,
               Jama.Matrix m)
Creates a child coordinate system based on the transformation matrix.
Parameters:
name - the name of the coordinate system.
parent -  
m - the forward transformation matrix.
Method Detail

attachChild

protected void attachChild(CoorSys child)
Attaches a child to this node.
Parameters:
child - the child node to attach.

clone

public Object clone()
Clones this object and its parents.
Overrides:
clone in class Object

getName

public String getName()
Returns the name of the coordinate system.

getParent

public TreeNode getParent()
Returns the parent of this coorsys.
Specified by:
getParent in interface TreeNode

getAllowsChildren

public boolean getAllowsChildren()
Always returns true.
Specified by:
getAllowsChildren in interface TreeNode

getChildAt

public TreeNode getChildAt(int childIndex)
Returns the child at the specified index.
Specified by:
getChildAt in interface TreeNode

getChildCount

public int getChildCount()
Returns the number of child of this node.
Specified by:
getChildCount in interface TreeNode

getIndex

public int getIndex(TreeNode node)
Returns the index of the specified child.
Specified by:
getIndex in interface TreeNode

isLeaf

public boolean isLeaf()
Returns true if the this cooorsys has no children.
Specified by:
isLeaf in interface TreeNode

children

public Enumeration children()
Returns an enumeration to the children.
Specified by:
children in interface TreeNode

setForwardMatrix

public void setForwardMatrix(Jama.Matrix m)
Sets the transformation matrix from a point in the real world to a point in the current coordinate system. Sets forwardMatrix and updates reverseMatrix.
Parameters:
m - new value for forwardMatrix
See Also:
forwardMatrix, reverseMatrix

setReverseMatrix

public void setReverseMatrix(Jama.Matrix m)
Sets the transformation matrix from a point in the current coordinate system to a point in the real world. Sets reverseMatrix and updates forwardMatrix.
Parameters:
m - new value for reverseMatrix
See Also:
forwardMatrix, reverseMatrix

getForwardMatrix

public Jama.Matrix getForwardMatrix()
Returns the transformation matrix.

getReverseMatrix

public Jama.Matrix getReverseMatrix()
Returns the inverse transformation matrix. NOTE: matrix inverse not implemented.

fromRealWorld

public void fromRealWorld(Point3D src,
                          Point3D dest)
Converts a point from RealWorld to a point in this coordinate system.
Parameters:
src - the coordinate in RealWorld.
dest - the corresponding point in this coordinate system will be placed here.

fromRealWorld

public void fromRealWorld(Point3D[] src,
                          Point3D[] dest)
Converts points from RealWorld to a point in this coordinate system.
Parameters:
src - the points in RealWorld.
dst - the corresponding points in this coordinate system will be placed here.

toRealWorld

public void toRealWorld(Point3D src,
                        Point3D dest)
Converts a point in RealWorld to a point in this coordinate system.
Parameters:
src - the point in this coordinate system.
dest - the corresponding point in RealWorld will be placed here.

toRealWorld

public void toRealWorld(Point3D[] src,
                        Point3D[] dest)
Converts points in RealWorld to points in this coordinate system.
Parameters:
src - the points in Re

toString

public String toString()
Returns the name of this coordinate system.
Overrides:
toString in class Object