|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.harvard.seas.iis.util.geom2D.Geom2DUtils
public class Geom2DUtils
Constructor Summary | |
---|---|
Geom2DUtils()
|
Method Summary | |
---|---|
static double |
getAngle(java.awt.Point p1,
java.awt.Point p2)
Returns the angle of the vector from p1 to p2 |
static java.awt.Point |
getCenter(java.awt.Dimension dim)
|
static java.awt.Point |
getCenter(java.awt.Rectangle loc)
|
static java.awt.Point[] |
getConnectingLine(java.awt.Point start,
java.awt.Rectangle r2)
|
static java.awt.Point[] |
getConnectingLine(java.awt.Rectangle r1,
java.awt.Rectangle r2)
Find the shortest connecting line between two rectangles. |
static double |
getDistance(double p1x,
double p1y,
double p2x,
double p2y)
|
static double |
getDistance(double x,
double y,
java.awt.Polygon polygn)
computes the distance from the point to the nearest point on the polygon boundary (works for points insider or outside the plygon) |
static double |
getDistance(java.awt.Point point)
Returns the norm of the vector represented by point |
static double |
getDistance(java.awt.Point point1,
java.awt.Point point2)
Computes distance between two points |
static java.awt.Dimension |
getMax(java.awt.Dimension d1,
java.awt.Dimension d2)
|
static java.awt.Dimension |
getMaxInPlace(java.awt.Dimension res,
java.awt.Dimension other)
computes max of the two dimensions but instead of creating a new return object, it modifies the first parameter to contain the answer |
static java.awt.Dimension |
getMaxInPlace(java.awt.Dimension res,
int otherWidth,
int otherHeight)
|
static java.awt.Dimension |
getMin(java.awt.Dimension d1,
java.awt.Dimension d2)
|
static java.awt.Dimension |
getMinInPlace(java.awt.Dimension res,
java.awt.Dimension other)
computes min of the two dimensions but instead of creating a new return object, it modifies the first parameter to contain the answer |
static java.awt.Insets |
getMinInPlace(java.awt.Insets res,
java.awt.Insets other)
|
static java.awt.Dimension |
getSumInPlace(java.awt.Dimension res,
java.awt.Dimension other)
|
static java.awt.Dimension |
getSumInPlace(java.awt.Dimension res,
int x,
int y)
|
static java.awt.Point |
getVector(java.awt.Point start,
java.awt.Point end)
|
static java.awt.Point |
getXY(double distance,
double angle)
Converts vector representation from polar to Euclidian coordinates |
static java.awt.Point |
getXY(java.awt.Point offset,
double distance,
double angle)
|
static java.awt.Rectangle |
interpolate(java.awt.Rectangle start,
java.awt.Rectangle target,
double fraction,
java.awt.Rectangle res)
Returns a rectangle that is an interpolation between start and target; if res is not null, the result will be put into it and returned; if res is null, a new Rectangle object will be allocated |
static java.awt.Point |
lineSegmentIntersection(java.awt.Point line1P1,
java.awt.Point line1P2,
java.awt.Point line2P1,
java.awt.Point line2P2)
Determine the intersection point of two line segments, or return null if no intersection. |
static double[] |
rotate(double x,
double y,
double angle)
|
static java.awt.Point |
rotate(java.awt.Point point,
double angle)
Rotate a point around the origin |
static java.awt.Point |
translate(java.awt.Point point,
double distance,
double angle)
|
static java.awt.Point |
translate(java.awt.Point point,
java.awt.Point offset)
|
static java.awt.Point |
uniqueLineSegmentRectangleIntersection(java.awt.Point p1,
java.awt.Point p2,
java.awt.Rectangle r)
Determine the unique intersection point of a line segment and a rectangle. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Geom2DUtils()
Method Detail |
---|
public static java.awt.Point rotate(java.awt.Point point, double angle)
point
- point to be rotatedangle
- the rotation angle (in radians)
public static double[] rotate(double x, double y, double angle)
public static java.awt.Point translate(java.awt.Point point, java.awt.Point offset)
public static java.awt.Point translate(java.awt.Point point, double distance, double angle)
public static double getDistance(java.awt.Point point1, java.awt.Point point2)
point1
- point2
-
public static double getDistance(double p1x, double p1y, double p2x, double p2y)
public static double getDistance(double x, double y, java.awt.Polygon polygn)
x
- y
- polygn
-
public static double getDistance(java.awt.Point point)
point
-
public static java.awt.Point getVector(java.awt.Point start, java.awt.Point end)
public static java.awt.Point getXY(double distance, double angle)
distance
- angle
-
public static java.awt.Point getXY(java.awt.Point offset, double distance, double angle)
public static java.awt.Point getCenter(java.awt.Dimension dim)
public static java.awt.Point getCenter(java.awt.Rectangle loc)
public static java.awt.Dimension getMin(java.awt.Dimension d1, java.awt.Dimension d2)
public static java.awt.Dimension getMinInPlace(java.awt.Dimension res, java.awt.Dimension other)
res
- other
-
public static java.awt.Dimension getMax(java.awt.Dimension d1, java.awt.Dimension d2)
public static java.awt.Dimension getMaxInPlace(java.awt.Dimension res, int otherWidth, int otherHeight)
public static java.awt.Dimension getMaxInPlace(java.awt.Dimension res, java.awt.Dimension other)
res
- other
-
public static java.awt.Dimension getSumInPlace(java.awt.Dimension res, java.awt.Dimension other)
public static java.awt.Dimension getSumInPlace(java.awt.Dimension res, int x, int y)
public static java.awt.Insets getMinInPlace(java.awt.Insets res, java.awt.Insets other)
public static double getAngle(java.awt.Point p1, java.awt.Point p2)
p1
- p2
-
public static java.awt.Point[] getConnectingLine(java.awt.Rectangle r1, java.awt.Rectangle r2)
public static java.awt.Point[] getConnectingLine(java.awt.Point start, java.awt.Rectangle r2)
public static java.awt.Point uniqueLineSegmentRectangleIntersection(java.awt.Point p1, java.awt.Point p2, java.awt.Rectangle r)
p1
- Coordinates of one end of a linep2
- Coordinates of the other end of a liner
- Rectangle object
copied from org/metagraph/utility/graphics/GraphicsUtil.java
public static java.awt.Point lineSegmentIntersection(java.awt.Point line1P1, java.awt.Point line1P2, java.awt.Point line2P1, java.awt.Point line2P2)
line1P1
- Coordinates of one end of line #1line1P2
- Coordinates of the other end of line #1line2P1
- Coordinates of one end of line #2line2P2
- Coordinates of the other end of line #2
copied from org/metagraph/utility/graphics/GraphicsUtil.java
public static java.awt.Rectangle interpolate(java.awt.Rectangle start, java.awt.Rectangle target, double fraction, java.awt.Rectangle res)
start
- target
- fraction
- res
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |