|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcs2110.collision.Block
public class Block
Basic square block/pixel primitive for representing image-based rigid objects and resolving contacts. Each Block is wrapped by a disk and used for contact generation.
Field Summary | |
---|---|
(package private) int |
col
Image column index. |
(package private) Color |
color
Pixel color. |
(package private) static Random |
gen
|
(package private) double |
halfwidth
Halfwidth of block (Note: the block radius is sqrt(2)*h). |
(package private) javax.vecmath.Point2d |
position
Body-frame position --- needed for contact processing. |
(package private) int |
row
Image row index. |
Constructor Summary | |
---|---|
Block(int i,
int j,
Color color,
javax.vecmath.Point2d center,
double halfwidth)
Constructs a Block. |
Method Summary | |
---|---|
boolean |
contains(cs2110.collision.Vector2D p)
|
void |
display(Graphics g,
double scale,
cs2110.collision.Vector2D d,
boolean clicked,
boolean overlaps)
|
cs2110.collision.BoundingBox |
getBBox()
|
(package private) int |
getCol()
Image column. |
double |
getColorMass()
Color-based mass on [0,1] with white having zero mass, and darker colors approaching one (feel free to modify). |
double |
getHalfwidth()
Halfwidth of block. |
javax.vecmath.Point2d |
getPosition()
Center position of Block (in body coordinates). |
(package private) int |
getRow()
Image row. |
static boolean |
overlaps(Block a,
cs2110.collision.Vector2D u,
Block b,
cs2110.collision.Vector2D v)
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
static Random gen
int row
int col
Color color
double halfwidth
javax.vecmath.Point2d position
Constructor Detail |
---|
Block(int i, int j, Color color, javax.vecmath.Point2d center, double halfwidth)
Method Detail |
---|
public static boolean overlaps(Block a, cs2110.collision.Vector2D u, Block b, cs2110.collision.Vector2D v)
a
- A block.u
- Displacement vector for block a.b
- A block.v
- Displacement vector for block b.
public boolean contains(cs2110.collision.Vector2D p)
p
- A point.
public void display(Graphics g, double scale, cs2110.collision.Vector2D d, boolean clicked, boolean overlaps)
g
- A Graphics2D object.scale
- Scale factor from image coordinate system to canvas coordinate
system.d
- Displacement vector for the block.clicked
- Indicates whether the shape containing the block has been
clicked on.overlaps
- Indicates whether the shape containing the block overlaps
another shape.public cs2110.collision.BoundingBox getBBox()
public double getColorMass()
public double getHalfwidth()
public javax.vecmath.Point2d getPosition()
public String toString()
toString
in class Object
int getCol()
int getRow()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |