org.pzgui.math
Class IntersectionFinder

java.lang.Object
  extended by org.pzgui.math.IntersectionFinder

public class IntersectionFinder
extends java.lang.Object

Algorithms for finding the intersection points of lines and other shapes.

Author:
David Underhill

Constructor Summary
IntersectionFinder()
           
 
Method Summary
static Vector2i intersect(Vector2i p1, Vector2i p2, int width, int height)
          Returns the first intersection point of a ray cast from point p to the edge of a box.
static Vector2f intersectBox(Line l, int x, int y, int w, int h)
          Returns an intersection point of l and the specified box or null if they do not intersection
static Vector2f intersectBox(Line l, Node n)
          Returns an intersection point of l and the area of the specified Icon or null if they do not intersection
static Vector2f intersectLine(Line l1, Line l2)
          Returns the insersection point of l1 and l2, or null if they do not intersect
static Vector2f intersectLineHelper(Line l1, Line l2)
          Returns the insersection point of infinite lines l1 and l2, or null if they are parallel
static boolean isWithin(Vector2f i, Line l)
          returns true if i is within the bounds of l
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntersectionFinder

public IntersectionFinder()
Method Detail

intersectLineHelper

public static Vector2f intersectLineHelper(Line l1,
                                           Line l2)
Returns the insersection point of infinite lines l1 and l2, or null if they are parallel


isWithin

public static boolean isWithin(Vector2f i,
                               Line l)
returns true if i is within the bounds of l


intersectLine

public static Vector2f intersectLine(Line l1,
                                     Line l2)
Returns the insersection point of l1 and l2, or null if they do not intersect


intersectBox

public static Vector2f intersectBox(Line l,
                                    int x,
                                    int y,
                                    int w,
                                    int h)
Returns an intersection point of l and the specified box or null if they do not intersection


intersectBox

public static Vector2f intersectBox(Line l,
                                    Node n)
Returns an intersection point of l and the area of the specified Icon or null if they do not intersection


intersect

public static Vector2i intersect(Vector2i p1,
                                 Vector2i p2,
                                 int width,
                                 int height)
Returns the first intersection point of a ray cast from point p to the edge of a box. This method assumes the object is centered around x2 and y2.