Poseidon for UMLTM
  UMLdoc
 PREV  CLASSIFIER    NEXT  CLASSIFIER     FRAMES    NO FRAMES      
SUMMARY:   INNER | ATTR | ASSOC | CONSTR | METHOD     DETAIL:   INNER | ATTR | ASSOC | CONSTR | METHOD     DIAGRAMS:   COLLAB | SEQ | STATE | ACTIV

com.gentleware.services.util

Class Geometry

com.gentleware.services.util.Geometry

public class Geometry


Authors:
Stephen Kelvin


 Attribute Summary
private static int  COORD_GREATER
 
private static int  COORD_INSIDE
 
private static int  COORD_IN_FIRST_GAP
 
private static int  COORD_IN_SECOND_GAP
 
private static int  COORD_SMALLER
 
private static int  FLAG_ABOVE
 
private static int  FLAG_BELOW
 
private static int  FLAG_LEFT
 
private static int  FLAG_RIGHT
 
private static int  INSIDE
 
arrow_up
 

 Method Summary
private static int   classify(double coord, double start, double end, double gap)
 
public static boolean   clipSegmentAtRectangle(Point2D a, Point2D b, double left, double top, double right, double bottom)
Clips the segment given be points a and b at the given rectangle (using Cohen-Sutherland algorithm). 
public static double   getAngleBetween(Point2D first, Point2D second)
Calculates the angle between the straight line defined through the points first and second and the x-axis in rad. 
public static double   getAngleBetween(double x0, double y0, double x1, double y1)
 
private static int   getClipCode(double x, double y, double left, double top, double right, double bottom)
 
public static Point2D   getClosestPointOnEllipse(double centerX, double centerY, double radiusX, double radiusY, double pointX, double pointY)
 
private static Point2D   getClosestPointOnEllipseInt(double a, double b, double u, double v)
See description at http://www.magic-software.com/Documentation/DistancePointToEllipse2.pdf and sources at http://www.magic-software.com/Source2D.html  
public static Point2D   getClosestPointOnLine(double lineX, double lineY, double lineAngle, double x, double y)
 
public static Point2D   getClosestPointOnLine(double lineX0, double lineY0, double lineX1, double lineY1, double px, double py)
 
public static Point2D   getClosestPointOnRectangle(double x, double y, double width, double height, double otherX, double otherY)
Calculates the point on the border of the rectangle closest to the given point. 
public static Point2D   getClosestPointOnRhombus(double x, double y, double width, double height, double px, double py)
 
public static Point2D   getClosestPointOnRoundRectangle(double left, double top, double width, double height, double arcWidth, double arcHeight, double x, double y)
 
public static Point2D   getClosestPointOnSegment(double lineX0, double lineY0, double lineX1, double lineY1, double px, double py)
 
public static double   getDistanceBetween(Point2D p0, Point2D p1)
 
public static Point2D   getLineIntersection(double x0, double y0, double angle0, double x1, double y1, double angle1)
 
private static boolean   isAngleHorz(double theta)
 
public static double   normalizeAngle(double angle)
 
public static Point2D   polarToRectangular(double angle, double distance)
 
public static Point2D   polarToRectangular(double angle, double distance, Point2D result)
 
public static Point2D   polarToRectangular(double angle, double distance, double x, double y)
 
public static Point2D   polarToRectangular(double angle, double distance, double x, double y, Point2D result)
 
arrow_up
 

Tagged Values
static false
 

 Attribute Detail

COORD_GREATER

private static int COORD_GREATER

arrow_up


COORD_INSIDE

private static int COORD_INSIDE

arrow_up


COORD_IN_FIRST_GAP

private static int COORD_IN_FIRST_GAP

arrow_up


COORD_IN_SECOND_GAP

private static int COORD_IN_SECOND_GAP

arrow_up


COORD_SMALLER

private static int COORD_SMALLER

arrow_up


FLAG_ABOVE

private static int FLAG_ABOVE

arrow_up


FLAG_BELOW

private static int FLAG_BELOW

arrow_up


FLAG_LEFT

private static int FLAG_LEFT

arrow_up


FLAG_RIGHT

private static int FLAG_RIGHT

arrow_up


INSIDE

private static int INSIDE

arrow_up
 Method Detail

classify

private static int classify(double coord, double start, double end, double gap)

Parameters:
coord -
start -
end -
gap -
Returns:
arrow_up


clipSegmentAtRectangle

public static boolean clipSegmentAtRectangle(Point2D a, Point2D b, double left, double top, double right, double bottom)


Clips the segment given be points a and b at the given rectangle (using Cohen-Sutherland algorithm). Does not modify a and b if the segment does not intersect the rectangle (or is contained in the rectangle)  
Parameters:
a -
b -
left -
top -
right -
bottom -
Returns:
true if the the segment intersects (or is contained in) the rectangle.
arrow_up


getAngleBetween

public static double getAngleBetween(Point2D first, Point2D second)


Calculates the angle between the straight line defined through the points first and second and the x-axis in rad.  
Parameters:
first - First point of the straight line.
second - Second point of the straight line.
Returns:
Angle between straight line and x-axis in rad. (0 <= angle < 2 pi)
arrow_up


