## Class Block

- java.lang.Object
- - Block

-     public class Block
      extends java.lang.Object

  An instance is a 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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected double` | `halfwidth`
    `protected javax.vecmath.Point2d` | `position` Body-frame position --- needed for contact processing.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `contains(Vector2D p)` Return true iff this block contains point p
    `void` | `display(java.awt.Graphics g, double scale, Vector2D d, boolean clicked, boolean overlaps)` Draw this block using g, which must be a Graphics2D object.
    `BoundingBox` | `getBBox()` Return the bounding box of this block.
    `int` | `getCol()` Return the Image column.
    `double` | `getColorMass()` Return the color-based mass on [0,1] with white having 0 mass and darker colors approaching 1 (feel free to modify).
    `double` | `getHalfwidth()` Return the halfwidth of block.
    `javax.vecmath.Point2d` | `getPosition()` Return the center position of this Block (in body coordinates).
    `int` | `getRow()` Return the Image row.
    `static boolean` | `overlaps(Block b, Vector2D u, Block c, Vector2D v)` Return true iff block b displaced by u overlaps block c displaced by v.
    `java.lang.String` | `toString()` Return a representation of this Block.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### halfwidth

          protected double halfwidth

    - #### position

          protected javax.vecmath.Point2d position

      Body-frame position --- needed for contact processing.

  - ### Method Detail

    - #### overlaps

          public static boolean overlaps(Block b,
                         Vector2D u,
                         Block c,
                         Vector2D v)

      Return true iff block b displaced by u overlaps block c displaced by v.

    - #### contains

          public boolean contains(Vector2D p)

      Return true iff this block contains point p

    - #### display

          public void display(java.awt.Graphics g,
                     double scale,
                     Vector2D d,
                     boolean clicked,
                     boolean overlaps)

      Draw this block using g, which must be a Graphics2D object. It is scaled using scale and is displaced using d. clicked indicates whether it has been clicked on, in which case it appears differently. overlaps indicates whether it overlaps with some other shape.
      Parameters:
        `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.

    - #### getBBox

          public BoundingBox getBBox()

      Return the bounding box of this block.

    - #### getColorMass

          public double getColorMass()

      Return the color-based mass on [0,1] with white having 0 mass and darker colors approaching 1 (feel free to modify).

    - #### getHalfwidth

          public double getHalfwidth()

      Return the halfwidth of block. Note that the block radius is sqrt(2)*h.

    - #### getPosition

          public javax.vecmath.Point2d getPosition()

      Return the center position of this Block (in body coordinates).

    - #### toString

          public java.lang.String toString()

      Return a representation of this Block.
      Overrides:
        `toString` in class `java.lang.Object`

    - #### getCol

          public int getCol()

      Return the Image column.

    - #### getRow

          public int getRow()

      Return the Image row.