Package toxi.geom

Interface Shape2D

All Known Implementing Classes:
Circle, Ellipse, PointQuadtree, Polygon2D, Rect, Triangle2D

public interface Shape2D
Interface description of common operations supported by 2D geometry types.
  • Method Details

    • containsPoint

      boolean containsPoint(ReadonlyVec2D p)
      Checks if the point is within the given shape.
      Returns:
      true, if inside
    • getArea

      float getArea()
      Computes the area of the shape.
      Returns:
      area
    • getBoundingCircle

      Circle getBoundingCircle()
      Computes the bounding circle of the shape.
      Returns:
      circle
    • getBounds

      Rect getBounds()
      Returns the shape's axis-aligned bounding rect.
      Returns:
      bounding rect
    • getCircumference

      float getCircumference()
      Computes the shape's circumference.
      Returns:
      circumference
    • getEdges

      List<Line2D> getEdges()
      Returns a list of the shape's perimeter edges.
      Returns:
      list of Line2D elements
    • getRandomPoint

      Vec2D getRandomPoint()
      Computes a random point within the shape's perimeter.
      Returns:
      Vec2D
    • toPolygon2D

      Polygon2D toPolygon2D()
      Converts the shape into a Polygon2D instance (possibly via a default resolution, e.g. for circles/ellipses)
      Returns:
      shape as polygon