edu.stanford.rsl.konrad.geometry.shapes.simple
Class PointND

java.lang.Object
  extended by edu.stanford.rsl.konrad.geometry.shapes.simple.PointND
All Implemented Interfaces:
Transformable, java.io.Serializable
Direct Known Subclasses:
CAPIPoint, Point2D, Point3D, SortablePoint

public class PointND
extends java.lang.Object
implements java.io.Serializable, Transformable

Class to model points of arbitrary dimension. Compatible with numerics.

Author:
akmaier
See Also:
Serialized Form

Constructor Summary
PointND(double... point)
          Creates a new point of a given array or list of double values.
PointND(PointND point)
          Copy constructor
PointND(SimpleVector knotVector)
          Creates a new point of the specified dimension
 
Method Summary
 void applyTransform(Transform t)
          Applies the Transform t to the object.
 PointND clone()
           
 boolean equals(java.lang.Object o)
           
 double euclideanDistance(PointND two)
          computes the Euclidean distance between the current point $\mathbf{x_1} = (x_1, y_1)$ the the point "two" $\mathbf{x_2} = (x_2, y_2)$ as $|| \\mathbf{x_1} - \\mathbf{x_2} || = \\sqrt{\\sum_n(x_1(n) - x_2(n))^2}$.
 double get(int i)
          Method to retrieve coordinate entries
 SimpleVector getAbstractVector()
          Returns the internal abstract vector to enable computations via the numerics library.
Changes to the vector will affect the point
 double[] getCoordinates()
          Returns a copy of the point as double array.
 int getDimension()
          Returns the dimension of the point
 void set(int i, double d)
          Methods to set individual entries of the coordinates
 void setCoordinates(SimpleVector coordinates)
           
 java.lang.String toString()
           
 void updateIfHigher(PointND p)
          Updates the vector at entries which are higher in p.
 void updateIfLower(PointND p)
          Updates the vector at entries which are higher in p.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PointND

public PointND(SimpleVector knotVector)
Creates a new point of the specified dimension

Parameters:
knotVector - the dimension

PointND

public PointND(PointND point)
Copy constructor

Parameters:
point -

PointND

public PointND(double... point)
Creates a new point of a given array or list of double values.
        PointND p = new PointND(1.5, 2.5);
        ArbitrayrPoint p2 = new PointND(new double [] {1.5, 2.5});
 
will create two 2D points at the same location.

Parameters:
point -
Method Detail

setCoordinates

public void setCoordinates(SimpleVector coordinates)
Parameters:
coordinates - the coordinates to set

clone

public PointND clone()
Overrides:
clone in class java.lang.Object

getCoordinates

public double[] getCoordinates()
Returns a copy of the point as double array.

Returns:
the coordinates as double []

get

public double get(int i)
Method to retrieve coordinate entries

Parameters:
i - the index of the coordinate [0, dim[
Returns:
the coordinate

set

public void set(int i,
                double d)
Methods to set individual entries of the coordinates

Parameters:
i - the index of the coordinate [0, dim[
d - the value of the coordinate

getAbstractVector

public SimpleVector getAbstractVector()
Returns the internal abstract vector to enable computations via the numerics library.
Changes to the vector will affect the point

Returns:
the internal abstract vector

getDimension

public int getDimension()
Returns the dimension of the point

Returns:
the dimension

euclideanDistance

public double euclideanDistance(PointND two)
computes the Euclidean distance between the current point $\mathbf{x_1} = (x_1, y_1)$ the the point "two" $\mathbf{x_2} = (x_2, y_2)$ as
$|| \mathbf{x_1} - \mathbf{x_2} ||  = \sqrt{\sum_n(x_1(n) - x_2(n))^2}$.

Parameters:
two - the other point
Returns:
the distance

toString

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

updateIfHigher

public void updateIfHigher(PointND p)
Updates the vector at entries which are higher in p. Used to scan for a maximum in an iterative process. Search for a bounding box can be performed like this:
 ArrayList list = ...
 PointND max = new PointND(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE);
 for (PointND p : list){
        max.updateIfHigher(p);
 }
 

Parameters:
p - the other point

updateIfLower

public void updateIfLower(PointND p)
Updates the vector at entries which are higher in p. Used to scan for a minimum in an iterative process. Search for a bounding box can be performed like this:
 ArrayList list = ...
 PointND min = new PointND(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
 for (PointND p : list){
        min.updateIfLower(p);
 }
 

Parameters:
p - the other point

equals

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

applyTransform

public void applyTransform(Transform t)
Description copied from interface: Transformable
Applies the Transform t to the object.

Specified by:
applyTransform in interface Transformable
Parameters:
t - the transform to apply to the object.