Package lejos.robotics.geometry
Class Line
- java.lang.Object
-
- lejos.robotics.geometry.Line2D
-
- lejos.robotics.geometry.Line2D.Float
-
- lejos.robotics.geometry.Line
-
- All Implemented Interfaces:
java.lang.Cloneable,Shape
public class Line extends Line2D.Float
Represents a line and supports calculating the point of intersection of two line segments.- Author:
- Lawrie Griffiths
WARNING: THIS CLASS IS SHARED BETWEEN THE classes AND pccomms PROJECTS. DO NOT EDIT THE VERSION IN pccomms AS IT WILL BE OVERWRITTEN WHEN THE PROJECT IS BUILT.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class lejos.robotics.geometry.Line2D
Line2D.Double, Line2D.Float
-
-
Field Summary
-
Fields inherited from class lejos.robotics.geometry.Line2D.Float
x1, x2, y1, y2
-
-
Constructor Summary
Constructors Constructor Description Line(float x1, float y1, float x2, float y2)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PointgetP1()Get the start point of the line as a Point2DPointgetP2()Get the end point of the line as a Point2DPointintersectsAt(Line l)Calculate the point of intersection of two lines.floatlength()Return the length of the linevoidlengthen(float delta)Make this line longer by an amount delta at each end.doublesegDist(Line seg)Returns the minimum distance between two line segments--this line segment and another.-
Methods inherited from class lejos.robotics.geometry.Line2D.Float
getBounds2D, getX1, getX2, getY1, getY2, setLine, setLine
-
Methods inherited from class lejos.robotics.geometry.Line2D
clone, contains, contains, contains, contains, getBounds, intersects, intersects, intersectsLine, intersectsLine, linesIntersect, ptSegDist, ptSegDist, ptSegDist, ptSegDistSq, ptSegDistSq, ptSegDistSq, relativeCCW, relativeCCW, relativeCCW, setLine, setLine
-
-
-
-
Method Detail
-
intersectsAt
public Point intersectsAt(Line l)
Calculate the point of intersection of two lines.- Parameters:
l- the second line- Returns:
- the point of intersection or null if the lines do not intercept or are coincident
-
segDist
public double segDist(Line seg)
Returns the minimum distance between two line segments--this line segment and another. If they intersect the distance is 0. Lines can be parallel or skewed (non-parallel).- Parameters:
seg- The other line segment.- Returns:
- The distance between the two line segments.
-
lengthen
public void lengthen(float delta)
Make this line longer by an amount delta at each end. Used by DijkstraPathFinder to use the same LineMap as the a RangeScanner in MCL navigation.- Parameters:
delta- the amount added to each end
-
length
public float length()
Return the length of the line- Returns:
- the length of the line
-
getP1
public Point getP1()
Description copied from class:Line2DGet the start point of the line as a Point2D- Overrides:
getP1in classLine2D.Float- Returns:
- the Point2D
-
getP2
public Point getP2()
Description copied from class:Line2DGet the end point of the line as a Point2D- Overrides:
getP2in classLine2D.Float- Returns:
- the Point2D
-
-