|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttoxi.geom.Rect
public class Rect
Field Summary | |
---|---|
float |
height
|
float |
width
|
float |
x
|
float |
y
|
Constructor Summary | |
---|---|
Rect()
Constructs an empty rectangle at point 0,0 with no dimensions. |
|
Rect(float x,
float y,
float width,
float height)
Constructs a new rectangle using a point and dimensions |
|
Rect(Vec2D topLeft,
Vec2D bottomRight)
Constructs a new rectangle defined by its top left and bottom right points. |
Method Summary | |
---|---|
boolean |
containsPoint(Vec2D p)
Checks if the given point is within the rectangle's bounds. |
Rect |
copy()
Creates a copy of this rectangle |
static Rect |
fromCenterExtent(Vec2D center,
Vec2D extent)
Factory method, constructs a new rectangle from a center point and extent vector. |
Vec2D |
getBottomRight()
|
Vec2D |
getCentroid()
Returns the centroid of the rectangle. |
Vec2D |
getDimensions()
Returns a vector containing the width and height of the rectangle. |
Vec2D |
getTopLeft()
|
Vec2D |
intersectsRay(Ray2D ray,
float minDist,
float maxDist)
Checks if the rectangle intersects with the given ray and if so computes the first intersection point. |
boolean |
intersectsRect(Rect r)
Checks if this rectangle intersects/overlaps the given one. |
Rect |
merge(Rect r)
Deprecated. use union(Rect) instead. |
Rect |
set(float x,
float y,
float w,
float h)
Sets new bounds for this rectangle. |
Rect |
set(Rect r)
|
Rect |
setDimension(Vec2D dim)
|
Rect |
setPosition(Vec2D pos)
|
java.lang.String |
toString()
|
Rect |
union(Rect r)
Updates the bounds of this rectangle by forming an union with the given rect. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public float x
public float y
public float width
public float height
Constructor Detail |
---|
public Rect()
public Rect(float x, float y, float width, float height)
x
- x of top lefty
- y of top leftwidth
- height
- public Rect(Vec2D topLeft, Vec2D bottomRight)
topLeft
- bottomRight
- Method Detail |
---|
public static final Rect fromCenterExtent(Vec2D center, Vec2D extent)
center
- extent
-
public final boolean containsPoint(Vec2D p)
p
- point to check
public Rect copy()
public final Vec2D getBottomRight()
public final Vec2D getCentroid()
public final Vec2D getDimensions()
public final Vec2D getTopLeft()
public Vec2D intersectsRay(Ray2D ray, float minDist, float maxDist)
ray
- intersection rayminDist
- minimum distancemaxDist
- max distance
public boolean intersectsRect(Rect r)
r
- another rect
@Deprecated public final Rect merge(Rect r)
union(Rect)
instead.
r
-
public final Rect set(float x, float y, float w, float h)
x
- x of top lefty
- y of top rightw
- widthh
- height
public final Rect set(Rect r)
public final Rect setDimension(Vec2D dim)
public final Rect setPosition(Vec2D pos)
public java.lang.String toString()
toString
in class java.lang.Object
public final Rect union(Rect r)
r
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |