|
||||||||||
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(Point p1,
Point p2)
Returns the angle of the vector from p1 to p2 |
static Point |
getCenter(Dimension dim)
|
static Point |
getCenter(Rectangle loc)
|
static Point[] |
getConnectingLine(Point start,
Rectangle r2)
|
static Point[] |
getConnectingLine(Rectangle r1,
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,
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(Point point)
Returns the norm of the vector represented by point |
static double |
getDistance(Point point1,
Point point2)
Computes distance between two points |
static Dimension |
getMax(Dimension d1,
Dimension d2)
|
static Dimension |
getMaxInPlace(Dimension res,
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 Dimension |
getMaxInPlace(Dimension res,
int otherWidth,
int otherHeight)
|
static Dimension |
getMin(Dimension d1,
Dimension d2)
|
static Dimension |
getMinInPlace(Dimension res,
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 Insets |
getMinInPlace(Insets res,
Insets other)
|
static Dimension |
getSumInPlace(Dimension res,
Dimension other)
|
static Dimension |
getSumInPlace(Dimension res,
int x,
int y)
|
static Point |
getVector(Point start,
Point end)
|
static Point |
getXY(double distance,
double angle)
Converts vector representation from polar to Euclidian coordinates |
static Point |
getXY(Point offset,
double distance,
double angle)
|
static Rectangle |
interpolate(Rectangle start,
Rectangle target,
double fraction,
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 Point |
lineSegmentIntersection(Point line1P1,
Point line1P2,
Point line2P1,
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 Point |
rotate(Point point,
double angle)
Rotate a point around the origin |
static Point |
translate(Point point,
double distance,
double angle)
|
static Point |
translate(Point point,
Point offset)
|
static Point |
uniqueLineSegmentRectangleIntersection(Point p1,
Point p2,
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 Point rotate(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 Point translate(Point point, Point offset)
public static Point translate(Point point, double distance, double angle)
public static double getDistance(Point point1, Point point2)
point1
- point2
-
public static double getDistance(double p1x, double p1y, double p2x, double p2y)
public static double getDistance(double x, double y, Polygon polygn)
x
- y
- polygn
-
public static double getDistance(Point point)
point
-
public static Point getVector(Point start, Point end)
public static Point getXY(double distance, double angle)
distance
- angle
-
public static Point getXY(Point offset, double distance, double angle)
public static Point getCenter(Dimension dim)
public static Point getCenter(Rectangle loc)
public static Dimension getMin(Dimension d1, Dimension d2)
public static Dimension getMinInPlace(Dimension res, Dimension other)
res
- other
-
public static Dimension getMax(Dimension d1, Dimension d2)
public static Dimension getMaxInPlace(Dimension res, int otherWidth, int otherHeight)
public static Dimension getMaxInPlace(Dimension res, Dimension other)
res
- other
-
public static Dimension getSumInPlace(Dimension res, Dimension other)
public static Dimension getSumInPlace(Dimension res, int x, int y)
public static Insets getMinInPlace(Insets res, Insets other)
public static double getAngle(Point p1, Point p2)
p1
- p2
-
public static Point[] getConnectingLine(Rectangle r1, Rectangle r2)
public static Point[] getConnectingLine(Point start, Rectangle r2)
public static Point uniqueLineSegmentRectangleIntersection(Point p1, Point p2, 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 Point lineSegmentIntersection(Point line1P1, Point line1P2, Point line2P1, 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 Rectangle interpolate(Rectangle start, Rectangle target, double fraction, Rectangle res)
start
- target
- fraction
- res
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |