Package lejos.robotics.geometry
Class Point
- java.lang.Object
-
- lejos.robotics.geometry.Point2D
-
- lejos.robotics.geometry.Point2D.Float
-
- lejos.robotics.geometry.Point
-
- All Implemented Interfaces:
java.lang.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 lejos.robotics.geometry.Point2D
Point2D.Double, Point2D.Float
-
-
Field Summary
-
Fields inherited from class lejos.robotics.geometry.Point2D.Float
x, y
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Pointadd(Point other)Returns the vector sum ofthisand otherPointaddWith(Point other)Vector addition; add other tothisfloatangle()returns the angle in radians of this point from the origin.floatangleTo(Point p)Returns the direction angle from this point to the Point pPointclone()returns a clone of itselfPointcopyTo(Point p)floatdotProduct(Point other)Returns the inner dot product.PointgetNormalized()get a copy ofthiswith length 1PointleftOrth()calculate left orthogonal vector ofthisfloatlength()Returns the length of this vectorPointmakeLeftOrth()Turns this vector into its left-handed cartesian orthagonalPointmakeRightOrth()Turns this vector into its right-handed cartesian orthagonalvoidmoveTo(Point other)Makesthisa copy of the other pointPointmultiply(float scale)Scalar multiplicationPointmultiplyBy(float scale)scalar multiplicationPointnormalize()Sets this vector's length to 1 unit while retaining directionPointpointAt(float distance, float angle)Returns a new point at the specified distance in the direction angle from this point.PointprojectOn(Line line)Finds the orthogonal projection of this point onto the line.Pointreverse()same as multiply(-1);PointrightOrth()calculate the right handed cartesian orthogonal of this poiontPointsubtract(float length)Vector subtractionPointsubtract(Point other)Vector subtractionPointsubtractWith(Point other)vector subtractionvoidtranslate(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 lejos.robotics.geometry.Point2D.Float
getX, getY, setLocation, setLocation, toString
-
Methods inherited from class lejos.robotics.geometry.Point2D
distance, distance, distance, distanceSq, distanceSq, distanceSq, equals, setLocation
-
-
-
-
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-
-
clone
public Point clone()
returns a clone of itself
-
add
public Point add(Point other)
Returns the vector sum ofthisand other- Parameters:
other- the point added tothis- Returns:
- vector sum
-
addWith
public Point addWith(Point other)
Vector addition; add other tothis- Parameters:
other- is added tothis- Returns:
thisafter the addition
-
moveTo
public void moveTo(Point other)
Makesthisa copy of the other point- Parameters:
other-
-
subtract
public Point subtract(Point other)
Vector subtraction- Parameters:
other- is subtracted fromthis- Returns:
- a new point; this point is unchanged
-
subtract
public Point subtract(float length)
Vector subtraction- Parameters:
length- of a copy ofthis- 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 ofthiswith 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 ofthis- 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 fromthis- 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 pointangle- the angle to the new point- Returns:
- the new point
-
-