public interface IOrientedRectangle extends ISize
The rectangle described by this interface has its lower left corner at the anchor as described by the AnchorX
and AnchorY
properties and is oriented in space so that its upper left corner lies in direction of
the (UpX
,UpY
) vector. The size of the instance does not describe the bounds of the
instance but the lengths of the sides of the rectangle. An IRectangle
would thus be an oriented rectangle, whose
anchor is the lower left corner of the rectangle, whose size is the same as that of the rectangle and whose up vector is
(0,-1)
. This interface provides read access to the features of the oriented rectangle only, however this
does not mean that an instance that implements IOrientedRectangle
will always return the same values for its
properties. Often times the instance provides a dynamic read access to the current state of a rectangle. It depends on
the context whether it is allowed to or even necessary to copy the state of the properties or whether the reference to
the instance should always be used to query the values.
ISize
,
IRectangle
,
OrientedRectangle
,
MutableRectangle
Modifier and Type | Field and Description |
---|---|
static IOrientedRectangle |
EMPTY
An immutable empty
IOrientedRectangle with width and height of -1 . |
Modifier and Type | Method and Description |
---|---|
default boolean |
contains(PointD point,
double eps)
Determines whether the given oriented rectangle contains the provided point, using an epsilon value.
|
default Matrix2D |
createTransform()
Creates a transformation matrix that can be used to transform points that are in the local coordinate system of the
oriented rectangle if the top-left corner is the origin.
|
default PointD |
getAnchorLocation()
Gets the anchor location of the oriented rectangle as a
PointD struct. |
double |
getAnchorX()
Returns the x coordinate of the anchor of the oriented rectangle.
|
double |
getAnchorY()
Returns the y coordinate of the anchor of the oriented rectangle.
|
default RectD |
getBounds()
Determines the bounds of an oriented rectangle.
|
default PointD |
getCenter()
Gets the current center of the oriented rectangle as a
PointD struct. |
default IPoint |
getDynamicCenter()
Create a dynamic
IPoint implementation that always points to the center of the given oriented rectangle. |
default PointD |
getTopLeftLocation()
Gets the location of the top left corner of the oriented rectangle as a
PointD . |
default PointD |
getUp()
Gets the up vector of the oriented rectangle as a
PointD struct. |
double |
getUpX()
Returns the x value of the up vector.
|
double |
getUpY()
Returns the y value of the up vector.
|
default boolean |
hits(PointD location,
double eps)
Determines whether the oriented rectangle contains the provided point, using an epsilon value.
|
default SizeD |
toSizeD()
Gets the size of the oriented rectangle.
|
static final IOrientedRectangle EMPTY
IOrientedRectangle
with width and height of -1
.default boolean contains(PointD point, double eps)
point
- The coordinates of the point to test.eps
- A positive value allows for fuzzy hit testing. If the point lies outside the given object but it's distance is less than
or equal to that value, it will be considered a hit.true
iff the point lies inside the rectangle.default Matrix2D createTransform()
default PointD getAnchorLocation()
PointD
struct.double getAnchorX()
The anchor is the lower left corner of the oriented rectangle if the up vector is (0,-1)
.
double getAnchorY()
The anchor is the lower left corner of the oriented rectangle if the up vector is (0,-1)
.
default RectD getBounds()
Bounding rectangles are parallel to the coordinate axes.
default PointD getCenter()
PointD
struct.default IPoint getDynamicCenter()
IPoint
implementation that always points to the center of the given oriented rectangle.default PointD getTopLeftLocation()
PointD
.
The top left corner is the one the up vector points to.
default PointD getUp()
PointD
struct.double getUpX()
The up vector points from the lower left corner to the upper left corner and is always normalized, i.e. it's length is always 1.
double getUpY()
The up vector points from the lower left corner to the upper left corner and is always normalized, i.e. it's length is always 1.
default boolean hits(PointD location, double eps)
location
- The coordinates of the point to test.eps
- A positive value allows for fuzzy hit testing. If the point lies outside the given object but it's distance is less than
or equal to that value, it will be considered a hit.true
iff the point lies inside the rectangle.