|
||||||||||
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(ReadonlyVec2D topLeft,
ReadonlyVec2D bottomRight)
Constructs a new rectangle defined by its top left and bottom right points. |
Method Summary | |
---|---|
boolean |
containsPoint(ReadonlyVec2D p)
Checks if the given point is within the rectangle's bounds. |
Rect |
copy()
Creates a copy of this rectangle |
static Rect |
fromCenterExtent(ReadonlyVec2D center,
Vec2D extent)
Factory method, constructs a new rectangle from a center point and extent vector. |
float |
getArea()
Computes the area of the shape. |
float |
getAspect()
Computes the aspect ratio of the rect as width over height. |
float |
getBottom()
|
Vec2D |
getBottomRight()
|
Vec2D |
getCentroid()
Returns the centroid of the rectangle. |
float |
getCircumference()
Computes the shape's circumference. |
Vec2D |
getDimensions()
Returns a vector containing the width and height of the rectangle. |
Line2D |
getEdge(int id)
Returns one of the rectangles edges as Line2D . |
float |
getLeft()
|
float |
getRight()
|
float |
getTop()
|
Vec2D |
getTopLeft()
|
ReadonlyVec2D |
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 |
scale(float s)
|
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)
|
Polygon2D |
toPolygon2D()
Creates a Polygon2D instance of the rect. |
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(ReadonlyVec2D topLeft, ReadonlyVec2D bottomRight)
topLeft
- bottomRight
- Method Detail |
---|
public static final Rect fromCenterExtent(ReadonlyVec2D center, Vec2D extent)
center
- extent
-
public boolean containsPoint(ReadonlyVec2D p)
containsPoint
in interface Shape2D
p
- point to check
public Rect copy()
public final float getArea()
Shape2D
getArea
in interface Shape2D
public final float getAspect()
public float getBottom()
public final Vec2D getBottomRight()
public final Vec2D getCentroid()
public final float getCircumference()
Shape2D
getCircumference
in interface Shape2D
public final Vec2D getDimensions()
public Line2D getEdge(int id)
Line2D
. The edge IDs are:
id
- edge ID
public float getLeft()
public float getRight()
public float getTop()
public final Vec2D getTopLeft()
public ReadonlyVec2D intersectsRay(Ray2D ray, float minDist, float maxDist)
ray
- intersection rayminDist
- minimum distancemaxDist
- max distance
public boolean intersectsRect(Rect r)
r
- another rect
public Rect scale(float s)
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 Polygon2D toPolygon2D()
Polygon2D
instance of the rect.
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 |