gizmoball.shape
Class ShapeGeometry

java.lang.Object
  extended by gizmoball.shape.ShapeGeometry

public class ShapeGeometry
extends java.lang.Object

This class contains static methods to perform geometry computations more complex than those in the Geometry class, such as those involving Shape objects. With these methods we can test Shape overlap or containment, as well as line segment intersection and midpoints.

Author:
Eitan Reich

Constructor Summary
ShapeGeometry()
           
 
Method Summary
static boolean containsShape(Shape enclosing, Shape contained)
          This method checks whethre one shape is completely contained in another.
static boolean lineSegmentContainsPoint(LineSegment s, Vect v)
           
static boolean lineSegmentsIntersect(LineSegment s1, LineSegment s2)
          This method tests whether the two line segments intersect
static boolean lineSegmentsIntersectProper(LineSegment s1, LineSegment s2)
           
static Vect midPoint(LineSegment s)
           
static boolean overlap(Shape s1, Shape s2)
          Tests whether two shapes overlap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShapeGeometry

public ShapeGeometry()
Method Detail

midPoint

public static Vect midPoint(LineSegment s)
Parameters:
s - line segment
Returns:
the midpoint of the line segment

lineSegmentContainsPoint

public static boolean lineSegmentContainsPoint(LineSegment s,
                                               Vect v)
Parameters:
s - line segment
v - point
Returns:
true iff the specified point is on the line segment

lineSegmentsIntersect

public static boolean lineSegmentsIntersect(LineSegment s1,
                                            LineSegment s2)
This method tests whether the two line segments intersect

Parameters:
s1 - first line segment
s2 - second line segment
Returns:
true if and only if s1 and s2 intersect

lineSegmentsIntersectProper

public static boolean lineSegmentsIntersectProper(LineSegment s1,
                                                  LineSegment s2)
Parameters:
s1 - line segment
s2 - lne segment
Returns:
true if the two line segments intersect on points not including the endpoints of either segment

overlap

public static boolean overlap(Shape s1,
                              Shape s2)
Tests whether two shapes overlap. Shape objects must be either Circle09, Polygon or UnionShape

Parameters:
s1 - Shape
s2 - Shape
Returns:
true iff shapes overlap

containsShape

public static boolean containsShape(Shape enclosing,
                                    Shape contained)
This method checks whethre one shape is completely contained in another. The shapes must be either Circle09, Polygon or UnionShape. The behavior is only correct if the enclosing shape is Circle09 or Polygon. If the enclosing shape is a UnionShape the method tests whether one of the constituent shapes completely contains the specified shape.

Parameters:
enclosing -
contained -
Returns:
true if the enclosing shape completely contains the other shape