lejos.geom
Class Point

java.lang.Object
  extended by java.awt.geom.Point2D
      extended by java.awt.geom.Point2D.Float
          extended by lejos.geom.Point
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
Waypoint

public class Point
extends Point2D.Float

Point with float co-ordinates for use in navigation. This class includes methods allow it to behave as a vector in 2 dimensional vector space. It includes the standard vector arithmetic operatins of addition, * subtraction, scalar multiplication, and inner product.

Author:
Lawrie Griffiths , Roger Glassey

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Point2D
Point2D.Double, Point2D.Float
 
Field Summary
 
Fields inherited from class java.awt.geom.Point2D.Float
x, y
 
Constructor Summary
Point(float radians)
          Returns a point ad distance 1 from the origin and an angle radans to the x-axis
Point(float x, float y)
          returns a Point at location x,y
 
Method Summary
 Point add(Point other)
          Returns the vector sum of this and other
 Point addWith(Point other)
          Vector addition; add other to this
 float angle()
          returns the angle in radians of this point from the origin.
 float angleTo(Point p)
          Returns the direction angle from this point to the Point p
 Point clone()
          returns a clone of itself
 Point copyTo(Point p)
           
 float dotProduct(Point other)
          Returns the inner dot product.
 Point getNormalized()
          get a copy of this with length 1
 Point leftOrth()
          calculate left orthogonal vector of this
 float length()
          Returns the length of this vector
 Point makeLeftOrth()
          Turns this vector into its left-handed cartesian orthagonal
 Point makeRightOrth()
          Turns this vector into its right-handed cartesian orthagonal
 void moveTo(Point other)
          Makes this a copy of the other point
 Point multiply(float scale)
          Scalar multiplication
 Point multiplyBy(float scale)
          scalar multiplication
 Point normalize()
          Sets this vector's length to 1 unit while retaining direction
 Point pointAt(float distance, float angle)
          Returns a new point at the specified distance in the direction angle from this point.
 Point projectOn(Line line)
          Finds the orthogonal projection of this point onto the line.
 Point reverse()
          same as multiply(-1);
 Point rightOrth()
          calculate the right handed cartesian orthogonal of this poiont
 Point subtract(float length)
          Vector subtraction
 Point subtract(Point other)
          Vector subtraction
 Point subtractWith(Point other)
          vector subtraction
 void translate(float dx, float dy)
          Translates this point, at location (x, y), by dx along the x axis and dy along the y axis so that it now represents the point (x + dx, y + dy).
 
Methods inherited from class java.awt.geom.Point2D.Float
getX, getY, setLocation, setLocation, toString
 
Methods inherited from class java.awt.geom.Point2D
distance, distance, distance, distanceSq, distanceSq, distanceSq, equals, setLocation
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Point

public Point(float x,
             float y)
returns a Point at location x,y

Parameters:
x - coordinate
y - coordinate

Point

public Point(float radians)
Returns a point ad distance 1 from the origin and an angle radans to the x-axis

Parameters:
radians -
Method Detail

angleTo

public float angleTo(Point p)
Returns the direction angle from this point to the Point p

Parameters:
p - the Point to determine the angle to
Returns:
the angle in degrees

translate

public void translate(float dx,
                      float dy)
Translates this point, at location (x, y), by dx along the x axis and dy along the y axis so that it now represents the point (x + dx, y + dy).

Parameters:
dx -
dy -

copyTo

public Point copyTo(Point p)

clone

public Point clone()
returns a clone of itself

Overrides:
clone in class Point2D
Returns:
clone of this point

add

public Point add(Point other)
Returns the vector sum of this and other

Parameters:
other - the point added to this
Returns:
vector sum

addWith

public Point addWith(Point other)
Vector addition; add other to this

Parameters:
other - is added to this
Returns:
this after the addition

moveTo

public void moveTo(Point other)
Makes this a copy of the other point

Parameters:
other -

subtract

public Point subtract(Point other)
Vector subtraction

Parameters:
other - is subtracted from this
Returns:
a new point; this point is unchanged

subtract

public Point subtract(float length)
Vector subtraction

Parameters:
length - of a copy of this
Returns:
a new vector, obtained b subtracting a scaled version of this point

multiply

public Point multiply(float scale)
Scalar multiplication

Parameters:
scale - multilies the length of this to give a new length
Returns:
a new copy of this, with length scaled

getNormalized

public Point getNormalized()
get a copy of this with length 1

Returns:
a new vector of unit length

reverse

public Point reverse()
same as multiply(-1);

Returns:
this pointing in the opposite direction

projectOn

public Point projectOn(Line line)
Finds the orthogonal projection of this point onto the line. The projection may lie on an extension of the line

Parameters:
line - onto which the projection is made
Returns:
the projection

angle

public float angle()
returns the angle in radians of this point from the origin. The X- axis ie at angle 0.

Returns:
the angle in radians

leftOrth

public Point leftOrth()
calculate left orthogonal vector of this

Returns:
orthogonal vector

rightOrth

public Point rightOrth()
calculate the right handed cartesian orthogonal of this poiont

Returns:
orthogonal vector

subtractWith

public Point subtractWith(Point other)
vector subtraction

Parameters:
other - is subtracted from this
Returns:
this point after subtraction

multiplyBy

public Point multiplyBy(float scale)
scalar multiplication

Parameters:
scale -
Returns:
scaled this point after multiplication

length

public float length()
Returns the length of this vector

Returns:
the length

normalize

public Point normalize()
Sets this vector's length to 1 unit while retaining direction

Returns:
this vector normalized

makeLeftOrth

public Point makeLeftOrth()
Turns this vector into its left-handed cartesian orthagonal


makeRightOrth

public Point makeRightOrth()
Turns this vector into its right-handed cartesian orthagonal


dotProduct

public float dotProduct(Point other)
Returns the inner dot product.

Returns:
dot product of this with other

pointAt

public Point pointAt(float distance,
                     float angle)
Returns a new point at the specified distance in the direction angle from this point.

Parameters:
distance - the distance to the new point
angle - the angle to the new point
Returns:
the new point