| java.lang.Object org.cougaar.mlm.debug.ui.draw.DrawUtil
DrawUtil | public class DrawUtil (Code) | | class DrawUtil
Drawing utility functions
|
Method Summary | |
final public static Point[] | bresenham_line(Point pt1, Point pt2) Bresenham's line algorithm. | final public static Point[] | bresenham_line(int x1, int y1, int x2, int y2) Bresenham's line algorithm. | final public static float | closestPolyDistance(int[] xpts, int[] ypts, int ptx, int pty, boolean connected) | final public static float | distance(int x1, int y1, int x2, int y2) | final public static float | distance_to_endpoint(int x1, int y1, int x2, int y2, int x, int y) | final public static float | distance_to_line(int x1, int y1, int x2, int y2, int x, int y) distance_to_line(): Compute the distance from point (x,y) to a
line by computing the perpendicular line from (x,y) to the
line and finding the intersection of this perpendicular and
the line. | public static OMVector | generateWideLine(int lw, int x1, int y1, int x2, int y2) | public static OMVector | generateWidePoly(int lw, int[] xpts, int[] ypts, int[] altx, boolean connect) generateWidePoly() - generates a polygon or polyline with
positive width lw, returns OMVector of x-y array pairs of
coordinates of polygon segments. | public static OMVector | generateWidePoly(int lw, int len, int[] xpts, int[] ypts, int[] altx, boolean connect) | final public static boolean | inside_polygon(int[] xpts, int[] ypts, int ptx, int pty) | public static void | main(String[] args) |
bresenham_line | final public static Point[] bresenham_line(Point pt1, Point pt2)(Code) | | Bresenham's line algorithm. Returns an array of points to draw.
|
bresenham_line | final public static Point[] bresenham_line(int x1, int y1, int x2, int y2)(Code) | | Bresenham's line algorithm.
|
closestPolyDistance | final public static float closestPolyDistance(int[] xpts, int[] ypts, int ptx, int pty, boolean connected)(Code) | | closestPolyDistance() - returns the distance from Point (x,y)
to the closest line segment in the Poly (int[] xpts, ypts)
|
distance | final public static float distance(int x1, int y1, int x2, int y2)(Code) | | distance() - 2D distance formula
|
distance_to_endpoint | final public static float distance_to_endpoint(int x1, int y1, int x2, int y2, int x, int y)(Code) | | distance_to_endpoint() - distance to closest endpoint
|
distance_to_line | final public static float distance_to_line(int x1, int y1, int x2, int y2, int x, int y)(Code) | | distance_to_line(): Compute the distance from point (x,y) to a
line by computing the perpendicular line from (x,y) to the
line and finding the intersection of this perpendicular and
the line. If the intersection is on the line segment, then
the distance is the distance from the mouse to the
intersection, otherwise it is the distance from (x,y) to the
nearest endpoint.
Equations used to compute distance:
m = (y2-y1)/(x2-x1) slope of the line
y = mx + b equation of the line
c = -1/m slope of line perpendicular to it
y = cx + d equation of perpendicular line
xi = (d-b)/(m-c) x-intersection, from equating the two line equations
y1 = c* xi + d y-intersection
distance = sqrt(sqr(x-xi) + sqr(y-yi)) distance between two points
|
generateWideLine | public static OMVector generateWideLine(int lw, int x1, int y1, int x2, int y2)(Code) | | |
generateWidePoly | public static OMVector generateWidePoly(int lw, int[] xpts, int[] ypts, int[] altx, boolean connect)(Code) | | generateWidePoly() - generates a polygon or polyline with
positive width lw, returns OMVector of x-y array pairs of
coordinates of polygon segments. the parameter altx must
either be null, or a mirror image of xpts.
|
generateWidePoly | public static OMVector generateWidePoly(int lw, int len, int[] xpts, int[] ypts, int[] altx, boolean connect)(Code) | | |
inside_polygon | final public static boolean inside_polygon(int[] xpts, int[] ypts, int ptx, int pty)(Code) | | inside_polygon() - tests if a point is inside a polygon
|
main | public static void main(String[] args)(Code) | | main() - for testing
|
|
|