cz.cuni.utils.math.extended
Class Triangle2D

java.lang.Object
  extended by cz.cuni.utils.math.extended.Triangle2D

public class Triangle2D
extends java.lang.Object


Field Summary
 int hashCode
           
 double[] max
          contains maximums from vertices x, y ... indexed 0 == X, 1 == Y
 double[] min
          contains minimums from vertices x, y ... indexed 0 == X, 1 == Y
 Vertex2D[] vertices
          List of triangles vertices.
protected  java.util.HashMap verticesHM
          We will store vertices also in hashset allowing method equals() to be as fast as possible.
 
Constructor Summary
Triangle2D(Segment2D s1, Segment2D s2, Segment2D s3)
           
Triangle2D(Vertex2D v1, Vertex2D v2, Vertex2D v3)
           
 
Method Summary
protected  int countHashCode()
          If triangle is a one point ... hash code == 0 If exactly two vertices are the same ... hash code == 1 Otherwise we need to sort it according to verties' coordinates.
 boolean equals(java.lang.Object o)
           
 Tuple2D getOrthocenter()
           
 Vertex2D getVertex2D(int index)
           
 int hashCode()
           
 boolean hasVertex(Vertex2D v)
           
protected  void checkMinMax(Vertex2D v)
           
protected  void init()
           
protected  void initVertices(Vertex2D v1, Vertex2D v2, Vertex2D v3)
           
protected  void initVerticesFromEdges(Segment2D s1, Segment2D s2, Segment2D s3)
           
protected  void recountMinMax()
          Recount min / max properties.
protected  void setVertex(int index, Vertex2D vertex)
           
protected  void setVertexAndHS(int index, Vertex2D vertex)
           
 boolean swapVertex(Vertex2D toBeSwapped, Vertex2D newVertex)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

vertices

public Vertex2D[] vertices
List of triangles vertices.


verticesHM

protected java.util.HashMap verticesHM
We will store vertices also in hashset allowing method equals() to be as fast as possible.


min

public double[] min
contains minimums from vertices x, y ... indexed 0 == X, 1 == Y


max

public double[] max
contains maximums from vertices x, y ... indexed 0 == X, 1 == Y


hashCode

public final int hashCode
Constructor Detail

Triangle2D

public Triangle2D(Vertex2D v1,
                  Vertex2D v2,
                  Vertex2D v3)

Triangle2D

public Triangle2D(Segment2D s1,
                  Segment2D s2,
                  Segment2D s3)
Method Detail

init

protected void init()

initVertices

protected void initVertices(Vertex2D v1,
                            Vertex2D v2,
                            Vertex2D v3)

initVerticesFromEdges

protected void initVerticesFromEdges(Segment2D s1,
                                     Segment2D s2,
                                     Segment2D s3)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

countHashCode

protected int countHashCode()
If triangle is a one point ... hash code == 0 If exactly two vertices are the same ... hash code == 1 Otherwise we need to sort it according to verties' coordinates.

Returns:
hashCode

setVertexAndHS

protected void setVertexAndHS(int index,
                              Vertex2D vertex)

setVertex

protected void setVertex(int index,
                         Vertex2D vertex)

getVertex2D

public Vertex2D getVertex2D(int index)

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

checkMinMax

protected void checkMinMax(Vertex2D v)

recountMinMax

protected void recountMinMax()
Recount min / max properties. Set min/max to Double.max/min values a do the check.


hasVertex

public boolean hasVertex(Vertex2D v)

swapVertex

public boolean swapVertex(Vertex2D toBeSwapped,
                          Vertex2D newVertex)

getOrthocenter

public Tuple2D getOrthocenter()