Class Parallelogram
- java.lang.Object
-
- org.apache.commons.geometry.core.partitioning.AbstractConvexHyperplaneBoundedRegion<Vector2D,LineConvexSubset>
-
- org.apache.commons.geometry.euclidean.twod.ConvexArea
-
- org.apache.commons.geometry.euclidean.twod.shape.Parallelogram
-
- 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:
- Parallelogram
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classParallelogram.BuilderClass designed to aid construction ofParallelograminstances.-
Nested classes/interfaces inherited from class org.apache.commons.geometry.core.partitioning.AbstractConvexHyperplaneBoundedRegion
AbstractConvexHyperplaneBoundedRegion.ConvexRegionBoundaryBuilder<P extends Point<P>,S extends HyperplaneConvexSubset<P>>
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<Vector2D>UNIT_SQUARE_VERTICESVertices defining a square with sides of length 1 centered on the origin.
-
Constructor Summary
Constructors Modifier Constructor Description privateParallelogram(java.util.List<LineConvexSubset> boundaries)Simple constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ParallelogramaxisAligned(Vector2D a, Vector2D b, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)Return a new instance representing an axis-aligned rectangle.static Parallelogram.Builderbuilder(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)Return a newParallelogram.Builderinstance to use for constructing parallelograms.static ParallelogramfromTransformedUnitSquare(Transform<Vector2D> transform, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)Create a new instance by transforming a unit square centered at the origin.static ParallelogramunitSquare(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)Return a new instance representing a unit square centered on the origin.-
Methods inherited from class org.apache.commons.geometry.euclidean.twod.ConvexArea
boundaryStream, convexPolygonFromPath, convexPolygonFromVertices, fromBounds, fromBounds, full, getBoundaryPaths, getCentroid, getSize, getVertices, split, toTree, transform, trim
-
Methods inherited from class org.apache.commons.geometry.core.partitioning.AbstractConvexHyperplaneBoundedRegion
classify, getBoundaries, getBoundarySize, isEmpty, isFull, project, splitInternal, swapsInsideOutside, toString, transformInternal
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.commons.geometry.euclidean.twod.BoundarySource2D
getBounds, linecast, linecastFirst, toList
-
Methods inherited from interface org.apache.commons.geometry.euclidean.twod.Linecastable2D
linecast, linecastFirst
-
Methods inherited from interface org.apache.commons.geometry.core.Sized
isFinite, isInfinite
-
-
-
-
Field Detail
-
UNIT_SQUARE_VERTICES
private static final java.util.List<Vector2D> UNIT_SQUARE_VERTICES
Vertices defining a square with sides of length 1 centered on the origin.
-
-
Constructor Detail
-
Parallelogram
private Parallelogram(java.util.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 Detail
-
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 pointsaandbare 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 ofb)b- second corner point in the rectangle (opposite ofa)precision- precision context used to construct boundaries- Returns:
- a new instance representing an axis-aligned rectangle
- Throws:
java.lang.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 squareprecision- precision context used to construct boundaries- Returns:
- a new instance constructed by transforming the unit square
- Throws:
java.lang.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 newParallelogram.Builderinstance to use for constructing parallelograms.- Parameters:
precision- precision context used to create boundaries- Returns:
- a new
Parallelogram.Builderinstance
-
-