cz.cuni.utils.math
Class Polygon3D

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

public class Polygon3D
extends java.lang.Object


Field Summary
 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  Plane3D plane
           
 java.util.ArrayList vertices
          List of polygon's vertices.
 
Constructor Summary
Polygon3D()
           
Polygon3D(java.util.AbstractList iVertices)
           
Polygon3D(java.util.ArrayList iVertices)
           
Polygon3D(Polygon3D p)
           
Polygon3D(Vertex3D[] iVertices)
           
Polygon3D(Vertex3D[] iVertices, Tuple3D normal)
           
 
Method Summary
 void add(Vertex3D v)
           
 void deleteColinear()
          Deletes collinear points from polygon.
 void deleteColinear(double precision)
          Deletes collinear points from polygon.
 Vertex3D get(int index)
           
 Vertex3D getCircular(int index)
           
 int getCircularIndex(int index)
           
 Tuple3D getEstimatedMiddlePoint()
          "Guess" the inner point ... average of all vertices
 Tuple3D getNormal()
          Returns normal of property 'plane'.
 Plane3D getPlane()
          Returns property 'plane'.
protected  void checkAddMinMax(Vertex3D v)
          Is called when new vertex was added into polygon to check the min / max properties.
protected  void checkRemoveMinMax(Vertex3D v)
          Is called when vertex has been removed from polygon.
protected  void recountMinMax()
          Recount min / max properties.
 boolean recountPlane()
          Recounts plane equation, taking first three vertices from property 'vertices'.
 boolean recountPlane(Tuple3D normal)
          Recounts plane equation using normal provided.
 Vertex3D remove(int index)
           
 boolean remove(Vertex3D v)
           
 int size()
           
 void swapVertex(int index, Vertex3D newVertex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vertices

public java.util.ArrayList vertices
List of polygon's vertices. They are in order so the polygon can be drawn as a line strip.


plane

protected Plane3D plane

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

Constructor Detail

Polygon3D

public Polygon3D()

Polygon3D

public Polygon3D(Vertex3D[] iVertices)

Polygon3D

public Polygon3D(Vertex3D[] iVertices,
                 Tuple3D normal)

Polygon3D

public Polygon3D(java.util.AbstractList iVertices)

Polygon3D

public Polygon3D(java.util.ArrayList iVertices)

Polygon3D

public Polygon3D(Polygon3D p)
Method Detail

checkAddMinMax

protected void checkAddMinMax(Vertex3D v)
Is called when new vertex was added into polygon to check the min / max properties.

Parameters:
v -

checkRemoveMinMax

protected void checkRemoveMinMax(Vertex3D v)
Is called when vertex has been removed from polygon. If it has sense, we do recount of min / max properties.

Parameters:
v -

recountMinMax

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


add

public void add(Vertex3D v)

size

public int size()

get

public Vertex3D get(int index)

swapVertex

public void swapVertex(int index,
                       Vertex3D newVertex)

getCircularIndex

public int getCircularIndex(int index)

getCircular

public Vertex3D getCircular(int index)

remove

public Vertex3D remove(int index)

remove

public boolean remove(Vertex3D v)

recountPlane

public boolean recountPlane()
Recounts plane equation, taking first three vertices from property 'vertices'. Returns success (true) or failure (false).

Returns:
boolean

recountPlane

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


getPlane

public Plane3D getPlane()
Returns property 'plane'. If plane isn't counted, you should call recountPlane() first.


getNormal

public Tuple3D getNormal()
Returns normal of property 'plane'. If plane isn't counted, you've got a problem man, better call recountPlane() first.


deleteColinear

public void deleteColinear()
Deletes collinear points from polygon.


deleteColinear

public void deleteColinear(double precision)
Deletes collinear points from polygon.


getEstimatedMiddlePoint

public Tuple3D getEstimatedMiddlePoint()
"Guess" the inner point ... average of all vertices