|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--venice.Intersections
Class containing static methods which can be used to calculate intersection points for lines against lines, rectangles and ellipses.
This is highly unoptimized code. Performance can be improved.
Constructor Summary | |
Intersections()
|
Method Summary | |
static java.awt.geom.Point2D |
lineIntersectLine(java.awt.geom.Line2D inLine1,
java.awt.geom.Line2D inLine2)
Calculates the intersection between two line segments. |
static java.awt.geom.Point2D |
lineIntersectsEllipse(java.awt.geom.Line2D inLine,
java.awt.geom.RectangularShape inEllipse)
Checks whether the given line intersects with the given ellipse. |
static java.awt.geom.Point2D |
lineIntersectsRectangle(java.awt.geom.Line2D inLine,
java.awt.geom.RectangularShape inRectangle)
Calculates whether the given line and rectangle intersect and returns the intersection point. |
static void |
main(java.lang.String[] argv)
Public main to test this class and its correctness. |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
public Intersections()
Method Detail |
public static java.awt.geom.Point2D lineIntersectLine(java.awt.geom.Line2D inLine1, java.awt.geom.Line2D inLine2)
Caution! Current implementation does not return an intersection for two collinear segments. This may be fixed in a later version.
Algorithm from comp.graphics.algorithm FAQ
inLine1
- first lineinLine2
- second linepublic static java.awt.geom.Point2D lineIntersectsRectangle(java.awt.geom.Line2D inLine, java.awt.geom.RectangularShape inRectangle)
Caution! A line segment can have two intersection points with a rectangle. This method returns at most one intersection point. This method will return the intersection point, which will cut the line segment to the shortest possible length.
inLine
- line segment which to checkinRectangle
- rectangle against which to check intersectionpublic static java.awt.geom.Point2D lineIntersectsEllipse(java.awt.geom.Line2D inLine, java.awt.geom.RectangularShape inEllipse)
Caution! Currently this code treats the ellipse as a circle. It assumes it has the same height as width.
inLine
- line to checkinEllipse
- ellipse to check againstpublic static void main(java.lang.String[] argv)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |