|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object hermes.hshape.HShape hermes.hshape.HRectangle
public class HRectangle
Represents an axis-aligned bounding rectangle.
Field Summary | |
---|---|
static int |
mode
|
Fields inherited from class hermes.hshape.HShape |
---|
_position |
Constructor Summary | |
---|---|
HRectangle(float a,
float b,
float c,
float d)
Creates a new Rectangle based on current rectMode. |
|
HRectangle(PVector ab,
float c,
float d)
Creates a new Rectangle based on current rectMode. |
|
HRectangle(PVector ab,
PVector cd)
Creates a new Rectangle based on current rectMode. |
|
HRectangle(PVector position,
PVector min,
PVector max)
Creates a new Rectangle. |
Method Summary | |
---|---|
boolean |
contains(float x,
float y)
|
boolean |
contains(HRectangle other)
Whether this rectangle completely encloses another (no part of other protrudes from this). |
boolean |
contains(PVector point)
Whether the Shape contains the given point coordinates (boundary is inclusive). |
void |
draw()
Shortcut method for drawing the shape on screen |
PVector |
getAbsMax()
|
PVector |
getAbsMin()
|
HRectangle |
getBoundingBox()
Finds the smallest Rectangle that encloses the shape. |
PVector |
getCenter()
|
float |
getHeight()
|
PVector |
getMax()
|
PVector |
getMin()
|
float |
getWidth()
|
PVector |
projectionVector(HCircle other)
|
PVector |
projectionVector(HPolygon other)
|
PVector |
projectionVector(HRectangle other)
|
PVector |
projectionVector(HShape other)
Finds the projection vector for a collision with another shape. |
void |
scale(float xScale,
float yScale)
Scales the rectangle's width and height about its position. |
java.lang.String |
toString()
|
Methods inherited from class hermes.hshape.HShape |
---|
collide, getPosition |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static int mode
Constructor Detail |
---|
public HRectangle(float a, float b, float c, float d)
Default - a and b define the upper left corner, and c and d are width and height, see Processing reference on rectMode() for details on other modes.
a
- b
- c
- d
- public HRectangle(PVector ab, float c, float d)
Default - ab.x and ab.y define the upper left corner, and c and d are width and height, see Processing reference on rectMode() for details on other modes.
ab
- c
- d
- public HRectangle(PVector ab, PVector cd)
Default - ab.x and ab.y define the upper left corner, and cd.x and cd.y are width and height see Processing reference on rectMode() for details on other modes
ab
- cd
- public HRectangle(PVector position, PVector min, PVector max)
Directly assigns fields, does not link with rectMode.
position
- - position of rectanglemin
- - location of top left corner in relation to positionmax
- - location of bottom right corner in relation to positionMethod Detail |
---|
public PVector getMin()
public PVector getMax()
public PVector getAbsMin()
public PVector getAbsMax()
public float getWidth()
public float getHeight()
public PVector getCenter()
public void scale(float xScale, float yScale)
xScale
- the x-axis scale factoryScale
- the y-axis scale factorpublic PVector projectionVector(HShape other)
HShape
The projection vector is the vector by which one body could be displaced such that it no longer intersects the other body, by the shortest possible distance.
Each shape must contain methods for collision with all other types of HShapes. If you create your own type of shape, you will have to modify HShape (as well as its subclasses) to contain methods colliding it with the new type.
projectionVector
in class HShape
other
- the shape to collide with
public PVector projectionVector(HCircle other)
projectionVector
in class HShape
public PVector projectionVector(HPolygon other)
projectionVector
in class HShape
public PVector projectionVector(HRectangle other)
projectionVector
in class HShape
public HRectangle getBoundingBox()
HShape
getBoundingBox
in class HShape
public boolean contains(HRectangle other)
contains
in class HShape
other
- the other rectangle
public boolean contains(float x, float y)
contains
in class HShape
x
- the x coordinatey
- the y coordinate
public boolean contains(PVector point)
HShape
contains
in class HShape
point
- the point vector
public void draw()
HShape
draw
in class HShape
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |