Class Polygon

java.lang.Object
org.chsrobotics.lib.math.geometry.Polygon

public class Polygon extends Object
Represents a closed shape with a definite number of sides in 2-dimensional space.
  • Constructor Details

    • Polygon

      public Polygon(Vector2D... vertices)
      Constructs a Polygon.
      Parameters:
      vertices - An ordered set of vectors with endpoints representing the vertices of the polygon. Lines will be connected between these vertices in accordance with the order of them in this constructor. The last edge is connected automatically.
  • Method Details

    • pointLiesWithin

      public boolean pointLiesWithin(Vector2D point)
      Returns whether a point is inside (not on the edge of) a polygon.
      Parameters:
      point - A vector with endpoint representing the point.
      Returns:
      Whether the point lies within the bounds of the polygon.