com.rolemodelsoft.drawlet.util
Class GraphicsGeometry

java.lang.Object
  |
  +--com.rolemodelsoft.drawlet.util.GraphicsGeometry

public class GraphicsGeometry
extends java.lang.Object

A collection of static geometric utility methods.


Constructor Summary
GraphicsGeometry()
           
 
Method Summary
static boolean intervalsOverlap(int start1, int stop1, int start2, int stop2)
          Answer whether the two intervals overlap.
protected static boolean isBetween(double potential, double first, double last)
           
protected static boolean sameLineSegmentsOverlap(int segment1x1, int segment1y1, int segment1x2, int segment1y2, int segment2x1, int segment2y1, int segment2x2, int segment2y2)
          Answer whether the first segment on a line overlaps the second segment on the same line.
static boolean segmentIntersectsLine(int segment1x1, int segment1y1, int segment1x2, int segment1y2, int segment2x1, int segment2y1, int segment2x2, int segment2y2)
          Answer whether the first segment intersects the line through the second segment.
static boolean segmentIntersectsNonVerticalLine(int segmentX1, int segmentY1, int segmentX2, int segmentY2, double slope, double yIntercept)
          Answer whether a segment intersects a non-vertical line.
static boolean segmentIntersectsSegment(int segment1x1, int segment1y1, int segment1x2, int segment1y2, int segment2x1, int segment2y1, int segment2x2, int segment2y2)
          Answer whether the two segments intersect.
static boolean segmentOverlapsSegment(int segment1x1, int segment1y1, int segment1x2, int segment1y2, int segment2x1, int segment2y1, int segment2x2, int segment2y2)
          Answer whether the first segment overlaps the second segment.
protected static boolean segmentsOnSameLine(int segment1x1, int segment1y1, int segment1x2, int segment1y2, int segment2x1, int segment2y1, int segment2x2, int segment2y2)
          Answer whether the first segment and second segment are on the same line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphicsGeometry

public GraphicsGeometry()
Method Detail

intervalsOverlap

public static boolean intervalsOverlap(int start1,
                                       int stop1,
                                       int start2,
                                       int stop2)
Answer whether the two intervals overlap.
Parameters:
start1 - int
stop1 - int
start2 - int
stop2 - int
Returns:
boolean

isBetween

protected static boolean isBetween(double potential,
                                   double first,
                                   double last)
Parameters:
seg1Constant - int
seg1Boundary1 - int
seg1Boundary2 - int
seg2Constant - int
seg2Boundary1 - int
seg2Boundary2 - int
Returns:
boolean

sameLineSegmentsOverlap

protected static boolean sameLineSegmentsOverlap(int segment1x1,
                                                 int segment1y1,
                                                 int segment1x2,
                                                 int segment1y2,
                                                 int segment2x1,
                                                 int segment2y1,
                                                 int segment2x2,
                                                 int segment2y2)
Answer whether the first segment on a line overlaps the second segment on the same line.

segmentIntersectsLine

public static boolean segmentIntersectsLine(int segment1x1,
                                            int segment1y1,
                                            int segment1x2,
                                            int segment1y2,
                                            int segment2x1,
                                            int segment2y1,
                                            int segment2x2,
                                            int segment2y2)
Answer whether the first segment intersects the line through the second segment.

segmentIntersectsNonVerticalLine

public static boolean segmentIntersectsNonVerticalLine(int segmentX1,
                                                       int segmentY1,
                                                       int segmentX2,
                                                       int segmentY2,
                                                       double slope,
                                                       double yIntercept)
Answer whether a segment intersects a non-vertical line.
Parameters:
segmentX1 - int
segmentY1 - int
segmentX2 - int
segmentY2 - int
slope - double
yIntercept - double
Returns:
boolean

segmentIntersectsSegment

public static boolean segmentIntersectsSegment(int segment1x1,
                                               int segment1y1,
                                               int segment1x2,
                                               int segment1y2,
                                               int segment2x1,
                                               int segment2y1,
                                               int segment2x2,
                                               int segment2y2)
Answer whether the two segments intersect. based on Paul Bourke's algorithm at http://www.mhri.edu.au/~pdb/geometry/lineline2d

segmentOverlapsSegment

public static boolean segmentOverlapsSegment(int segment1x1,
                                             int segment1y1,
                                             int segment1x2,
                                             int segment1y2,
                                             int segment2x1,
                                             int segment2y1,
                                             int segment2x2,
                                             int segment2y2)
Answer whether the first segment overlaps the second segment.

segmentsOnSameLine

protected static boolean segmentsOnSameLine(int segment1x1,
                                            int segment1y1,
                                            int segment1x2,
                                            int segment1y2,
                                            int segment2x1,
                                            int segment2y1,
                                            int segment2x2,
                                            int segment2y2)
Answer whether the first segment and second segment are on the same line.