|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.geom.Geom
public final class Geom
This class provides useful geometric primitives and advanced geometric algorithms.
This class is intended to provide static methods for geometric calculations. It can be compared to the classjava.lang.Math
which provides methods for general mathematical calculations.
Method Summary | |
---|---|
static YList |
calcConvexHull(YList points)
Calculates the convex hull for a set of points. |
static YPoint |
calcIntersection(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double x4,
double y4)
Calculates the intersection point of two affine lines. |
static java.awt.geom.Rectangle2D |
calcIntersection(java.awt.geom.Rectangle2D r1,
java.awt.geom.Rectangle2D r2,
java.awt.geom.Rectangle2D dest)
Intersects the pair of specified source Rectangle2D
objects and puts the result into the specified destination
Rectangle2D object. |
static YPoint |
calcIntersection(YPoint p1,
YPoint p2,
YPoint p3,
YPoint p4)
Calculates the intersection point of two affine lines. |
static YPoint |
calcIntersection(YPoint p1,
YVector d1,
YPoint p2,
YVector d2)
Calculates the intersection point of two affine lines. |
static java.awt.geom.Rectangle2D |
calcTransformedBounds(double x,
double y,
double width,
double height,
java.awt.geom.AffineTransform transform,
java.awt.geom.Rectangle2D dest)
Calculates the bounding box of the rectangle at location (x,y) with the specified width and height after the specified transformation has been applied. |
static java.awt.geom.Rectangle2D |
calcUnion(java.awt.geom.Rectangle2D r1,
java.awt.geom.Rectangle2D r2,
java.awt.geom.Rectangle2D dest)
Unions the pair of source Rectangle2D objects
and puts the result into the specified destination
Rectangle2D object. |
static boolean |
collinear(YPoint p,
YPoint q,
YPoint r)
Returns true iff the given points are collinear, that is, all
three points lie on a common line. |
static double |
distanceToLineSegment(double pointX,
double pointY,
double lineX1,
double lineY1,
double lineX2,
double lineY2)
Determines the distance of the point p to the line segment
[l1, l2] . |
static boolean |
leftTurn(YPoint p,
YPoint q,
YPoint r)
Same as orientation(p,q,r) > 0 |
static boolean |
linesIntersect(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double x4,
double y4)
Same as Line2D.linesIntersect(double, double, double, double, double, double, double, double) . |
static int |
orientation(double px,
double py,
double qx,
double qy,
double rx,
double ry)
Same as orientation(YPoint, YPoint, YPoint) with double values as arguments. |
static int |
orientation(YPoint p,
YPoint q,
YPoint r)
Returns the orientation of point r relative to the directed
line from point p to point q . |
static YPoint |
projection(double pointX,
double pointY,
double lineX1,
double lineY1,
double lineX2,
double lineY2)
Determines the projection of the point p onto the line
segment [l1, l2] . |
static boolean |
rightTurn(YPoint p,
YPoint q,
YPoint r)
Same as orientation(p,q,r) < 0 |
static int |
sideOfCircle(YPoint a,
YPoint b,
YPoint c,
YPoint d)
Returns +1 if point d lies left of the directed circle through
points a , b , and c ,
0 if a,b,c and d are cocircular, and -1 otherwise. |
static double |
toDegrees(double angrad)
Same as Math.toDegrees(double) . |
static double |
toRadians(double angdeg)
Same as Math.toRadians(double) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static int orientation(YPoint p, YPoint q, YPoint r)
r
relative to the directed
line from point p
to point q
.
The given tuple of points is said to have positive orientation if
p
and q
are distinct and r
lies
to the left of the oriented line passing through p
and q
and oriented from p
to q
.
The tuple is said to have negative orientation if
p
and q
are distinct and r
lies
to the right of the line, and the tuple is said to have orientation zero
if the three points are collinear.
public static int orientation(double px, double py, double qx, double qy, double rx, double ry)
orientation(YPoint, YPoint, YPoint)
with double values as arguments.
public static boolean leftTurn(YPoint p, YPoint q, YPoint r)
orientation(p,q,r) > 0
public static boolean rightTurn(YPoint p, YPoint q, YPoint r)
orientation(p,q,r) < 0
public static boolean collinear(YPoint p, YPoint q, YPoint r)
true
iff the given points are collinear, that is, all
three points lie on a common line.
Same as orientation(p,q,r) == 0
public static int sideOfCircle(YPoint a, YPoint b, YPoint c, YPoint d)
d
lies left of the directed circle through
points a
, b
, and c
,
0 if a,b,c
and d
are cocircular, and -1 otherwise.
public static YList calcConvexHull(YList points)
O(n)*log(n), n := points.size()
points
- a list of YPoint
objects
YPoint
objects that constitute the convex hull of
the given points. The list contains points in counter clockwise order
around the hull. The first point is the one with the smallest
x
coordinate. If two such points exist then of these points
the one with the smallest y
coordinate is chosen as the first
one.public static double toRadians(double angdeg)
Math.toRadians(double)
.
public static double toDegrees(double angrad)
Math.toDegrees(double)
.
public static YPoint calcIntersection(YPoint p1, YVector d1, YPoint p2, YVector d2)
p1
- origin point of the first line.d1
- direction vector of the first line.p2
- origin point of the second line.d2
- direction vector of the second line.
null
if there is no intersection.public static YPoint calcIntersection(YPoint p1, YPoint p2, YPoint p3, YPoint p4)
p1
- one point on the first line.p2
- another point on the first line.p3
- one point on the second line.p4
- another point on the second line.
null
if there is no intersection.public static YPoint calcIntersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
x1
- x-coordinate of one point on the first line.y1
- y-coordinate of one point on the first line.x2
- x-coordinate of another point on the first line.y2
- y-coordinate of another point on the first line.x3
- x-coordinate of one point on the second line.y3
- y-coordinate of one point on the second line.x4
- x-coordinate of another point on the second line.y4
- y-coordinate of another point on the second line.
null
if there is no intersection.public static boolean linesIntersect(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
Line2D.linesIntersect(double, double, double, double, double, double, double, double)
.
public static YPoint projection(double pointX, double pointY, double lineX1, double lineY1, double lineX2, double lineY2)
p
onto the line
segment [l1, l2]
.
The resulting point is
p
onto the line through
l1
and l2
, iff the projection lies on the
line segment [l1, l2]
[l1, l2]
that is closest
to p
pointX
- the x coordinate of ppointY
- the y coordinate of plineX1
- the x coordinate of l1lineY1
- the y coordinate of l1lineX2
- the x coordinate of l2lineY2
- the y coordinate of l2public static double distanceToLineSegment(double pointX, double pointY, double lineX1, double lineY1, double lineX2, double lineY2)
p
to the line segment
[l1, l2]
.
pointX
- the x coordinate of ppointY
- the y coordinate of plineX1
- the x coordinate of l1lineY1
- the y coordinate of l1lineX2
- the x coordinate of l2lineY2
- the y coordinate of l2public static java.awt.geom.Rectangle2D calcUnion(java.awt.geom.Rectangle2D r1, java.awt.geom.Rectangle2D r2, java.awt.geom.Rectangle2D dest)
Rectangle2D
objects
and puts the result into the specified destination
Rectangle2D
object.
If one of the source rectangles has negative width or height,
it is excluded from the union.
If both source rectangles have negative width or height,
the destination rectangle will become a copy of r1
.
One of the source rectangles can also be the destination to avoid creating
a third Rectangle2D object, but in this case the original points of this
source rectangle will be overwritten by this method.
If the destination is null
, a new Rectangle2D
is created.
r1
- the first of a pair of Rectangle2D
objects to be combined with each otherr2
- the second of a pair of Rectangle2D
objects to be combined with each otherdest
- the Rectangle2D
that holds the
results of the union of r1
and
r2
public static java.awt.geom.Rectangle2D calcIntersection(java.awt.geom.Rectangle2D r1, java.awt.geom.Rectangle2D r2, java.awt.geom.Rectangle2D dest)
Rectangle2D
objects and puts the result into the specified destination
Rectangle2D
object.
If one or both of the source rectangles have negative width or height,
the resulting rectangle will be located at (0,0) with a width and height
of -1.
One of the source rectangles can also be the destination to avoid
creating a third Rectangle2D object, but in this case the original
points of this source rectangle will be overwritten by this method.
r1
- the first of a pair of Rectangle2D
objects to be intersected with each otherr2
- the second of a pair of Rectangle2D
objects to be intersected with each otherdest
- the Rectangle2D
that holds the
results of the intersection of r1
and
r2
public static java.awt.geom.Rectangle2D calcTransformedBounds(double x, double y, double width, double height, java.awt.geom.AffineTransform transform, java.awt.geom.Rectangle2D dest)
x
- the x coordinate of the rectangle to be transformedy
- the y coordinate of the rectangle to be transformedwidth
- the width of the rectangle to be transformedheight
- the height of the rectangle to be transformedtransform
- the AffineTransform
to be applieddest
- the Rectangle2D
that holds the
bounding box of the transformed input
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |