rcssjava.geom
Class Line

java.lang.Object
  extended by rcssjava.geom.Line

public class Line
extends java.lang.Object

Implementation of 2d line


Constructor Summary
Line(double a, double b, double c)
          Construct line given the three coefficients in ay + bx + c = 0.
 
Method Summary
 double getA()
          Get a coefficient
 double getB()
          Get a coefficient
 double getC()
          Get a coefficient
 double getDistanceToPoint(VecPosition pos)
          Get euclidean distance between a given point and the closest point on the line to that point
 VecPosition getIntersection(Line line)
          Get intersecton with a line
 VecPosition getIntersection(LineSegment ls)
          Get intersecton with a line segment
 VecPosition getPointOnLineClosestTo(VecPosition pos)
          Get point on line with smallest euclidean distance to given point
 double getSlope()
          Get slope
 Line getTangentLine(VecPosition pos)
          Get line orthogonal to this that passes through the given point
 double getXGivenY(double y)
          Get the x coordinate on the line for a given y coordinate
 double getYGivenX(double x)
          Get the y coordinate on the line for a given x coordinate
 double getYIntercept()
          Get y-intercept
static Line makeLineFromTwoPoints(VecPosition pos1, VecPosition pos2)
          Create the line that passes through the two given points
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Line

public Line(double a,
            double b,
            double c)
Construct line given the three coefficients in ay + bx + c = 0.

Parameters:
a - a coefficient
b - b coefficient
c - c coefficient
Method Detail

getA

public double getA()
Get a coefficient

Returns:
a coefficient

getB

public double getB()
Get a coefficient

Returns:
b coefficient

getC

public double getC()
Get a coefficient

Returns:
c coefficient

getSlope

public double getSlope()
Get slope

Returns:
slope, m in y = mx + b

getYIntercept

public double getYIntercept()
Get y-intercept

Returns:
y-intercept, b in y = mx + b

getIntersection

public VecPosition getIntersection(LineSegment ls)
Get intersecton with a line segment

Parameters:
ls - line segment
Returns:
intersection point or null if none

getIntersection

public VecPosition getIntersection(Line line)
Get intersecton with a line

Parameters:
line - another line
Returns:
intersection point or null if none

getTangentLine

public Line getTangentLine(VecPosition pos)
Get line orthogonal to this that passes through the given point

Parameters:
pos - intersection point
Returns:
orthogonal line

getPointOnLineClosestTo

public VecPosition getPointOnLineClosestTo(VecPosition pos)
Get point on line with smallest euclidean distance to given point

Parameters:
pos - point to which closest should be determined
Returns:
point on line closest to given point

getDistanceToPoint

public double getDistanceToPoint(VecPosition pos)
Get euclidean distance between a given point and the closest point on the line to that point

Parameters:
pos - point to which closest should be determined
Returns:
distance to given point

getYGivenX

public double getYGivenX(double x)
Get the y coordinate on the line for a given x coordinate

Parameters:
x - x coordinate
Returns:
y coordinate

getXGivenY

public double getXGivenY(double y)
Get the x coordinate on the line for a given y coordinate

Parameters:
y - y coordinate
Returns:
x coordinate

makeLineFromTwoPoints

public static Line makeLineFromTwoPoints(VecPosition pos1,
                                         VecPosition pos2)
Create the line that passes through the two given points

Parameters:
pos1 - first point
pos2 - second point
Returns:
line passing through both points

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object