com.mizar.geometry
Class Line

java.lang.Object
  extended by com.mizar.geometry.Geometry
      extended by com.mizar.geometry.Line
All Implemented Interfaces:
OneCell

public class Line
extends Geometry
implements OneCell


Nested Class Summary
 
Nested classes/interfaces inherited from class com.mizar.geometry.Geometry
Geometry.Results
 
Field Summary
static java.util.HashMap<java.lang.String,java.lang.String> ORDINAL_NAMES
           
 
Fields inherited from class com.mizar.geometry.Geometry
defaultOrdinates, dimensions, geographic, LEFTSIDE, maximumCoordinates, mbr, minimumCoordinates, ONLINE, ordinates, precision, results, RIGHTSIDE, SIDE, toStringDecimals
 
Constructor Summary
Line()
          defaults to dimensions == 2 and precision == Double.MIN_VALUE;
Line(double precision)
           
Line(double[] ordinates)
           
Line(double[] ordinates, double precision)
           
Line(double[] begin, double[] end)
           
Line(double[] begin, double[] end, double precision)
           
Line(double[] ordinates, int dimensions)
           
Line(double[] ordinates, int dimensions, double precision)
           
 
Method Summary
 void changeDimensionality(int dimensionality)
          Converts the geometry entity to a different dimensionality
 Line clone()
           
 double[] directionVector()
          Subtracts the first point in ordinates from the last point to return a normalized vector.
static double[] directionVector(double radians)
           
static double[] directionVector(double[] ordinates)
          Subtracts the first point in ordinates from the last point to return a normalized vector.
static double[] directionVectorFromDegrees(double degrees)
           
 double distanceToPointOnLine(double[] point)
           
static double dotProduct(double[] a, double[] b)
          Computes the dot product of a DOT b
static double dotProduct(Line a, Line b)
           
 Line extendBothEnds(double distance)
           
 double getAngle()
           
static double getAngle(double[] xyxy)
           
 double[] getCommonPoints(Line line)
          TODO:
 java.lang.String getCompassOrdinal()
           
static java.lang.String getCompassOrdinal(double angle)
           
static java.lang.String getCompassOrdinalFull(double angle)
           
 Point getEndPoint()
           
static double getLength(double[] ordinates, int dimensions, double precision)
           
 Point getStartPoint()
           
 double[] intersect(double[] line, double precision)
           
 IntersectionInfo intersect(Line inLine)
           
 double[] intersections(Line line)
           
 boolean isColinear(Line inLine)
          Tests for colinearity.
 boolean isColinearSwitchback(Line inLine)
           
static boolean isLineIntersectingLine(Line line1, Line line2)
           
static boolean isLineIntersectingLine1(Line line1, Line line2)
          TODO: this method is not handling precision.
 boolean isPointOnLine(double[] pt)
          Tests y-K = ((Q-K)/(P-H))(x-H) where (H,K),(P,Q) are this lines end points and (x,y) is the point to test.
 boolean isPointOnLine(Point pt)
           
 boolean isPointOnSegment(Point pt)
           
 boolean isZeroLength()
           
static boolean isZeroLength(double[] line, double precision)
           
static boolean isZeroLength(double[] begin, double[] end, double precision)
           
static void main(java.lang.String[] argv)
           
static void main1(java.lang.String[] argv)
           
static void main2(java.lang.String[] argv)
           
 double[] makeBox(double width)
           
static double[] makeBox(double[] beginEnd, double width)
           
 double[] pointAtDistance(double percentage)
          Using a percentage between 0.0 and 1.0 where 0 is the starting point and 1 is the end point, find the point that lies on the line at the percentage.
 double[] pointOnLine(double[] point)
          The point returned may not actually fall on the line; it may fall on an extension of the line.
 double[] pointOnLine(double x, double y)
           
 Line[] splitAt(double[] point)
          Converts a Line into two Lines using point as a "middle" point.
 Line[] splitAtPoint(double[] point)
           
 Line[] splitAtPoint(Point point)
           
 