getAngleBetween

public static double getAngleBetween(double x0, double y0, double x1, double y1)

Parameters:
x0 -
y0 -
x1 -
y1 -
Returns:
arrow_up


getClipCode

private static int getClipCode(double x, double y, double left, double top, double right, double bottom)

Parameters:
x -
y -
left -
top -
right -
bottom -
Returns:
arrow_up


getClosestPointOnEllipse

public static Point2D getClosestPointOnEllipse(double centerX, double centerY, double radiusX, double radiusY, double pointX, double pointY)

Parameters:
centerX -
centerY -
radiusX -
radiusY -
pointX -
pointY -
Returns:
the point on the ellipse described by centerX/Y, radiusX/Y that is closest to pointX/Y
arrow_up


getClosestPointOnEllipseInt

private static Point2D getClosestPointOnEllipseInt(double a, double b, double u, double v)


See description at http://www.magic-software.com/Documentation/DistancePointToEllipse2.pdf and sources at http://www.magic-software.com/Source2D.html  
Parameters:
a -
b -
u -
v -
Returns:
the point on the ellipse (x/a)^2 + (y/b)^2 = 1 that is closest to (u, v)
arrow_up


getClosestPointOnLine

public static Point2D getClosestPointOnLine(double lineX, double lineY, double lineAngle, double x, double y)

Parameters:
lineX -
lineY -
lineAngle -
x -
y -
Returns:
arrow_up


getClosestPointOnLine

public static Point2D getClosestPointOnLine(double lineX0, double lineY0, double lineX1, double lineY1, double px, double py)

Parameters:
lineX0 -
lineY0 -
lineX1 -
lineY1 -
px -
py -
Returns:
arrow_up


getClosestPointOnRectangle

public static Point2D getClosestPointOnRectangle(double x, double y, double width, double height, double otherX, double otherY)


Calculates the point on the border of the rectangle closest to the given point. All coordinates are global.  
Parameters:
x -
y -
width -
height -
otherX -
otherY -
Returns:
the point closest to the rectangle described by x, y, width, height from otherPoint
arrow_up


getClosestPointOnRhombus

public static Point2D getClosestPointOnRhombus(double x, double y, double width, double height, double px, double py)

Parameters:
x -
y -
width -
height -
px -
py -
Returns:
arrow_up


getClosestPointOnRoundRectangle

public static Point2D getClosestPointOnRoundRectangle(double left, double top, double width, double height, double arcWidth, double arcHeight, double x, double y)

Parameters:
left -
top -
width -
height -
arcWidth -
arcHeight -
x -
y -
Returns:
arrow_up


getClosestPointOnSegment

public static Point2D getClosestPointOnSegment(double lineX0, double lineY0, double lineX1, double lineY1, double px, double py)

Parameters:
lineX0 -
lineY0 -
lineX1 -
lineY1 -
px -
py -
Returns:
arrow_up


getDistanceBetween

public static double getDistanceBetween(Point2D p0, Point2D p1)

Parameters:
p0 -
p1 -
Returns:
arrow_up


getLineIntersection

public static Point2D getLineIntersection(double x0, double y0, double angle0, double x1, double y1, double angle1)

Parameters:
x0 -
y0 -
angle0 -
x1 -
y1 -
angle1 -
Returns:
the intersection point of two lines described by a point and an angle, null if the lines are parallel
arrow_up


isAngleHorz

private static boolean isAngleHorz(double theta)

Parameters:
theta - must be normalized, i.e. in [0, 2*PI]
Returns:
true if the absolute slope of a line with angle theta is < 1
arrow_up


normalizeAngle

public static double normalizeAngle(double angle)

Parameters:
angle - in radians
Returns:
angle in [0, 2*Math.PI[
arrow_up


polarToRectangular

public static Point2D polarToRectangular(double angle, double distance)

Parameters:
angle -
distance -
Returns:
arrow_up


polarToRectangular

public static Point2D polarToRectangular(double angle, double distance, Point2D result)

Parameters:
angle -
distance -
result -
Returns:
arrow_up


polarToRectangular

public static Point2D polarToRectangular(double angle, double distance, double x, double y)

Parameters:
angle -
distance -
x -
y -
Returns:
arrow_up


polarToRectangular

public static Point2D polarToRectangular(double angle, double distance, double x, double y, Point2D result)

Parameters:
angle -
distance -
x -
y -
result -
Returns:
arrow_up
Created  2004 - 10 - 21

    Poseidon for UMLTM
  UMLdoc
 PREV  CLASSIFIER    NEXT  CLASSIFIER     FRAMES    NO FRAMES      
SUMMARY:   INNER | ATTR | ASSOC | CONSTR | METHOD     DETAIL:   INNER | ATTR | ASSOC | CONSTR | METHOD     DIAGRAMS:   COLLAB | SEQ | STATE | ACTIV

Generated with Poseidon for UMLTM.
Poseidon is a registered trademark of Gentleware AG in Germany, USA and other countries. Copyright 2003-2004 Gentleware AG, Schanzenstr. 70, 20357 Hamburg, Germany. All Rights Reserved.

UML is a trademark or registered trademark of Object Management Group, Inc. in the U.S. and other countries.