Class Point

java.lang.Object
  extended byPoint

public class Point
extends java.lang.Object

model a point in 2D Cartesian space


Field Summary
private  double x
           
private  double y
           
 
Constructor Summary
Point()
          no parameters passed, create point at origin 0,0
Point(double x, double y)
          given x, y create a new point
 
Method Summary
 double distance(double x1, double y1)
          calculate Euclidean distance between this point and another given it's x and y coords
 double distance(Point p)
          calculate Euclidean distance between this point and another
 boolean equals(double x1, double y1)
          check equality between this point and another given it's x and y coords
 boolean equals(Point p)
          check equality between this point and another
 double getX()
           
 double getY()
           
 Point midpoint(double x1, double y1)
          calculate middle point between this point and another given it's x and y coords
 Point midpoint(Point p)
          calculate middle point between this point and another
 void rotate90()
          rotate point 90 degrees "clockwise"
 void setX(double x)
           
 void setY(double y)
           
 void shift(double xShift, double yShift)
          move point by xShift and yShoft amounts
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

private double x

y

private double y
Constructor Detail

Point

public Point()
no parameters passed, create point at origin 0,0


Point

public Point(double x,
             double y)
given x, y create a new point

Method Detail

distance

public double distance(double x1,
                       double y1)
calculate Euclidean distance between this point and another given it's x and y coords

Parameters:
x1 -
y1 -
Returns:
distance

distance

public double distance(Point p)
calculate Euclidean distance between this point and another

Parameters:
p - the point to calculate distance to
Returns:
the distance

equals

public boolean equals(double x1,
                      double y1)
check equality between this point and another given it's x and y coords

Parameters:
x1 -
y1 -
Returns:

equals

public boolean equals(Point p)
check equality between this point and another

Parameters:
p -
Returns:

getX

public double getX()
Returns:
Returns the x.

getY

public double getY()
Returns:
Returns the y.

midpoint

public Point midpoint(double x1,
                      double y1)
calculate middle point between this point and another given it's x and y coords

Parameters:
x1 -
y1 -
Returns:

midpoint

public Point midpoint(Point p)
calculate middle point between this point and another

Parameters:
p -
Returns:

rotate90

public void rotate90()
rotate point 90 degrees "clockwise"


setX

public void setX(double x)
Parameters:
x - The x to set.

setY

public void setY(double y)
Parameters:
y - The y to set.

shift

public void shift(double xShift,
                  double yShift)
move point by xShift and yShoft amounts

Parameters:
xShift - amount to shift in direction
yShift - amount to shift in y direction

toString

public java.lang.String toString()