|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.geom.OrientedRectangle
public class OrientedRectangle
An oriented rectangle in 2D coordinate space with double precision
coordinates.
The rectangle's height
extends from its
anchor point
in the direction of its up
vector (
.
Its ux
, uy
)width
extends from its
in direction
anchor point
(-uy, ux)
(i.e. perpendicular to the up vector).
This means that an oriented rectangle with anchor point (0, 0)
width 100
, height 10
, and up vector
(0, -1)
is a paraxial rectangle with upper left corner
(0, -10)
and lower right corner (100, 0)
.
Constructor Summary | |
---|---|
OrientedRectangle(double anchorX,
double anchorY,
double width,
double height)
Creates a new instance using the provided values to initialize anchor and size. |
|
OrientedRectangle(double anchorX,
double anchorY,
double width,
double height,
double upX,
double upY)
Creates a new instance using the provided values to initialize anchor, size, and up vector. |
|
OrientedRectangle(OrientedRectangle rect)
Creates a new instance using the provided rectangle's values to initialize anchor, size, and up vector. |
|
OrientedRectangle(YPoint anchor,
YDimension size)
Creates a new instance using the provided values to initialize the anchor and size. |
|
OrientedRectangle(YPoint position,
YDimension size,
YVector upVector)
Creates a new instance using the provided values to initialize anchor, size, and up vector. |
|
OrientedRectangle(YRectangle rect)
Creates a new instance using the provided rectangle's values to initialize anchor and size. |
Method Summary | |
---|---|
void |
adoptValues(OrientedRectangle other)
Copies the actual values from the given OrientedRectangle to this instance. |
static YPoint[] |
calcPoints(OrientedRectangle rect)
Determines the four corner points of an oriented rectangle. |
static double[] |
calcPointsInDouble(OrientedRectangle rect)
Determines the coordinates of the four corners of an oriented rectangle. |
boolean |
contains(double x,
double y)
Determines whether or not the specified point lies inside this oriented rectangle. |
boolean |
contains(double x,
double y,
boolean closed)
Determines whether or not the specified point lies inside this oriented rectangle. |
static boolean |
contains(OrientedRectangle rect,
double x,
double y,
double eps)
Determines whether the given oriented rectangle contains the provided point, using an epsilon value. |
static boolean |
contains(OrientedRectangle r1,
OrientedRectangle r2,
double eps)
Determines whether the given rectangle r1 contains rectangle r2, using an epsilon value. |
static boolean |
contains(OrientedRectangle rect,
YPoint p,
double eps)
Determines whether the given oriented rectangle contains the provided point, using an epsilon value. |
boolean |
equals(java.lang.Object o)
|
YPoint |
getAnchor()
Returns the anchor of this oriented rectangle. |
double |
getAnchorX()
Returns the x-coordinate of this rectangle's anchor point. |
double |
getAnchorY()
Returns the y-coordinate of this rectangle's anchor point. |
double |
getAngle()
Returns the angle (measured in radians) of this rectangle. |
YRectangle |
getBoundingBox()
Calculates the paraxial bounding box of this oriented rectangle. |
YPoint |
getCenter()
Returns the current center of the oriented rectangle. |
double |
getHeight()
Returns the height of this rectangle. |
OrientedRectangle |
getMovedInstance(double dx,
double dy)
Creates a new OrientedRectangle instance whose anchor point
is moved by the specified distance values, but has the same width, height,
and up vector as this rectangle. |
OrientedRectangle |
getResizedInstance(double width,
double height)
Creates a new OrientedRectangle instance that has the
specified width and height, but has the same anchor point and up vector
as this rectangle. |
YDimension |
getSize()
Returns the size of this rectangle. |
double |
getUpX()
Returns the x-component of this rectangle's up vector. |
double |
getUpY()
Returns the y-component of this rectangle's up vector. |
double |
getWidth()
Returns the width of this rectangle. |
int |
hashCode()
|
static YPoint |
intersectionPoint(OrientedRectangle rect,
LineSegment line,
double eps)
Determines an intersection point of the specified oriented rectangle and the specified line segment. |
static boolean |
intersects(OrientedRectangle rect,
LineSegment line,
double eps)
Determines whether or not the specified oriented rectangle and the specified line segment intersect. |
static boolean |
intersects(OrientedRectangle orientedRectangle,
YRectangle rectangle,
double eps)
Determines whether a rectangle intersects an oriented rectangle, given an epsilon. |
boolean |
isEmpty()
Returns whether this instance has negative width or height. |
void |
moveBy(double dx,
double dy)
Moves this rectangle by applying the offset to the anchor. |
void |
setAnchor(double x,
double y)
Sets the anchor of this rectangle. |
void |
setAnchor(YPoint anchor)
Sets the anchor of this rectangle. |
void |
setAngle(double angle)
Sets the angle of this rectangle. |
void |
setCenter(double cx,
double cy)
Sets the anchor of the OrientedRectangle so that the center of the rectangle coincides with the given coordinate pair. |
void |
setCenter(YPoint center)
Sets the anchor of the OrientedRectangle so that the center of the rectangle coincides with the given point. |
void |
setSize(double width,
double height)
Sets the size of this rectangle. |
void |
setSize(YDimension size)
Sets the size of this rectangle. |
void |
setUpVector(double upX,
double upY)
Sets the components of the up vector to the new values. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public OrientedRectangle(YRectangle rect)
(0, -1)
.
rect
- the provided rectangle.public OrientedRectangle(OrientedRectangle rect)
rect
- the provided rectangle.public OrientedRectangle(YPoint anchor, YDimension size)
(0, -1)
.
anchor
- The provider for the dynamic anchor of this instance.size
- The provider for the dynamic size of this instance.public OrientedRectangle(YPoint position, YDimension size, YVector upVector)
position
- The provider for the dynamic anchor of this instance.size
- The provider for the dynamic size of this instance.upVector
- The up vector.public OrientedRectangle(double anchorX, double anchorY, double width, double height)
(0, -1)
.
anchorX
- The x coordinate of the anchor of the oriented rectangle.anchorY
- The y coordinate of the anchor of the oriented rectangle.width
- The width of the rectangle.height
- The height of the rectangle.public OrientedRectangle(double anchorX, double anchorY, double width, double height, double upX, double upY)
anchorX
- The x coordinate of the anchor of the oriented rectangle.anchorY
- The y coordinate of the anchor of the oriented rectangle.width
- The width of the rectangle.height
- The height of the rectangle.upX
- The x component of the up vector.upY
- The y component of the up vector.Method Detail |
---|
public boolean isEmpty()
public YPoint getAnchor()
public void setAnchor(YPoint anchor)
anchor
- the new anchor point of this rectangle.public void setAnchor(double x, double y)
x
- the new x-coordinate of the anchor point.y
- the new y-coordinate of the anchor point.public double getAnchorX()
public double getAnchorY()
public YDimension getSize()
public void setSize(YDimension size)
size
- the new size.public void setSize(double width, double height)
width
- the new width.height
- the new height.public double getWidth()
public double getHeight()
public void setUpVector(double upX, double upY)
upX
- The x component of the normalized up vector.upY
- The y component of the normalized up vector.public double getUpX()
public double getUpY()
public double getAngle()
(0, -1)
and the rectangle's up vector in counter clockwise
order.
An angle of 0 means the up vector points up in direction (0, -1)
.
public void setAngle(double angle)
(0, -1)
and the rectangle's up vector in counter clockwise
order.
An angle of 0 means the up vector points up in direction (0, -1)
.
angle
- the new angle in radians.public void moveBy(double dx, double dy)
dx
- The x offset to move the rectangle's position by.dy
- The y offset to move the rectangle's position by.public YPoint getCenter()
public void setCenter(YPoint center)
center
- the new center coordinates.public void setCenter(double cx, double cy)
cx
- The x coordinate of the center.cy
- The y coordinate of the center.public YRectangle getBoundingBox()
getBoundingBox
in interface PlaneObject
public boolean contains(double x, double y)
x
- the x-coordinate of the point to check.y
- the y-coordinate of the point to check.
true
iff the specified point lies inside;
false
otherwise.public boolean contains(double x, double y, boolean closed)
x
- the x-coordinate of the point to check.y
- the y-coordinate of the point to check.closed
- if true
, all points on the border of the
rectangle are considered to be contained.
true
iff the specified point lies inside;
false
otherwise.public static YPoint[] calcPoints(OrientedRectangle rect)
rect
- The rectangle to determine the bounds.
public static double[] calcPointsInDouble(OrientedRectangle rect)
rect
- The rectangle to determine the bounds.
public static boolean intersects(OrientedRectangle orientedRectangle, YRectangle rectangle, double eps)
orientedRectangle
- The oriented rectangle to test.rectangle
- The rectangle 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.
public static boolean contains(OrientedRectangle rect, YPoint p, double eps)
rect
- The rectangle.p
- The point to test.eps
- fuzziness range. A positive value allows for fuzzy hit testing.
If a point lies outside the given rectangle, but its distance is less than
or equal to that value, it will be considered a hit.
true
if the point lies inside the rectangle;
false
otherwise.public static boolean contains(OrientedRectangle rect, double x, double y, double eps)
rect
- The rectangle.x
- x-coordinate of the point to test.y
- y-coordinate of the point to test.eps
- fuzziness range. A positive value allows for fuzzy hit testing.
If a point lies outside the given rectangle, but its distance is less than
or equal to that value, it will be considered a hit.
true
if the point lies inside the rectangle;
false
otherwise.public static boolean contains(OrientedRectangle r1, OrientedRectangle r2, double eps)
r1
- The first rectangle.r2
- The second rectangle.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.
public static boolean intersects(OrientedRectangle rect, LineSegment line, double eps)
true
if the rectangle and the segment intersect and
false
otherwise.public static YPoint intersectionPoint(OrientedRectangle rect, LineSegment line, double eps)
null
if there is no intersection.
null
if the rectangle and the
segment do not intersect.public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public OrientedRectangle getMovedInstance(double dx, double dy)
OrientedRectangle
instance whose anchor point
is moved by the specified distance values, but has the same width, height,
and up vector as this rectangle.
dx
- the distance to move the anchor point in x-direction. A positive
value means "move" to the right, a negative value means "move" to the left.dy
- the distance to move the anchor point in y-direction. A positive
value means "move" downwards, a negative value means "move" upwards.
OrientedRectangle
instance whose anchor point
is moved by the specified distance values.public OrientedRectangle getResizedInstance(double width, double height)
OrientedRectangle
instance that has the
specified width and height, but has the same anchor point and up vector
as this rectangle.
width
- the width of the new rectangle.height
- the height of the new rectangle.
OrientedRectangle
instance that has the
specified width and height.public void adoptValues(OrientedRectangle other)
OrientedRectangle
to this instance.
other
- the OrientedRectangle
to retrieve the values from
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |