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
Class representing parallelograms, i.e. quadrilaterals with two pairs of parallel sides.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Class designed to aid construction ofParallelogram
instances.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
FieldsModifier and TypeFieldDescriptionVertices defining a square with sides of length 1 centered on the origin. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Parallelogram
(List<LineConvexSubset> boundaries) Simple constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic Parallelogram
axisAligned
(Vector2D a, Vector2D b, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return a new instance representing an axis-aligned rectangle.static Parallelogram.Builder
builder
(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return a newParallelogram.Builder
instance to use for constructing parallelograms.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.static Parallelogram
unitSquare
(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 Details
-
UNIT_SQUARE_VERTICES
Vertices defining a square with sides of length 1 centered on the origin.
-
-
Constructor Details
-
Parallelogram
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 pointsa
andb
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 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:
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:
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.Builder
instance to use for constructing parallelograms.- Parameters:
precision
- precision context used to create boundaries- Returns:
- a new
Parallelogram.Builder
instance
-