de.erichseifert.gral.util
Class PointND<T extends Number>

java.lang.Object
  extended by de.erichseifert.gral.util.PointND<T>
Type Parameters:
T - Data type of the coordinates.

public class PointND<T extends Number>
extends Object

Class for storing n-dimensional points.


Field Summary
static int X
          Constant for accessing x-coordinate.
static int Y
          Constant for accessing y-coordinate.
static int Z
          Constant for accessing z-coordinate.
 
Constructor Summary
PointND(T... coordinates)
          Constructor that initializes the point with a list of coordinates.
 
Method Summary
 boolean equals(Object obj)
           
 T get(int dimension)
          Returns the value of a specified dimension.
 int getDimensions()
          Returns the number of dimensions.
 Point2D getPoint2D()
          Creates a two-dimensional point from dimensions 0 and 1.
 Point2D getPoint2D(int dimX, int dimY)
          Creates a two-dimensional point from the specified dimensions.
 int hashCode()
           
 void set(int dimension, T coordinate)
          Sets the value of a specified dimension.
 void setLocation(T... coordinates)
          Sets all coordinate values at once.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

X

public static final int X
Constant for accessing x-coordinate.

See Also:
Constant Field Values

Y

public static final int Y
Constant for accessing y-coordinate.

See Also:
Constant Field Values

Z

public static final int Z
Constant for accessing z-coordinate.

See Also:
Constant Field Values
Constructor Detail

PointND

public PointND(T... coordinates)
Constructor that initializes the point with a list of coordinates.

Parameters:
coordinates - Coordinate values.
Method Detail

getDimensions

public int getDimensions()
Returns the number of dimensions.

Returns:
Number of dimensions.

get

public T get(int dimension)
Returns the value of a specified dimension.

Parameters:
dimension - Dimension.
Returns:
Coordinate value.

set

public void set(int dimension,
                T coordinate)
Sets the value of a specified dimension.

Parameters:
dimension - Dimension.
coordinate - New coordinate value.

setLocation

public void setLocation(T... coordinates)
Sets all coordinate values at once.

Parameters:
coordinates - Coordinate values.

getPoint2D

public Point2D getPoint2D(int dimX,
                          int dimY)
Creates a two-dimensional point from the specified dimensions.

Parameters:
dimX - Dimension for x coordinate.
dimY - Dimension for y coordinate.
Returns:
Two-dimensional point.

getPoint2D

public Point2D getPoint2D()
Creates a two-dimensional point from dimensions 0 and 1.

Returns:
Two-dimensional point.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2009-2010. All Rights Reserved.