jwo.landserf.structure
Class Triangle

java.lang.Object
  extended byjwo.landserf.structure.Triangle
All Implemented Interfaces:
Serializable

public class Triangle
extends Object
implements Serializable

Stores a topological triangle. Used for Delaunay and TIN networks. Triangle contains 3 topological edges and a circumcircle (for Delaunay triangulation and Voronoi diagram). Adapted from Zhao and Saalfeld, 1996.

Version:
2.2, 28th February, 2002.
Author:
Jo Wood.
See Also:
Edge, Serialized Form

Constructor Summary
Triangle(Edge edge1, Edge edge2, Edge edge3)
          Creates a triangle from the three given edges.
Triangle(Edge edge1, Edge edge2, Edge edge3, boolean isolated)
          Creates a triangle from the three given edges.
Triangle(Vector edges, Edge edge1, Edge edge2, Edge edge3)
          Creates a triangle from the three given edges and stores them in their own Java vector.
 
Method Summary
 void calcCircumCircle()
          Calculates this triangle's circumcircle.
 float[] calcMER()
          Calculates the triangle's minimum enclosing rectangle.
 float[] calcMER(float[] mer)
          Calculates the minimum enclosing rectangle surrounding this triangle and the supplied MER.
 void calcPlane()
          Calculates the equation of the plane passing through all three points of the triangle.
 double getCircleRadius()
          Reports the radius of the circumcircle associated with this triangle.
 double getCircleX()
          Reports the x coordinate of circumcircle associated with this triangle.
 double getCircleY()
          Reports the y coordinate of circumcircle associated with this triangle.
 Edge getEdge()
          Reports an edge associated with this triangle.
 float getHeight(float px, float py)
          Interpolates the z value at a given location based on the plane passing though this triangle.
 float[] getTriangleX()
          Reports the 3 x coordinates of this triangle.
 float[] getTriangleY()
          Reports the 3 y coordinates of this triangle.
 float[] getTriangleZ()
          Reports the 3 z coordinates of this triangle.
 float getVersion()
          Reports the version of the object.
 boolean isInCircle(Node node)
          Determines if a given point is inside the triangle's circumcircle.
 boolean isInTriangle(Node node)
          Determines if a given point is inside the triangle.
 void removeEdges(Vector edges)
          Removes this triangle's three connected edges from a given Java vector.
 void setVersion(float version)
          Sets the version number of this object.
 String toString()
          Reports the coordinates of this triangle.
 void update(Edge edge1, Edge edge2, Edge edge3)
          Initialises the triangle by storing the given edges and calculating the triangle's circumcirle.
 void update(Edge edge1, Edge edge2, Edge edge3, boolean isolated)
          Initialises the triangle by storing the given edges and calculating the triangle's circumcirle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Triangle

public Triangle(Edge edge1,
                Edge edge2,
                Edge edge3)
Creates a triangle from the three given edges.

Parameters:
edge1 - First triangle edge.
edge2 - Second triangle edge.
edge3 - Third triangle edge.

Triangle

public Triangle(Edge edge1,
                Edge edge2,
                Edge edge3,
                boolean isolated)
Creates a triangle from the three given edges.

Parameters:
edge1 - First triangle edge.
edge2 - Second triangle edge.
edge3 - Third triangle edge.
isolated - Edges not linked to this triangle if true.

Triangle

public Triangle(Vector edges,
                Edge edge1,
                Edge edge2,
                Edge edge3)
Creates a triangle from the three given edges and stores them in their own Java vector.

Parameters:
edges - Java vector to contain the three edges.
edge1 - First triangle edge.
edge2 - Second triangle edge.
edge3 - Third triangle edge.
Method Detail

update

public void update(Edge edge1,
                   Edge edge2,
                   Edge edge3)
Initialises the triangle by storing the given edges and calculating the triangle's circumcirle.

Parameters:
edge1 - First triangle edge.
edge2 - Second triangle edge.
edge3 - Third triangle edge.

update

public void update(Edge edge1,
                   Edge edge2,
                   Edge edge3,
                   boolean isolated)
Initialises the triangle by storing the given edges and calculating the triangle's circumcirle.

Parameters:
edge1 - First triangle edge.
edge2 - Second triangle edge.
edge3 - Third triangle edge.
isolated - Edges not linked to this triangle if true.

isInTriangle

public boolean isInTriangle(Node node)
Determines if a given point is inside the triangle.

Parameters:
node - Node to test.
Returns:
True if point is inside triangle, false if outside.

isInCircle

public boolean isInCircle(Node node)
Determines if a given point is inside the triangle's circumcircle.

Parameters:
node - Node to test.
Returns:
True if point is inside circle, false if outside.

removeEdges

public void removeEdges(Vector edges)
Removes this triangle's three connected edges from a given Java vector.

Parameters:
edges - Java vector storing edges.

calcCircumCircle

public void calcCircumCircle()
Calculates this triangle's circumcircle.


calcPlane

public void calcPlane()
Calculates the equation of the plane passing through all three points of the triangle. Plane is represented as Ax + By + Cz + D = 0. The normal to the plane is the vector (A,B,C).


calcMER

public float[] calcMER()
Calculates the triangle's minimum enclosing rectangle. Array order is minX,minY,maxX,maxY.

Returns:
array holding minimum and maximum coordinates.

calcMER

public float[] calcMER(float[] mer)
Calculates the minimum enclosing rectangle surrounding this triangle and the supplied MER. Array order is minX, minY,maxX,maxY.

Parameters:
mer - Array storing some MER.
Returns:
array holding minimum and maximum coordinates.

getEdge

public Edge getEdge()
Reports an edge associated with this triangle.

Returns:
An edge associated with this triangle.

getCircleX

public double getCircleX()
Reports the x coordinate of circumcircle associated with this triangle.

Returns:
x coordinate of circumcircle associated with this triangle.

getCircleY

public double getCircleY()
Reports the y coordinate of circumcircle associated with this triangle.

Returns:
y coordinate of circumcircle associated with this triangle.

getCircleRadius

public double getCircleRadius()
Reports the radius of the circumcircle associated with this triangle.

Returns:
radius of circumcircle associated with this triangle.

getTriangleX

public float[] getTriangleX()
Reports the 3 x coordinates of this triangle.

Returns:
Array of three x coordinates representing this triangle.

getTriangleY

public float[] getTriangleY()
Reports the 3 y coordinates of this triangle.

Returns:
Array of three y coordinates representing this triangle.

getTriangleZ

public float[] getTriangleZ()
Reports the 3 z coordinates of this triangle.

Returns:
Array of three y coordinates representing this triangle.

getHeight

public float getHeight(float px,
                       float py)
Interpolates the z value at a given location based on the plane passing though this triangle.

Parameters:
px - x coordinate of the location to interpolate.
py - y coordinate of the location to interpolate.
Returns:
Interpolated height.

toString

public String toString()
Reports the coordinates of this triangle. Overrides the method in Object.


getVersion

public float getVersion()
Reports the version of the object. This can be useful when serialising future (changed) versions of this class.

Returns:
Version number of this object.

setVersion

public void setVersion(float version)
Sets the version number of this object.

Parameters:
version - Version number of this object.


Copyright Jo Wood, 1996-2005, last modified, 11th March, 2005