public final class RectD
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static RectD |
EMPTY
An empty read-only
RectD. |
PointD |
max
The greatest coordinates within the
RectD. |
PointD |
min
The smallest coordinates within the
RectD. |
| Constructor and Description |
|---|
RectD()
Creates a
RectD with all coordinates set to zero. |
RectD(double minX,
double minY,
double maxX,
double maxY)
Creates a
RectD with the specified Double coordinates. |
RectD(PointD min,
PointD max)
|
| Modifier and Type | Method and Description |
|---|---|
PointD |
center()
|
RectI |
circumscribe()
|
static RectD |
circumscribe(PointD... points)
|
boolean |
contains(double x,
double y)
Determines whether the
RectD contains the specified Double coordinates. |
boolean |
contains(PointD point)
|
boolean |
contains(RectD rect)
Determines whether the
RectD entirely contains the specified instance. |
boolean |
containsOpen(double x,
double y)
|
boolean |
containsOpen(PointD point)
|
PointD |
distanceVector(PointD q)
|
boolean |
equals(java.lang.Object obj)
Compares the specified
Object to this RectD instance. |
static boolean |
equals(RectD a,
RectD b,
double epsilon)
Compares two
RectD instances for equality, given the specified epsilon. |
static RectD[] |
fromDoubles(double... rects)
Converts the specified
Double array to a RectD array. |
int |
hashCode()
Returns a hash code for the
RectD. |
double |
height()
Gets the height the
RectD. |
LineD |
intersect(LineD line)
|
PointD[] |
intersect(PointD[] polygon)
|
RectD |
intersect(RectD rect)
Finds the intersection of the
RectD with the specified instance. |
boolean |
intersectsWith(LineD line)
|
boolean |
intersectsWith(RectD rect)
Determines whether the
RectD intersects with the specified instance. |
RectLocation |
locate(PointD q)
|
RectLocation |
locate(PointD q,
double epsilon)
|
RectD |
offset(double x,
double y)
Offsets the
RectD by the specified Double distances. |
RectD |
offset(PointD vector)
|
RectI |
round()
|
static double[] |
toDoubles(RectD... rects)
Converts the specified
RectD array to a Double array. |
RectI |
toRectI()
|
java.lang.String |
toString()
Returns a
String representation of the RectD. |
RectD |
union(RectD rect)
Finds the union of the
RectD with the specified instance. |
double |
width()
Gets the width the
RectD. |
public final PointD min
public final PointD max
public static final RectD EMPTY
public RectD()
public RectD(double minX,
double minY,
double maxX,
double maxY)
RectD with the specified Double coordinates.minX - the smallest x-coordinate within the RectDminY - the smallest y-coordinate within the RectDmaxX - the greatest x-coordinate within the RectDmaxY - the greatest y-coordinate within the RectDjava.lang.IllegalArgumentException - if maxX is less than minX,
or maxY is less than minYpublic PointD center()
public RectI circumscribe()
RectI around the RectD.
The RectI extends from the Fortran.floor(double) of
min to the Fortran.ceiling(double) of max.public boolean contains(double x,
double y)
RectD contains the specified Double coordinates.public boolean contains(PointD point)
public boolean containsOpen(double x,
double y)
public boolean containsOpen(PointD point)
public boolean contains(RectD rect)
RectD entirely contains the specified instance.public static boolean equals(RectD a, RectD b, double epsilon)
RectD instances for equality, given the specified epsilon.a - the first RectD to compareb - the second RectD to compareepsilon - the maximum absolute difference where the corresponding coordinates
of a and b are considered equaltrue if the absolute difference between all corresponding coordinates
of a and b is no greater than epsilon, else falsejava.lang.IllegalArgumentException - if epsilon is less than zerojava.lang.NullPointerException - if a or b is nullpublic static RectD[] fromDoubles(double... rects)
Double array to a RectD array.
The returned array has a quarter as many elements as the specified
rects and retains the same coordinate sequence.rects - an array containing the coordinates min.x, min.y, max.x, max.y of
RectD instances, stored in successive index positions per RectDRectD array created from rectsjava.lang.IllegalArgumentException - if the length of rects is not divisible by four,
or if any max coordinate is less than the corresponding min coordinatejava.lang.NullPointerException - if rects is nullpublic double height()
RectD. Never negative but may be zero.public PointD[] intersect(PointD[] polygon)
RectD with the specified arbitrary PointD polygon.
Performs the Sutherland–Hodgman polygon clipping algorithm, optimized for an axis-aligned
RectD as the clipping polygon. At intersection points, the border coordinates of the
RectD are copied rather than computed, allowing exact floating-point comparisons.
The specified polygon and the returned intersection are implicitly assumed to be closed,
with an edge connecting first and last vertex. Therefore, all vertices should be different.
Unless the specified polygon is convex, the returned intersection may represent
multiple polygons, connected across the borders of RectD.
polygon - an array of PointD coordinates describing the vertices
of the polygon to intersect with the RectDpolygon with the RectD,
if an intersection was found, else nulljava.lang.NullPointerException - if polygon is null or empty,
or contains any null elementspublic RectD intersect(RectD rect)
RectD with the specified instance.public boolean intersectsWith(LineD line)
RectD intersects with the specified LineD.
Performs the same Liang-Barsky line clipping algorithm as intersect(LineD)
but without computing the intersecting line segment.public boolean intersectsWith(RectD rect)
RectD intersects with the specified instance.rect - the RectD to examinetrue if rect shares any coordinates with this instance,
else falsejava.lang.NullPointerException - if rect is nullpublic RectLocation locate(PointD q)
PointD relative to the RectD,
using exact coordinate comparisons.q - the PointD coordinates to examineRectLocation indicating the location of q
relative to the RectD in each dimensionjava.lang.NullPointerException - if q is nullpublic RectLocation locate(PointD q, double epsilon)
PointD relative to the RectD,
given the specified epsilon for coordinate comparisons.q - the PointD coordinates to examineepsilon - the maximum absolute difference at which coordinates should be considered equalRectLocation indicating the location of q
relative to the RectD in each dimensionjava.lang.IllegalArgumentException - if epsilon is less than zerojava.lang.NullPointerException - if q is nullpublic RectI round()
RectD to a RectI by rounding coordinates to the
nearest Integer values. Uses PointD.round() for rounding.public static double[] toDoubles(RectD... rects)
RectD array to a Double array.
The returned array has four times as many elements as the specified
rects and retains the same coordinate sequence.public RectI toRectI()
public double width()
RectD. Never negative but may be zero.public boolean equals(java.lang.Object obj)
Object to this RectD instance.public int hashCode()
RectD.hashCode in class java.lang.ObjectInteger hash code for the RectD