edu.columbia.cs.coms4701.geometry
Class DiscretePoint2D

java.lang.Object
  extended by edu.columbia.cs.coms4701.geometry.AbstractVector<java.lang.Integer>
      extended by edu.columbia.cs.coms4701.geometry.DiscreteVector
          extended by edu.columbia.cs.coms4701.geometry.DiscretePoint2D
All Implemented Interfaces:
GeometricVector<java.lang.Integer>, Point2D<java.lang.Integer>, java.lang.Iterable<java.lang.Integer>

public class DiscretePoint2D
extends DiscreteVector
implements Point2D<java.lang.Integer>

A 2-dimensional point in a lattice (i.e. with integer coordinates).

Version:
0.1

User: aaron Date: Aug 25, 2006 Time: 11:34:04 AM

Author:
aaron@cs

Field Summary
 
Fields inherited from class edu.columbia.cs.coms4701.geometry.DiscreteVector
DIRECTIONS, EAST, NORTH, NORTHEAST, NORTHWEST, SOUTH, SOUTHEAST, SOUTHWEST, WEST
 
Fields inherited from class edu.columbia.cs.coms4701.geometry.AbstractVector
components, PRIME
 
Fields inherited from interface edu.columbia.cs.coms4701.geometry.GeometricVector
X_DIM, Y_DIM, Z_DIM
 
Constructor Summary
DiscretePoint2D(GeometricVector<java.lang.Integer> theVector)
          Constructs a new 2D discrete point from the given discrete vector
DiscretePoint2D(java.lang.Integer x, java.lang.Integer y)
          Constructs a new 2-D discrete point at the specified coordinates.
 
Method Summary
 double distanceFromOrigin()
          Returns the distance of this point from the origin.
 double distanceFromPoint(Point2D<java.lang.Integer> thePoint)
          Returns the distance between this point and the given point.
 java.lang.Integer getX()
          Returns x coordinate
 java.lang.Integer getY()
          Returns y coordinate
 DiscretePoint2D translateBy(GeometricVector<java.lang.Integer> theVector)
          Returns a new point at the coordinate translated from this point's position by the given vector
 
Methods inherited from class edu.columbia.cs.coms4701.geometry.DiscreteVector
add, getComponents, multiply
 
Methods inherited from class edu.columbia.cs.coms4701.geometry.AbstractVector
checkDimension, checkEqualOrSmallerDimensionVector, equals, getComponent, getDimension, getLength, hashCode, iterator, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DiscretePoint2D

public DiscretePoint2D(java.lang.Integer x,
                       java.lang.Integer y)
Constructs a new 2-D discrete point at the specified coordinates.

Parameters:
x -
y -

DiscretePoint2D

public DiscretePoint2D(GeometricVector<java.lang.Integer> theVector)
Constructs a new 2D discrete point from the given discrete vector

Method Detail

translateBy

public DiscretePoint2D translateBy(GeometricVector<java.lang.Integer> theVector)
Returns a new point at the coordinate translated from this point's position by the given vector

Specified by:
translateBy in interface Point2D<java.lang.Integer>
Parameters:
theVector -
Throws:
java.lang.IllegalArgumentException - if the vector is > 2 dimensional

distanceFromOrigin

public double distanceFromOrigin()
Returns the distance of this point from the origin.

Specified by:
distanceFromOrigin in interface Point2D<java.lang.Integer>
Returns:
distance from origin (0,0)

distanceFromPoint

public double distanceFromPoint(Point2D<java.lang.Integer> thePoint)
Returns the distance between this point and the given point.

Specified by:
distanceFromPoint in interface Point2D<java.lang.Integer>
Parameters:
thePoint -
Returns:
distance between the two points

getX

public java.lang.Integer getX()
Returns x coordinate

Specified by:
getX in interface Point2D<java.lang.Integer>
Returns:
x coordinate

getY

public java.lang.Integer getY()
Returns y coordinate

Specified by:
getY in interface Point2D<java.lang.Integer>
Returns:
y coordinate