org.tigris.gef.base
Class Geometry

java.lang.Object
  extended by org.tigris.gef.base.Geometry

public class Geometry
extends java.lang.Object

A library of functions that do geometric opeations. These are all static methods, so you never need to make an instance of this class. Needs-More-Work: many of these are not done yet or not used yet.


Constructor Summary
Geometry()
           
 
Method Summary
static int counterClockWise(int x1, int y1, int x2, int y2, int x, int y)
          Reply true if the given point is counter-clockwise from the vector defined by the position of the given line.
static boolean intersects(java.awt.Rectangle r, int x1, int y1, int x2, int y2)
          Reply true if the given Rectangle intersects the given line segment.
static boolean nearPolySegment(int[] xs, int[] ys, int n, int x, int y, int grip)
          Reply true iff the given point is within grip pixels of one of the segments of the given polygon.
static boolean nearSegment(int x1, int y1, int x2, int y2, int x, int y, int grip)
          Reply true if the given point is within grip pixels of the given segment.
static java.awt.Point ptClosestTo(int[] xs, int[] ys, int n, java.awt.Point p)
          Given a polygon and a point, return a new point on the perimiter of the polygon that is closest to to the given point.
static void ptClosestTo(int[] xs, int[] ys, int n, java.awt.Point p, java.awt.Point res)
          Given a polygon and a point, set res to be the point on the perimiter of the polygon that is closest to to the given point.
static java.awt.Point ptClosestTo(int x1, int y1, int x2, int y2, java.awt.Point p)
          Given the coordinates of the endpoints of a line segment, and a point, return a new point that is the closest point on the segement to the given point.
static void ptClosestTo(int x1, int y1, int x2, int y2, java.awt.Point p, java.awt.Point res)
          Given the coordinates of the endpoints of a line segment, and a point, set res to be the closest point on the segement to the given point.
static java.awt.Point ptClosestTo(java.awt.Point p1, java.awt.Point p2, java.awt.Point p)
          Given the endpoints of a line segment, and a point, return a new point that is the closest point on the segement to the given point.
static java.awt.Point ptClosestTo(java.awt.Rectangle r, java.awt.Point p)
          Given a Rectangle and a point, return a new Point on or in the Rectangle that is closest to the given Point.
static void ptClosestTo(java.awt.Rectangle r, java.awt.Point p, java.awt.Point res)
          Given a Rectangle and a point, set res to be the point on or in the Rectangle that is closest to the given point.
static double segmentAngle(java.awt.Point p1, java.awt.Point p2)
          Return the angle of the given line segment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Geometry

public Geometry()
Method Detail

ptClosestTo

public static void ptClosestTo(java.awt.Rectangle r,
                               java.awt.Point p,
                               java.awt.Point res)
Given a Rectangle and a point, set res to be the point on or in the Rectangle that is closest to the given point.


ptClosestTo

public static java.awt.Point ptClosestTo(java.awt.Rectangle r,
                                         java.awt.Point p)
Given a Rectangle and a point, return a new Point on or in the Rectangle that is closest to the given Point.


segmentAngle

public static double segmentAngle(java.awt.Point p1,
                                  java.awt.Point p2)
Return the angle of the given line segment.


ptClosestTo

public static void ptClosestTo(int x1,
                               int y1,
                               int x2,
                               int y2,
                               java.awt.Point p,
                               java.awt.Point res)
Given the coordinates of the endpoints of a line segment, and a point, set res to be the closest point on the segement to the given point.


ptClosestTo

public static java.awt.Point ptClosestTo(int x1,
                                         int y1,
                                         int x2,
                                         int y2,
                                         java.awt.Point p)
Given the coordinates of the endpoints of a line segment, and a point, return a new point that is the closest point on the segement to the given point.


ptClosestTo

public static java.awt.Point ptClosestTo(java.awt.Point p1,
                                         java.awt.Point p2,
                                         java.awt.Point p)
Given the endpoints of a line segment, and a point, return a new point that is the closest point on the segement to the given point.


ptClosestTo

public static void ptClosestTo(int[] xs,
                               int[] ys,
                               int n,
                               java.awt.Point p,
                               java.awt.Point res)
Given a polygon and a point, set res to be the point on the perimiter of the polygon that is closest to to the given point.


ptClosestTo

public static java.awt.Point ptClosestTo(int[] xs,
                                         int[] ys,
                                         int n,
                                         java.awt.Point p)
Given a polygon and a point, return a new point on the perimiter of the polygon that is closest to to the given point.


nearPolySegment

public static boolean nearPolySegment(int[] xs,
                                      int[] ys,
                                      int n,
                                      int x,
                                      int y,
                                      int grip)
Reply true iff the given point is within grip pixels of one of the segments of the given polygon. Needs-more-work: this is never used, I don't know that it is needed now that I use hit rectangles instead.


nearSegment

public static boolean nearSegment(int x1,
                                  int y1,
                                  int x2,
                                  int y2,
                                  int x,
                                  int y,
                                  int grip)
Reply true if the given point is within grip pixels of the given segment. Needs-more-work: this is never used, I don't know that it is needed now that I use hit rectangles instead.


intersects

public static boolean intersects(java.awt.Rectangle r,
                                 int x1,
                                 int y1,
                                 int x2,
                                 int y2)
Reply true if the given Rectangle intersects the given line segment.


counterClockWise

public static int counterClockWise(int x1,
                                   int y1,
                                   int x2,
                                   int y2,
                                   int x,
                                   int y)
Reply true if the given point is counter-clockwise from the vector defined by the position of the given line. This is used as in determining intersection between lines and rectangles. Taken from Algorithms in C by Sedgewick, page 350.