ProGAL.geom3d
Class PointList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<Point>
              extended by ProGAL.geom3d.PointList
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Point>, java.util.Collection<Point>, java.util.List<Point>, java.util.RandomAccess
Direct Known Subclasses:
EiffelPointList

public class PointList
extends java.util.ArrayList<Point>

An ArrayList-wrapper for storing 3d points. Adds functionality specific to point-sets such as finding centroid, diameter or covariance.

See Also:
Serialized Form

Constructor Summary
PointList()
          Construct an empty point-list.
PointList(java.util.Collection<Point> points)
           
PointList(Point[] elements)
          Construc a point-list from an array of points.
 
Method Summary
 PointList clone()
          Get a shallow copy of this list.
 LineSegment diameterSqrt3Approx()
          Get a segment seg between two points in the set such that diameter/sqrt(3) <= seg.
static PointList generatePointsInCube(int n)
          Construct a point-list containing n uniformly distributed random points in the unit cube.
static PointList generatePointsInCube(int n, double xL, double xH, double yL, double yH, double zL, double zH)
           
static PointList generatePointsOnSphere(int n)
          Construct a point-list of n evenly distributed points (not random) on the unit sphere.
static PointList generateRandomPointsOnSphere(int n)
          Construct a point-list of n uniformly distributed random points on the unit sphere.
 Point getCentroid()
          Get the centroid of the points.
 double getCoord(int k, int i)
          Returns the i'th coordinate of k'th point.
 Matrix3x3 getCovariance()
          Get the covariance of the points.
 LineSegment getDiameter()
          Get the diameter of the point set - trivial O(n^2) algorithm.
 Point getExtreme(Vector direction)
          Get the most extreme point in the direction specified by the vector.
 Point getExtremeBack()
          Get the deepest point (in case of ties the left topmost point is returned).
 Point getExtremeBottom()
          Get the lowest point (in case of ties the bottom rightmost point is returned).
 Point getExtremeFront()
          Get the frontmost point (in case of ties the front rightmost point is returned).
 int getExtremeIndex(int ix, int iy, int iz, boolean high)
          Get the index of the extreme point.
 int getExtremeIndex(Vector direction)
          Get the most extreme point in the direction specified by the vector.
 Point getExtremeLeft()
          Get the leftmost point (in case of ties the bottom lefttmost point is returned).
 Point getExtremeRight()
          Get the rightmost point (in case of ties the top rightmost point is returned).
 Point getExtremeTop()
          Get the highest point (in case of ties the left topmost point is returned).
 PointList getRandomPermutation()
          Returns a new point-list containing all the elements in random order.
 double getStandardDeviation()
          Get the standard deviation of the point set.
 PointList getSubList(int from, int to)
          Returns a sub-list of elements from (including) from to (not including) to.
 double getVariance()
          Get the variance of the points.
 void toConsole()
          Writes this point-list to System.out.
 void toConsole(int dec)
          Writes this point-list to System.out.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

PointList

public PointList()
Construct an empty point-list.


PointList

public PointList(Point[] elements)
Construc a point-list from an array of points.


PointList

public PointList(java.util.Collection<Point> points)
Method Detail

getCoord

public double getCoord(int k,
                       int i)
Returns the i'th coordinate of k'th point.


getSubList

public PointList getSubList(int from,
                            int to)
Returns a sub-list of elements from (including) from to (not including) to. The returned sub-list is not a 'view' of the sublist (such as AbstractList.subList), but a shallow copy of the specified range.


getRandomPermutation

public PointList getRandomPermutation()
Returns a new point-list containing all the elements in random order.


getCentroid

public Point getCentroid()
Get the centroid of the points.


getVariance

public double getVariance()
Get the variance of the points.


getCovariance

public Matrix3x3 getCovariance()
Get the covariance of the points.


getStandardDeviation

public double getStandardDeviation()
Get the standard deviation of the point set.


getExtreme

public Point getExtreme(Vector direction)
Get the most extreme point in the direction specified by the vector.


getExtremeIndex

public int getExtremeIndex(Vector direction)
Get the most extreme point in the direction specified by the vector.


getExtremeIndex

public int getExtremeIndex(int ix,
                           int iy,
                           int iz,
                           boolean high)
Get the index of the extreme point. Go along axis ix first, then iy and finally iz. If high is true, the index of the point with highest coordinate is returned. Otherwise the index of the point with lowest coordinate is returned. For instance
 PointList3d list = new PointList3d();
 list.add( new Point3d(0,0,0) );
 list.add( new Point3d(1,0,0) );
 list.add( new Point3d(0,1,0) );
 list.add( new Point3d(0,0,1) );
 System.out.println(list.getExtremeIndex(1,2,0,true));
 System.out.println(list.getExtremeIndex(1,2,0,false));
 
will print the indices 2 and 0.


getExtremeRight

public Point getExtremeRight()
Get the rightmost point (in case of ties the top rightmost point is returned).


getExtremeLeft

public Point getExtremeLeft()
Get the leftmost point (in case of ties the bottom lefttmost point is returned).


getExtremeTop

public Point getExtremeTop()
Get the highest point (in case of ties the left topmost point is returned).


getExtremeBottom

public Point getExtremeBottom()
Get the lowest point (in case of ties the bottom rightmost point is returned).


getExtremeFront

public Point getExtremeFront()
Get the frontmost point (in case of ties the front rightmost point is returned).


getExtremeBack

public Point getExtremeBack()
Get the deepest point (in case of ties the left topmost point is returned).


getDiameter

public LineSegment getDiameter()
Get the diameter of the point set - trivial O(n^2) algorithm.


diameterSqrt3Approx

public LineSegment diameterSqrt3Approx()
Get a segment seg between two points in the set such that diameter/sqrt(3) <= seg. Requires O(n) time.


clone

public PointList clone()
Get a shallow copy of this list.

Overrides:
clone in class java.util.ArrayList<Point>

toConsole

public void toConsole()
Writes this point-list to System.out.


toConsole

public void toConsole(int dec)
Writes this point-list to System.out.


generatePointsInCube

public static PointList generatePointsInCube(int n)
Construct a point-list containing n uniformly distributed random points in the unit cube. Uses the ProGAL.math.Randomization class.


generatePointsInCube

public static PointList generatePointsInCube(int n,
                                             double xL,
                                             double xH,
                                             double yL,
                                             double yH,
                                             double zL,
                                             double zH)

generateRandomPointsOnSphere

public static PointList generateRandomPointsOnSphere(int n)
Construct a point-list of n uniformly distributed random points on the unit sphere. Uses the ProGAL.math.Randomization class.


generatePointsOnSphere

public static PointList generatePointsOnSphere(int n)
Construct a point-list of n evenly distributed points (not random) on the unit sphere. Taken from http://www.cgafaq.info/wiki/Evenly_distributed_points_on_sphere