de.unihalle.informatik.MiToBo.core.datatypes
Class MTBLineSegment2D

java.lang.Object
  extended by java.awt.geom.Line2D
      extended by java.awt.geom.Line2D.Double
          extended by de.unihalle.informatik.MiToBo.core.datatypes.MTBLineSegment2D
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, java.lang.Cloneable

public class MTBLineSegment2D
extends java.awt.geom.Line2D.Double

Enhanced 2D line segments.

This class adds some useful functions to Line2D.Double, mostly concerning geometrical calculations like intersections, orientations, scalar products and distances.

Author:
moeller
See Also:
Line2D.Double, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Line2D
java.awt.geom.Line2D.Double, java.awt.geom.Line2D.Float
 
Field Summary
 
Fields inherited from class java.awt.geom.Line2D.Double
x1, x2, y1, y2
 
Constructor Summary
MTBLineSegment2D(double X1, double Y1, double X2, double Y2)
          Constructor.
 
Method Summary
 boolean containsPoint(double px, double py)
          Checks if a given point is part of the segment.
 java.awt.geom.Point2D.Double getIntersection(MTBLineSegment2D ls)
          Calculates the point of intersection between the segments.
 double getNorm()
          Calculates the Euclidean norm of the segment.
 double getOrientation(double px, double py)
          Deprecated. 
 double getPointDist(double x, double y)
          Deprecated. 
 double scalprod(MTBLineSegment2D ls)
          Calculates the scalar product of the given segment to this one.
 
Methods inherited from class java.awt.geom.Line2D.Double
getBounds2D, getP1, getP2, getX1, getX2, getY1, getY2, setLine
 
Methods inherited from class java.awt.geom.Line2D
clone, contains, contains, contains, contains, getBounds, getPathIterator, getPathIterator, intersects, intersects, intersectsLine, intersectsLine, linesIntersect, ptLineDist, ptLineDist, ptLineDist, ptLineDistSq, ptLineDistSq, ptLineDistSq, ptSegDist, ptSegDist, ptSegDist, ptSegDistSq, ptSegDistSq, ptSegDistSq, relativeCCW, relativeCCW, relativeCCW, setLine, setLine
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MTBLineSegment2D

public MTBLineSegment2D(double X1,
                        double Y1,
                        double X2,
                        double Y2)
Constructor.

Parameters:
X1 - x-coordinate of first point.
Y1 - y-coordinate of first point.
X2 - x-coordinate of second point.
Y2 - y-coordinate of second point.
Method Detail

containsPoint

public boolean containsPoint(double px,
                             double py)
Checks if a given point is part of the segment.

Parameters:
px - x-coordinate of the point.
py - y-coordinate of the point.
Returns:
True if point lies on the segment.

getIntersection

public java.awt.geom.Point2D.Double getIntersection(MTBLineSegment2D ls)
Calculates the point of intersection between the segments.

Parameters:
ls - Line segment to be checked.
Returns:
True, if both segments intersect.

getNorm

public double getNorm()
Calculates the Euclidean norm of the segment.

Returns:
Length of the segment.

getOrientation

@Deprecated
public double getOrientation(double px,
                                        double py)
Deprecated. 

Get orientation of point relative to segment.

If return value is positive, point lies left of the segment, if it is negative, the point is located on the right. If the return value is zero, the point is located on the segment or at least on the line to which the segment belongs to.

Parameters:
px - x-coordinate of the point.
py - y-coordinate of the point.
Returns:
Orientation of point with regard to segment.

getPointDist

@Deprecated
public double getPointDist(double x,
                                      double y)
Deprecated. 


scalprod

public double scalprod(MTBLineSegment2D ls)
Calculates the scalar product of the given segment to this one.

The segments are interpreted as vectors, directed from the first point of the segment to the second.

Parameters:
ls - Input line segment.
Returns:
Value of scalar product.