Methods inherited from class com.mizar.geometry.Geometry
adjustEndPoints, adjustEndPoints, adjustEndPoints, adjustEndPoints, changeDimensions, computeMbr, computeMbr, computeMbr, computeNearestDistance, computeNearestDistance, connectsTo, connectsTo, connectsTo, connectsTo, constructDefaultPoint, equals, expandMbr, getCoordinate, getCoordinates, getCoordinates, getCoordinates, getCoordinates, getDefaultOrdinates, getDimensions, getEndCoordinateIndex, getFirstPoint, getFirstPoint, getLastPoint, getLastPoint, getLeastDimension, getLeastPrecise, getLength, getLength, getMaximumCoordinates, getMbr, getMbrCorner, getMbrCorner, getMinimumCoordinates, getMostPrecise, getNumberOfCoordiates, getOrdinates, getPoints, getPointWithMatchingDimensions, getPrecision, getRange, getRange, getResults, getSegment, getToStringDecimals, getXYCoordinates, getXYCoordinates, hashCode, isCoveredByMbr, isEqualOrBetween, isGeographic, isInsideMbr, isSame, mbrIntersect, mbrOverlap, mbrOverlap, mbrOverlapRatio, mbrValid, polygonizeMbr, quadrant, seedMbr, setCoordinate, setCoordinates, setCoordinates, setDefaultOrdinates, setDimensions, setFirstPoint, setGeographic, setLastPoint, setMaximumCoordinates, setMinimumCoordinates, setOrdinates, setPrecision, setSegment, setToStringDecimals, toString, updateMbr
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.mizar.geometry.OneCell
getDimensions, getFirstPoint, getLastPoint, getLength, setFirstPoint, setLastPoint
 

Field Detail

ORDINAL_NAMES

public static final java.util.HashMap<java.lang.String,java.lang.String> ORDINAL_NAMES
Constructor Detail

Line

public Line()
defaults to dimensions == 2 and precision == Double.MIN_VALUE;


Line

public Line(double precision)
Parameters:
precision -

Line

public Line(double[] ordinates,
            double precision)
     throws GeometryException
Parameters:
ordinates -
precision -
Throws:
GeometryException

Line

public Line(double[] ordinates,
            int dimensions,
            double precision)
     throws GeometryException
Throws:
GeometryException

Line

public Line(double[] ordinates)
     throws GeometryException
Parameters:
ordinates -
Throws:
GeometryException

Line

public Line(double[] ordinates,
            int dimensions)
     throws GeometryException
Throws:
GeometryException

Line

public Line(double[] begin,
            double[] end,
            double precision)
     throws GeometryException
Parameters:
begin -
end -
precision -
Throws:
GeometryException

Line

public Line(double[] begin,
            double[] end)
     throws GeometryException
Parameters:
begin -
end -
Throws:
GeometryException
Method Detail

pointOnLine

public double[] pointOnLine(double[] point)
                     throws GeometryException
The point returned may not actually fall on the line; it may fall on an extension of the line. If this happens then results.onLine will be false.

Parameters:
point -
Returns:
Throws:
GeometryException
See Also:
Line#pointOnLine(double,double), Line.Results.onLine, OSA1_dist_point_line

dotProduct

public static double dotProduct(Line a,
                                Line b)
                         throws GeometryException
Throws:
GeometryException

dotProduct

public static double dotProduct(double[] a,
                                double[] b)
                         throws GeometryException
Computes the dot product of a DOT b

Throws:
GeometryException

directionVector

public static double[] directionVector(double[] ordinates)
                                throws GeometryException
Subtracts the first point in ordinates from the last point to return a normalized vector.

Parameters:
ordinates - assumed to be two points
Returns:
a direction vector
Throws:
GeometryException - if the area of ordinates is not an even number or is null.

directionVector

public double[] directionVector()
                         throws GeometryException
Subtracts the first point in ordinates from the last point to return a normalized vector.

Returns:
a direction vector
Throws:
GeometryException - if ordinates is null.

directionVector

public static double[] directionVector(double radians)
Parameters:
radians - and angle in radians
Returns:
a direction vector

directionVectorFromDegrees

public static double[] directionVectorFromDegrees(double degrees)

pointOnLine

public double[] pointOnLine(double x,
                            double y)
                     throws GeometryException
Parameters:
x -
y -
Returns:
Throws:
GeometryException
See Also:
pointOnLine(double[])

distanceToPointOnLine

public double distanceToPointOnLine(double[] point)
                             throws GeometryException
Parameters:
point -
Returns:
Throws:
GeometryException
See Also:
Line#pointOnLine(double[]), Point#distance, OSA1_dist_point_line

pointAtDistance

public double[] pointAtDistance(double percentage)
                         throws GeometryException
Using a percentage between 0.0 and 1.0 where 0 is the starting point and 1 is the end point, find the point that lies on the line at the percentage. The start and end points of the line are used.

Parameters:
percentage -
Returns:
coordinates of the point
Throws:
GeometryException

splitAtPoint

public Line[] splitAtPoint(double[] point)
                    throws GeometryException
Parameters:
point -
Returns:
if a perpendicular from point falls on the Line an array of two Lines; if the perpendicular falls on either end point of the Line then a Line[1] is returned with a clone of the original line; if the perpendicular does not fall on the Line then the method returns null.
Throws:
GeometryException

splitAt

public Line[] splitAt(double[] point)
               throws GeometryException
Converts a Line into two Lines using point as a "middle" point.

