Class Parallelogram.Builder
java.lang.Object
org.apache.commons.geometry.euclidean.twod.shape.Parallelogram.Builder
- Enclosing class:
Parallelogram
Class designed to aid construction of
Parallelogram
instances. Parallelograms are constructed
by transforming the vertices of a unit square centered at the origin with a transform built from
the values configured here. The transformations applied are scaling, rotation,
and translation, in that order. When applied in this order, the scale factors determine
the width and height of the parallelogram, the rotation determines the orientation, and the translation
determines the position of the center point.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Vector2D
Amount to translate the parallelogram.private final org.apache.commons.numbers.core.Precision.DoubleEquivalence
Precision context used to construct boundaries.private Rotation2D
The rotation of the parallelogram.private Vector2D
Amount to scale the parallelogram. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Builder
(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Construct a new instance configured with the given precision context. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build a new parallelogram instance with the values configured in this builder.setPosition
(Vector2D pos) Set the center position of the created parallelogram.setRotation
(Rotation2D rot) Set the rotation of the created parallelogram.setScale
(double scaleFactor) Set the scaling for the created parallelogram.setScale
(double x, double y) Set the scaling for the created parallelogram.Set the scaling for the created parallelogram.setXDirection
(Vector2D xDirection) Set the rotation of the created parallelogram such that the relative x-axis of the shape points in the given direction.setYDirection
(Vector2D yDirection) Set the rotation of the created parallelogram such that the relative y-axis of the shape points in the given direction.
-
Field Details
-
scale
Amount to scale the parallelogram. -
rotation
The rotation of the parallelogram. -
position
Amount to translate the parallelogram. -
precision
private final org.apache.commons.numbers.core.Precision.DoubleEquivalence precisionPrecision context used to construct boundaries.
-
-
Constructor Details
-
Builder
private Builder(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Construct a new instance configured with the given precision context.- Parameters:
precision
- precision context used to create boundaries
-
-
Method Details
-
setPosition
Set the center position of the created parallelogram.- Parameters:
pos
- center position of the created parallelogram- Returns:
- this instance
-
setScale
Set the scaling for the created parallelogram. The scale values determine the lengths of the respective sides in the created parallelogram.- Parameters:
scaleFactors
- scale factors- Returns:
- this instance
-
setScale
Set the scaling for the created parallelogram. The scale values determine the lengths of the respective sides in the created parallelogram.- Parameters:
x
- x scale factory
- y scale factor- Returns:
- this instance
-
setScale
Set the scaling for the created parallelogram. The given scale factor is applied to both the x and y directions.- Parameters:
scaleFactor
- scale factor for x and y directions- Returns:
- this instance
-
setRotation
Set the rotation of the created parallelogram.- Parameters:
rot
- the rotation of the created parallelogram- Returns:
- this instance
-
setXDirection
Set the rotation of the created parallelogram such that the relative x-axis of the shape points in the given direction.- Parameters:
xDirection
- the direction of the relative x-axis- Returns:
- this instance
- Throws:
IllegalArgumentException
- if the given vector cannot be normalized- See Also:
-
setYDirection
Set the rotation of the created parallelogram such that the relative y-axis of the shape points in the given direction.- Parameters:
yDirection
- the direction of the relative y-axis- Returns:
- this instance
- Throws:
IllegalArgumentException
- if the given vector cannot be normalized- See Also:
-
build
Build a new parallelogram instance with the values configured in this builder.- Returns:
- a new parallelogram instance
- Throws:
IllegalArgumentException
- if the length of any side of the parallelogram is zero, as determined by the configured precision context- See Also:
-