cz.cuni.utils.math.extended
Class Triangle3D

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

public class Triangle3D
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
protected  Tuple3D orthocenter
           
 Plane3D plane
           
 Vertex3D[] vertices
          List of triangles vertices in normalizedOrder.
protected  java.util.HashMap verticesHM
          We will store vertices also in hashset allowing method equals() to be as fast as possible.
 
Constructor Summary
Triangle3D(Segment3D s1, Segment3D s2, Segment3D s3)
           
Triangle3D(Vertex3D v1, Vertex3D v2, Vertex3D 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)
           
 Tuple3D getOrthocenter()
           
 Vertex3D getVertex3D(int index)
           
 int hashCode()
           
 boolean hasVertex(Vertex3D v)
           
protected  void checkMinMax(Vertex3D v)
           
protected  void init()
           
protected  void initVertices(Vertex3D v1, Vertex3D v2, Vertex3D v3)
           
protected  void initVerticesFromEdges(Segment3D s1, Segment3D s2, Segment3D s3)
           
protected  void recountMinMax()
          Recount min / max properties.
 void recountPlane()
          Recounts plane equation, taking first three vertices from property 'vertices'.
 void recountPlane(Tuple3D normal)
          Recounts plane equation using normal provided.
protected  void setVertex(int index, Vertex3D vertex)
           
protected  void setVertexAndHM(int index, Vertex3D vertex)
           
 boolean swapVertex(Vertex3D toBeSwapped, Vertex3D newVertex)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

vertices

public Vertex3D[] vertices
List of triangles vertices in normalizedOrder.


verticesHM

protected java.util.HashMap verticesHM
We will store vertices also in hashset allowing method equals() to be as fast as possible. Associated value is index pointing into 'vertices'.


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


plane

public Plane3D plane

orthocenter

protected Tuple3D orthocenter

hashCode

public final int hashCode
Constructor Detail

Triangle3D

public Triangle3D(Vertex3D v1,
                  Vertex3D v2,
                  Vertex3D v3)

Triangle3D

public Triangle3D(Segment3D s1,
                  Segment3D s2,
                  Segment3D s3)
Method Detail

init

protected void init()

initVertices

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

initVerticesFromEdges

protected void initVerticesFromEdges(Segment3D s1,
                                     Segment3D s2,
                                     Segment3D 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

setVertexAndHM

protected void setVertexAndHM(int index,
                              Vertex3D vertex)

setVertex

protected void setVertex(int index,
                         Vertex3D vertex)

getVertex3D

public Vertex3D getVertex3D(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(Vertex3D v)

recountMinMax

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


recountPlane

public void recountPlane()
Recounts plane equation, taking first three vertices from property 'vertices'.


recountPlane

public void recountPlane(Tuple3D normal)
Recounts plane equation using normal provided.


hasVertex

public boolean hasVertex(Vertex3D v)

swapVertex

public boolean swapVertex(Vertex3D toBeSwapped,
                          Vertex3D newVertex)

getOrthocenter

public Tuple3D getOrthocenter()