All Implemented Interfaces:
BoundarySource<LineConvexSubset>, HyperplaneBoundedRegion<Vector2D>, Splittable<Vector2D,HyperplaneBoundedRegion<Vector2D>>, Region<Vector2D>, Sized, BoundarySource2D, Linecastable2D

public final class Parallelogram extends ConvexArea
Class representing parallelograms, i.e. quadrilaterals with two pairs of parallel sides.
See Also:
  • Field Details

    • UNIT_SQUARE_VERTICES

      private static final List<Vector2D> UNIT_SQUARE_VERTICES
      Vertices defining a square with sides of length 1 centered on the origin.
  • Constructor Details

    • Parallelogram

      private Parallelogram(List<LineConvexSubset> boundaries)
      Simple constructor. Callers are responsible for ensuring that the given path represents a parallelogram. No validation is performed.
      Parameters:
      boundaries - the boundaries of the parallelogram; this must be a list with 4 elements
  • Method Details

    • unitSquare

      public static Parallelogram unitSquare(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
      Return a new instance representing a unit square centered on the origin. The vertices of this square are:
       [
            (-0.5 -0.5),
            (0.5, -0.5),
            (0.5, 0.5),
            (-0.5, 0.5)
       ]
       
      Parameters:
      precision - precision context used to construct boundaries
      Returns:
      a new instance representing a unit square centered on the origin
    • axisAligned

      public static Parallelogram axisAligned(Vector2D a, Vector2D b, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
      Return a new instance representing an axis-aligned rectangle. The points a and b are taken to represent opposite corner points in the rectangle and may be specified in any order.
      Parameters:
      a - first corner point in the rectangle (opposite of b)
      b - second corner point in the rectangle (opposite of a)
      precision - precision context used to construct boundaries
      Returns:
      a new instance representing an axis-aligned rectangle
      Throws:
      IllegalArgumentException - if the length of any side of the parallelogram is zero, as determined by the given precision context
    • fromTransformedUnitSquare

      public static Parallelogram fromTransformedUnitSquare(Transform<Vector2D> transform, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
      Create a new instance by transforming a unit square centered at the origin. The vertices of this input square are:
       [
            (-0.5 -0.5),
            (0.5, -0.5),
            (0.5, 0.5),
            (-0.5, 0.5)
       ]
       
      Parameters:
      transform - the transform to apply to the unit square
      precision - precision context used to construct boundaries
      Returns:
      a new instance constructed by transforming the unit square
      Throws:
      IllegalArgumentException - if the length of any side of the parallelogram is zero, as determined by the given precision context
    • builder

      public static Parallelogram.Builder builder(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
      Return a new Parallelogram.Builder instance to use for constructing parallelograms.
      Parameters:
      precision - precision context used to create boundaries
      Returns:
      a new Parallelogram.Builder instance