Parameters:
point - assumed to fall on the line and not be an end point
Returns:
Line[2] as the {firstPoint,point} and {point,lastPoint} of the Line.
Throws:
GeometryException

splitAtPoint

public Line[] splitAtPoint(Point point)
                    throws GeometryException
Parameters:
point -
Returns:
if a perpendicular from point falls on the Line an array of two Lines; if the perpendicular falls on either end point of the Line then a Line[1] is returned with a clone of the original line; if the perpendicular does not fall on the Line then the method returns null.
Throws:
GeometryException
See Also:
splitAtPoint(double[])

getCommonPoints

public double[] getCommonPoints(Line line)
TODO:

Parameters:
line -
Returns:
an array of points common between line and this

isZeroLength

public boolean isZeroLength()
                     throws GeometryException
Returns:
true if begin and end are less than or equal to precision apart.
Throws:
GeometryException

isZeroLength

public static boolean isZeroLength(double[] line,
                                   double precision)
Parameters:
line -
precision -
Returns:
true if line begin and end are less than or equal to precision apart.

isZeroLength

public static boolean isZeroLength(double[] begin,
                                   double[] end,
                                   double precision)
Parameters:
begin -
end -
precision -
Returns:
true if begin and end are less than or equal to precision apart.

isLineIntersectingLine1

public static boolean isLineIntersectingLine1(Line line1,
                                              Line line2)
TODO: this method is not handling precision. It should treat lines that "touch" within the value of leastPrecise as intersecting.

Parameters:
line1 -
line2 -
Returns:

intersect

public double[] intersect(double[] line,
                          double precision)
                   throws GeometryException
Throws:
GeometryException

intersections

public double[] intersections(Line line)
                       throws GeometryException
Throws:
GeometryException

isLineIntersectingLine

public static boolean isLineIntersectingLine(Line line1,
                                             Line line2)

intersect

public IntersectionInfo intersect(Line inLine)
                           throws GeometryException
Throws:
GeometryException

isColinearSwitchback

public boolean isColinearSwitchback(Line inLine)
                             throws GeometryException
Throws:
GeometryException

isColinear

public boolean isColinear(Line inLine)
                   throws GeometryException
Tests for colinearity.

Parameters:
inLine - line to test
Returns:
true if both endpoints of inLine are on this
Throws:
GeometryException

isPointOnSegment

public boolean isPointOnSegment(Point pt)
                         throws GeometryException
Throws:
GeometryException

isPointOnLine

public boolean isPointOnLine(Point pt)
                      throws GeometryException
Throws:
GeometryException

isPointOnLine

public boolean isPointOnLine(double[] pt)
                      throws GeometryException
Tests y-K = ((Q-K)/(P-H))(x-H) where (H,K),(P,Q) are this lines end points and (x,y) is the point to test.

Parameters:
pt - point to test
Returns:
true if point is on the line
Throws:
GeometryException

getStartPoint

public Point getStartPoint()
                    throws GeometryException
Specified by:
getStartPoint in interface OneCell
Throws:
GeometryException

getEndPoint

public Point getEndPoint()
                  throws GeometryException
Specified by:
getEndPoint in interface OneCell
Throws:
GeometryException

getLength

public static double getLength(double[] ordinates,
                               int dimensions,
                               double precision)

getAngle

public double getAngle()
                throws GeometryException
Throws:
GeometryException

getAngle

public static double getAngle(double[] xyxy)
                       throws GeometryException
Throws:
GeometryException

getCompassOrdinal

public java.lang.String getCompassOrdinal()
                                   throws GeometryException
Throws:
GeometryException

getCompassOrdinalFull

public static java.lang.String getCompassOrdinalFull(double angle)

getCompassOrdinal

public static java.lang.String getCompassOrdinal(double angle)

changeDimensionality

public void changeDimensionality(int dimensionality)
                          throws GeometryException
Description copied from interface: OneCell
Converts the geometry entity to a different dimensionality

Specified by:
changeDimensionality in interface OneCell
Parameters:
dimensionality - new dimension number if dimensions is less than current dimensionality then excess points are thrown away if dimensions is greater than current dimensionality then points are added as needed and set to 0 The function has no effect if dimensions = dimensionality
Throws:
GeometryException

extendBothEnds

public Line extendBothEnds(double distance)

clone

public Line clone()
Overrides:
clone in class java.lang.Object

makeBox

public double[] makeBox(double width)
                 throws GeometryException
Throws:
GeometryException

makeBox

public static double[] makeBox(double[] beginEnd,
                               double width)
                        throws GeometryException
Throws:
GeometryException

main

public static void main(java.lang.String[] argv)

main1

public static void main1(java.lang.String[] argv)

main2

public static void main2(java.lang.String[] argv)
                  throws GeometryException
Throws:
GeometryException