Class PolygonRegion

java.lang.Object
com.marswars.geometry.Region
com.marswars.geometry.PolygonRegion

public class PolygonRegion extends Region
This class models a region of the field. It is defined by its vertices Credit to frc-3061 for base code
  • Constructor Details

    • PolygonRegion

      public PolygonRegion(Translation2d[] points, String regionName)
      Create a Region2d, a polygon, from an array of Translation2d specifying vertices of a polygon. The polygon is created using the even-odd winding rule.
      Parameters:
      points - the array of Translation2d that define the vertices of the region.
      regionName - the name of the region that is used for logging
  • Method Details

    • constructRegion

      public void constructRegion()
      Description copied from class: Region
      Constructs the region and prepares it for logging.
      Specified by:
      constructRegion in class Region
    • logPoints

      public void logPoints()
      Log the bounding points of the region. These can be visualized using AdvantageScope to confirm that the regions are properly defined.
      Specified by:
      logPoints in class Region
    • contains

      public boolean contains(Pose2d other)
      Returns true if the region contains a given Pose2d.
      Specified by:
      contains in class Region
      Parameters:
      other - the given pose2d
      Returns:
      if the pose is inside the region
    • getName

      public String getName()
      Description copied from class: Region
      Returns the name of the region for logging purposes.
      Specified by:
      getName in class Region
    • getPoints

      public Translation2d[] getPoints()
      Get the points that define the polygon region
      Returns:
      the points of the polygon region