Class CompositeBoundary2D

java.lang.Object
org.episteme.core.mathematics.geometry.boundaries.CompositeBoundary2D
All Implemented Interfaces:
Serializable, Boundary<Point2D>, Boundary2D

public class CompositeBoundary2D extends Object implements Boundary2D
A composite 2D boundary supporting exclaves and enclaves.

This class represents complex territorial shapes:

  • Exclaves - Multiple disjoint regions that belong to the same territory (e.g., Alaska as an exclave of the contiguous USA)
  • Enclaves - Holes within a region that don't belong to it (e.g., Vatican City as an enclave within Rome)

A point is considered "inside" the composite boundary if it is inside at least one inclusion region AND not inside any exclusion region.

Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
See Also:
  • Constructor Details

    • CompositeBoundary2D

      public CompositeBoundary2D()
      Creates an empty composite boundary.
    • CompositeBoundary2D

      public CompositeBoundary2D(Boundary2D mainBoundary)
      Creates a composite boundary with a single inclusion.
      Parameters:
      mainBoundary - the main boundary
    • CompositeBoundary2D

      public CompositeBoundary2D(List<Boundary2D> inclusions, List<Boundary2D> exclusions)
      Creates a composite from inclusions and exclusions.
      Parameters:
      inclusions - the inclusion regions (exclaves)
      exclusions - the exclusion regions (enclaves/holes)
  • Method Details

    • addInclusion

      public void addInclusion(Boundary2D region)
      Adds an inclusion region (exclave).
      Parameters:
      region - the region to include
    • addExclusion

      public void addExclusion(Boundary2D region)
      Adds an exclusion region (enclave/hole).
      Parameters:
      region - the region to exclude
    • getInclusions

      public List<Boundary2D> getInclusions()
      Returns the inclusion regions (exclaves).
      Returns:
      unmodifiable list of inclusions
    • getExclusions

      public List<Boundary2D> getExclusions()
      Returns the exclusion regions (enclaves/holes).
      Returns:
      unmodifiable list of exclusions
    • getExclaveCount

      public int getExclaveCount()
      Returns the number of disjoint regions (exclaves).
      Returns:
      exclave count
    • getEnclaveCount

      public int getEnclaveCount()
      Returns the number of holes (enclaves).
      Returns:
      enclave count
    • contains

      public boolean contains(Point2D point)
      Checks if a point is inside the composite boundary.

      A point is IN if:

      1. It is inside at least one inclusion (exclave)
      2. AND it is not inside any exclusion (enclave)
      Specified by:
      contains in interface Boundary<Point2D>
      Parameters:
      point - the point to test
      Returns:
      true if inside
    • getContainmentStatus

      public CompositeBoundary2D.ContainmentResult getContainmentStatus(Point2D point)
      Determines the containment status of a point.
      Parameters:
      point - the point to check
      Returns:
      the containment result
    • getVertices

      public List<Point2D> getVertices()
      Description copied from interface: Boundary2D
      Returns the vertices of this boundary in order.
      Specified by:
      getVertices in interface Boundary2D
      Returns:
      list of vertices
    • getVertexCount

      public int getVertexCount()
      Description copied from interface: Boundary2D
      Returns the number of vertices.
      Specified by:
      getVertexCount in interface Boundary2D
      Returns:
      vertex count
    • getVertex

      public Point2D getVertex(int index)
      Description copied from interface: Boundary2D
      Returns a specific vertex.
      Specified by:
      getVertex in interface Boundary2D
      Parameters:
      index - the vertex index
      Returns:
      the vertex
    • getArea

      public Real getArea()
      Description copied from interface: Boundary2D
      Returns the area of this 2D boundary.
      Specified by:
      getArea in interface Boundary2D
      Returns:
      the area
    • getPerimeter

      public Real getPerimeter()
      Description copied from interface: Boundary2D
      Returns the perimeter of this 2D boundary.
      Specified by:
      getPerimeter in interface Boundary2D
      Returns:
      the perimeter
    • isConvex

      public boolean isConvex()
      Description copied from interface: Boundary2D
      Checks if this boundary is convex.
      Specified by:
      isConvex in interface Boundary2D
      Returns:
      true if convex
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Boundary
      Checks if this boundary is empty.
      Specified by:
      isEmpty in interface Boundary<Point2D>
      Returns:
      true if the boundary has no extent
    • getCentroid

      public Point2D getCentroid()
      Description copied from interface: Boundary
      Returns the centroid of this boundary.
      Specified by:
      getCentroid in interface Boundary<Point2D>
      Returns:
      the geometric center
    • getBoundingBox

      public BoundingBox<Point2D> getBoundingBox()
      Description copied from interface: Boundary
      Returns the bounding box of this boundary.
      Specified by:
      getBoundingBox in interface Boundary<Point2D>
      Returns:
      an axis-aligned bounding box
    • intersects

      public boolean intersects(Boundary<Point2D> other)
      Description copied from interface: Boundary
      Checks if this boundary intersects with another.
      Specified by:
      intersects in interface Boundary<Point2D>
      Parameters:
      other - the other boundary
      Returns:
      true if boundaries intersect
    • union

      public Boundary<Point2D> union(Boundary<Point2D> other)
      Description copied from interface: Boundary
      Computes the union of this boundary with another.
      Specified by:
      union in interface Boundary<Point2D>
      Parameters:
      other - the other boundary
      Returns:
      the union boundary
    • intersection

      public Boundary<Point2D> intersection(Boundary<Point2D> other)
      Description copied from interface: Boundary
      Computes the intersection of this boundary with another.
      Specified by:
      intersection in interface Boundary<Point2D>
      Parameters:
      other - the other boundary
      Returns:
      the intersection boundary
    • convexHull

      public Boundary<Point2D> convexHull()
      Description copied from interface: Boundary
      Computes the convex hull of this boundary.
      Specified by:
      convexHull in interface Boundary<Point2D>
      Returns:
      the convex hull
    • translate

      public Boundary<Point2D> translate(Point2D offset)
      Description copied from interface: Boundary
      Creates a copy of this boundary translated by a vector.
      Specified by:
      translate in interface Boundary<Point2D>
      Parameters:
      offset - the translation vector (as point)
      Returns:
      translated boundary
    • scale

      public Boundary<Point2D> scale(Real factor)
      Description copied from interface: Boundary
      Creates a scaled copy of this boundary.
      Specified by:
      scale in interface Boundary<Point2D>
      Parameters:
      factor - the scaling factor
      Returns:
      scaled boundary
    • rotate

      public Boundary2D rotate(Real angleRadians)
      Description copied from interface: Boundary2D
      Rotates the boundary around the centroid.
      Specified by:
      rotate in interface Boundary2D
      Parameters:
      angleRadians - rotation angle in radians
      Returns:
      rotated boundary
    • rotateAround

      public Boundary2D rotateAround(Real angleRadians, Point2D pivot)
      Description copied from interface: Boundary2D
      Rotates around a specific pivot point.
      Specified by:
      rotateAround in interface Boundary2D
      Parameters:
      angleRadians - rotation angle
      pivot - the pivot point
      Returns:
      rotated boundary
    • extrude

      public Boundary3D extrude(Real height)
      Description copied from interface: Boundary2D
      Creates an extruded 3D boundary from this 2D boundary.
      Specified by:
      extrude in interface Boundary2D
      Parameters:
      height - the extrusion height
      Returns:
      a 3D boundary
    • toString

      public String toString()
      Overrides:
      toString in class Object